From: Mark Hymers Date: Fri, 29 Jul 2011 20:02:57 +0000 (+0100) Subject: Create keyrings if necessary X-Git-Tag: debian-r/squeeze~94^2~25 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4e63dbea5b75d2f51829fdd23ccb40dbad9f7387;p=dak.git Create keyrings if necessary Signed-off-by: Mark Hymers --- diff --git a/dak/init_dirs.py b/dak/init_dirs.py index 71a38311..a4703bb8 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -77,6 +77,29 @@ def process_morguesubdir(subdir): target = os.path.join(Cnf["Dir::Morgue"], Cnf[config_name]) do_dir(target, config_name) +def process_keyring(fullpath, secret=False): + """Create empty keyring if necessary.""" + + if os.path.exists(fullpath): + return + + keydir = os.path.dirname(fullpath) + + if not os.path.isdir(keydir): + print "Creating %s ..." % (keydir) + os.makedirs(keydir) + if secret: + # Make sure secret keyring directories are 0700 + os.chmod(keydir, 0700) + + # Touch the file + print "Creating %s ..." % (fullpath) + file(fullpath, 'w') + if secret: + os.chmod(fullpath, 0600) + else: + os.chmod(fullpath, 0644) + ###################################################################### def create_directories(): @@ -100,6 +123,17 @@ def create_directories(): suite_suffix = "%s" % (Cnf.Find("Dinstall::SuiteSuffix")) + # Process secret keyrings + if Cnf.has_key('Dinstall::SigningKeyring'): + process_keyring(Cnf['Dinstall::SigningKeyring'], secret=True) + + if Cnf.has_key('Dinstall::SigningPubKeyring'): + process_keyring(Cnf['Dinstall::SigningPubKeyring'], secret=True) + + # Process public keyrings + for keyring in session.query(Keyring).all(): + process_keyring(keyring.keyring_name) + # Process pool directories for component in session.query(Component): directory = os.path.join( Cnf['Dir::Pool'], component.component_name )