gpg: allow specifying custom homedir during init

This commit is contained in:
Roman Zeyde 2018-03-10 18:39:56 +02:00
parent cbdc52c0a4
commit 870152a7af
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -123,7 +123,10 @@ def run_init(device_type, args):
# Prepare new GPG home directory for hardware-based identity
device_name = os.path.basename(sys.argv[0]).rsplit('-', 1)[0]
log.info('device name: %s', device_name)
homedir = os.path.expanduser('~/.gnupg/{}'.format(device_name))
homedir = args.homedir
if not homedir:
homedir = os.path.expanduser('~/.gnupg/{}'.format(device_name))
log.info('GPG home directory: %s', homedir)
if os.path.exists(homedir):
@ -261,6 +264,9 @@ def main(device_type):
p.add_argument('-v', '--verbose', default=0, action='count')
p.add_argument('-s', '--subkey', default=False, action='store_true')
p.add_argument('--homedir', type=str,
help='Customize GnuPG home directory for the new identity.')
p.add_argument('--pin-entry-binary', type=str, default='pinentry',
help='Path to PIN entry UI helper.')
p.add_argument('--passphrase-entry-binary', type=str, default='pinentry',