mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-04 02:28:34 +00:00
Added keychain chpass
This commit is contained in:
parent
6c672b1ee5
commit
57a79f547b
2 changed files with 21 additions and 2 deletions
|
@ -83,6 +83,10 @@ class Archiver(object):
|
|||
def do_keychain_restrict(self, args):
|
||||
return KeyChain(args.input).restrict(args.output)
|
||||
|
||||
def do_keychain_chpass(self, args):
|
||||
return KeyChain(args.keychain).chpass()
|
||||
|
||||
|
||||
def run(self, args=None):
|
||||
parser = argparse.ArgumentParser(description='Dedupestore')
|
||||
parser.add_argument('-k', '--key-chain', dest='keychain', type=str,
|
||||
|
@ -105,6 +109,10 @@ class Archiver(object):
|
|||
subparser.add_argument('output', metavar='OUTPUT', type=str,
|
||||
help='Keychain to create')
|
||||
subparser.set_defaults(func=self.do_keychain_restrict)
|
||||
subparser = subsubparsers.add_parser('chpass')
|
||||
subparser.add_argument('keychain', metavar='KEYCHAIN', type=str,
|
||||
help='Path to keychain')
|
||||
subparser.set_defaults(func=self.do_keychain_chpass)
|
||||
|
||||
subparser = subparsers.add_parser('create')
|
||||
subparser.set_defaults(func=self.do_create)
|
||||
|
|
|
@ -20,6 +20,7 @@ class KeyChain(object):
|
|||
|
||||
def __init__(self, path=None):
|
||||
self.aes_id = self.rsa_read = self.rsa_create = None
|
||||
self.path = path
|
||||
if path:
|
||||
self.open(path)
|
||||
|
||||
|
@ -87,13 +88,23 @@ class KeyChain(object):
|
|||
self.save(path, self.password)
|
||||
return 0
|
||||
|
||||
def chpass(self):
|
||||
self.rsa_read = self.rsa_read.publickey()
|
||||
password, password2 = 1, 2
|
||||
while password != password2:
|
||||
password = getpass('New password: ')
|
||||
password2 = getpass('New password again: ')
|
||||
if password != password2:
|
||||
logging.error('Passwords do not match')
|
||||
self.save(self.path, password)
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def generate(path):
|
||||
if os.path.exists(path):
|
||||
logging.error('%s already exists', path)
|
||||
return 1
|
||||
password = ''
|
||||
password2 = 'x'
|
||||
password, password2 = 1, 2
|
||||
while password != password2:
|
||||
password = getpass('Keychain password: ')
|
||||
password2 = getpass('Keychain password again: ')
|
||||
|
|
Loading…
Add table
Reference in a new issue