aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraeroniero33 <justthisthing@gmail.com>2016-06-17 13:56:24 +0000
committerBrian Dolbec <dolsen@gentoo.org>2016-12-24 01:40:26 -0800
commit6b82f9204cb0522b6393fe673d7c4ed4617183c9 (patch)
tree10e9f796ea65b533631e8ecb97246140086a3a2b
parentFixed a bug in the verify function (diff)
downloadgentoo-keys-6b82f920.tar.gz
gentoo-keys-6b82f920.tar.bz2
gentoo-keys-6b82f920.zip
Made the default GPG config file overridable
<rebase edit> Remove trailing whitespace </edit Brian Dolbec>
-rw-r--r--gkeys-gen/gkeygen/actions.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py
index aaedcd1..403c779 100644
--- a/gkeys-gen/gkeygen/actions.py
+++ b/gkeys-gen/gkeygen/actions.py
@@ -127,6 +127,21 @@ class Actions(object):
self.output = output
self.logger = logger
+ def configure_config_file(self,args, gpghome):
+ '''Creates the config file'''
+ newgpgconfpath = os.path.join(gpghome, 'gpg.conf')
+ defaultpath = '/usr/share/gnupg/gpg-conf.skel'
+ file_exists = False
+ while not file_exists:
+ skelconfpath = py_input("Path of default gpg configuration file to use (default: %s) " %defaultpath)
+ if len(skelconfpath) <= 0:
+ skelconfpath = defaultpath
+ file_exists = os.path.exists(skelconfpath)
+ shutil.copy(skelconfpath, newgpgconfpath)
+ with open(newgpgconfpath, 'a') as conf:
+ for line in urlopen(self.config.get_key('gpg-urls', args.spec)):
+ conf.write(_unicode(line.decode('utf-8')))
+
def genkey(self, args):
'''Generate a gpg key using a spec file'''
@@ -158,12 +173,7 @@ class Actions(object):
self.output(["\n* Creating gpg folder at %s" % gpghome_full_path])
ensure_dirs(gpghome)
# Copy default gpg-conf.skel and append glep63 requirements
- self.output(["* Creating gpg.conf file at %s" % gpghome_full_path])
- newgpgconfpath = os.path.join(gpghome, 'gpg.conf')
- shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath)
- with open(newgpgconfpath, 'a') as conf:
- for line in urlopen(self.config.get_key('gpg-urls', args.spec)):
- conf.write(_unicode(line.decode('utf-8')))
+ self.configure_config_file(args, gpghome)
# Key generation
ctx = gpgme.Context()
self.logger.info("MAIN: _action_genkey: Generating GPG key...")