backups: don't echo entered passwords

This commit is contained in:
Marek Marczykowski-Górecki 2013-11-24 03:19:11 +01:00
parent 61b3a81e82
commit 6c61e79ebf
2 changed files with 4 additions and 4 deletions

View File

@ -26,6 +26,7 @@ from qubes.qubesutils import backup_prepare, backup_do_copy
from optparse import OptionParser from optparse import OptionParser
import os import os
import sys import sys
import getpass
def print_progress(progress): def print_progress(progress):
print >> sys.stderr, "\r-> Backing up files: {0}%...".format (progress), print >> sys.stderr, "\r-> Backing up files: {0}%...".format (progress),
@ -92,8 +93,7 @@ def main():
if not (prompt == "y" or prompt == "Y"): if not (prompt == "y" or prompt == "Y"):
exit (0) exit (0)
passphrase = raw_input("Please enter the pass phrase that will be used to encrypt/verify the backup:\n") passphrase = getpass.getpass("Please enter the pass phrase that will be used to encrypt/verify the backup: ")
passphrase = passphrase.replace("\r","").replace("\n","")
try: try:
backup_do_copy(base_backup_dir, files_to_backup, passphrase, progress_callback=print_progress, encrypt=options.encrypt,appvm=options.appvm) backup_do_copy(base_backup_dir, files_to_backup, passphrase, progress_callback=print_progress, encrypt=options.encrypt,appvm=options.appvm)

View File

@ -30,6 +30,7 @@ from optparse import OptionParser
import os import os
import sys import sys
import getpass
def main(): def main():
usage = "usage: %prog [options] <backup-dir>" usage = "usage: %prog [options] <backup-dir>"
@ -95,8 +96,7 @@ def main():
restore_options['exclude'] = options.exclude restore_options['exclude'] = options.exclude
passphrase = raw_input("Please enter the pass phrase that will be used to decrypt/verify the backup:\n") passphrase = getpass.getpass("Please enter the pass phrase that will be used to decrypt/verify the backup: ")
passphrase = passphrase.replace("\r","").replace("\n","")
print >> sys.stderr, "Checking backup content..." print >> sys.stderr, "Checking backup content..."
restore_tmpdir,qubes_xml = backup_restore_header(backup_dir, passphrase, options.decrypt, appvm=options.appvm) restore_tmpdir,qubes_xml = backup_restore_header(backup_dir, passphrase, options.decrypt, appvm=options.appvm)