From aadc88bc25c4f64dd395aca2dd5c7a0a85c94c4d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 12 Apr 2012 00:42:26 +0200 Subject: [PATCH] Remove pakfire keyring installation stuff. This is not a very handy idea to generate random keys. --- python/pakfire/api.py | 5 ----- python/pakfire/builder.py | 7 ------- python/pakfire/cli.py | 12 ------------ python/pakfire/keyring.py | 32 +++++++------------------------- 4 files changed, 7 insertions(+), 49 deletions(-) diff --git a/python/pakfire/api.py b/python/pakfire/api.py index 9e57edd7a..5203c5fdb 100644 --- a/python/pakfire/api.py +++ b/python/pakfire/api.py @@ -135,11 +135,6 @@ def cache_create(**pakfire_args): # Key functions. -def key_init(**pakfire_args): - pakfire = Pakfire(**pakfire_args) - - return pakfire.keyring.init() - def key_generate(realname, email, **pakfire_args): pakfire = Pakfire(**pakfire_args) diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index 6123b4d93..8661dc16b 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -276,14 +276,7 @@ class BuildEnviron(object): def keyring(self): """ Shortcut to access the pakfire keyring. - - (Makes also sure that it is properly initialized.) """ - assert self.pakfire - - if not self.pakfire.keyring.initialized: - self.pakfire.keyring.init() - return self.pakfire.keyring def lock(self): diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index 2275ded31..cccd9868f 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -1145,7 +1145,6 @@ class CliKey(Cli): # Add sub-commands. self.sub_commands = self.parser.add_subparsers() - self.parse_command_init() self.parse_command_generate() self.parse_command_import() self.parse_command_export() @@ -1161,7 +1160,6 @@ class CliKey(Cli): self.pakfire = pakfire.Pakfire(**self.pakfire_args) self.action2func = { - "init" : self.handle_init, "generate" : self.handle_generate, "import" : self.handle_import, "export" : self.handle_export, @@ -1179,12 +1177,6 @@ class CliKey(Cli): return ret - def parse_command_init(self): - # Parse "init" command. - sub_init = self.sub_commands.add_parser("init", - help=_("Initialize the local keyring.")) - sub_init.add_argument("action", action="store_const", const="init") - def parse_command_generate(self): # Parse "generate" command. sub_gen = self.sub_commands.add_parser("generate", @@ -1247,10 +1239,6 @@ class CliKey(Cli): help=_("Package(s) to verify.")) sub_verify.add_argument("action", action="store_const", const="verify") - def handle_init(self): - # Initialize the keyring... - pakfire.key_init(**self.pakfire_args) - def handle_generate(self): realname = self.args.realname[0] email = self.args.email[0] diff --git a/python/pakfire/keyring.py b/python/pakfire/keyring.py index c7da4b350..8e78e9d17 100644 --- a/python/pakfire/keyring.py +++ b/python/pakfire/keyring.py @@ -54,42 +54,24 @@ class Keyring(object): return KEYRING_DIR def create_path(self): + if os.path.exists(self.path): + os.chmod(self.path, 700) + else: + os.makedirs(self.path, 700) + filename = os.path.join(self.path, "gnupg.conf") if os.path.exists(filename): + os.chmod(filename, 600) return - if not os.path.exists(self.path): - os.makedirs(self.path) - # XXX chmod 700 - # Create a default gnupg.conf. f = open(filename, "w") f.write("# This is a default gnupg configuration file created by\n") f.write("# Pakfire %s.\n" % PAKFIRE_VERSION) f.close() - # XXX chmod 600 - - @property - def initialized(self): - """ - Returns true if the local keyring was already initialized. - """ - if self.get_host_key(): - return True - - return False - - def init(self): - # If the host key is already present, we break up. - if self.initialized: - log.error(_("The local keyring is already initialized. Aborting.")) - return - - log.info(_("Initializing local keyring...")) - hostname, domainname = system.hostname.split(".", 1) - self.gen_key(system.hostname, "%s@%s" % (hostname, domainname)) + os.chmod(filename, 600) def dump_key(self, keyfp): ret = [] -- 2.39.5