diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-08-05 17:29:20 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-08-05 17:29:20 +0000 |
commit | 9ef9c703159404dba311e18624d2fdd5fb399020 (patch) | |
tree | ebd19c69f8b96ca5b3c48444d0194de9815a828c /src | |
parent | 3e55be9beb131b33b56985053f05272918ecb4b8 (diff) | |
download | bcfg2-9ef9c703159404dba311e18624d2fdd5fb399020.tar.gz bcfg2-9ef9c703159404dba311e18624d2fdd5fb399020.tar.bz2 bcfg2-9ef9c703159404dba311e18624d2fdd5fb399020.zip |
SSHbase: improve tempfile handling (patch from f.pauget) (Resolves Ticket #588)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4854 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Tools/RPMng.py | 14 | ||||
-rw-r--r-- | src/lib/Client/Tools/__init__.py | 7 | ||||
-rw-r--r-- | src/lib/Server/Plugins/SSHbase.py | 6 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Statistics.py | 7 |
4 files changed, 28 insertions, 6 deletions
diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py index 21813e283..c1eec1ab6 100644 --- a/src/lib/Client/Tools/RPMng.py +++ b/src/lib/Client/Tools/RPMng.py @@ -108,6 +108,16 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.verify_fail_action = 'none' self.logger.debug('verify_fail_action = %s' % self.verify_fail_action) + # version_fail_action + if RPMng_CP.has_option(self.__name__, 'verify_flags'): + self.verify_flags = RPMng_CP.get(self.__name__, 'verify_flags').lower().split(',') + else: + self.verify_flags = [] + if '' in self.verify_flags: + self.verify_flags.remove('') + self.logger.debug('version_fail_action = %s' % self.version_fail_action) + + def RefreshPackages(self): ''' Creates self.installed{} which is a dict of installed packages. @@ -202,7 +212,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): if self.pkg_verify == 'true' and \ inst.get('pkg_verify', 'true') == 'true': - flags = inst.get('verify_flags', '').split(',') + flags = inst.get('verify_flags', '').split(',') + self.verify_flags if pkg.get('gpgkeyid', '')[-8:] not in self.gpg_keyids and \ entry.get('name') != 'gpg-pubkey': flags += ['nosignature', 'nodigest'] @@ -257,7 +267,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): if self.pkg_verify == 'true' and \ inst.get('pkg_verify', 'true') == 'true': - flags = inst.get('verify_flags', '').split(',') + flags = inst.get('verify_flags', '').split(',') + self.verify_flags if pkg.get('gpgkeyid', '')[-8:] not in self.gpg_keyids: flags += ['nosignature', 'nodigest'] self.logger.info('WARNING: Package %s %s requires GPG Public key with ID %s'\ diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index cda5d83cc..5333752bb 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -148,8 +148,11 @@ class Tool: '''Build a list of potentially modified POSIX paths for this entry''' if struct.tag != 'Bundle': return [] - return [sentry.get('name') for sentry in struct if sentry.tag in \ - ['ConfigFile', 'SymLink', 'Directory', 'Permissions']] + basic = [sentry.get('name') for sentry in struct if sentry.tag in \ + ['ConfigFile', 'SymLink', 'Directory', 'Permissions']] + pdir = ["@%s" % (sentry.get('name')) for sentry in struct if entry.tag \ + == 'Directory' and entry.get('prune', 'false') == 'true'] + return basic + pdir def gatherCurrentData(self, entry): '''Default implementation of the information gathering routines''' diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index cdd95181b..8da2f4429 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -1,7 +1,7 @@ '''This module manages ssh key files for bcfg2''' __revision__ = '$Revision$' -import binascii, os, socket +import binascii, os, socket, tempfile import Bcfg2.Server.Plugin class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.DirectoryBacked): @@ -176,7 +176,8 @@ class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.Director if hostkey not in self.entries.keys(): fileloc = "%s/%s" % (self.data, hostkey) publoc = self.data + '/' + ".".join([hostkey.split('.')[0]]+['pub', "H_%s" % client]) - temploc = "/tmp/%s" % hostkey + tempdir = tempfile.mkdtemp() + temploc = "%s/%s" % (tempdir, hostkey) os.system('ssh-keygen -q -f %s -N "" -t %s -C root@%s < /dev/null' % (temploc, keytype, client)) open(fileloc, 'w').write(open(temploc).read()) @@ -186,6 +187,7 @@ class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.Director try: os.unlink(temploc) os.unlink("%s.pub" % temploc) + os.rmdir(tempdir) except OSError: self.logger.error("Failed to unlink temporary ssh keys") diff --git a/src/lib/Server/Plugins/Statistics.py b/src/lib/Server/Plugins/Statistics.py index bc6e648bf..41de7ba4b 100644 --- a/src/lib/Server/Plugins/Statistics.py +++ b/src/lib/Server/Plugins/Statistics.py @@ -117,4 +117,11 @@ class Statistics(Bcfg2.Server.Plugin.StatisticsPlugin): def WriteBack(self): self.data.WriteBack() + + def FindCurrent(self, client): + rt = self.data.element.xpath('//Node[@name="%s"]' % client) + maxtime = max([time.strptime(stat.get('time')) for stat in rt.findall('Statistics')]) + return [stat for stat in rt.findall('Statistics') if time.strptime(stat.get('time')) == maxtime][0] + def GetExtra(self, client): + return [(entry.tag, entry.get('name')) for entry in self.FindCurrent(client).xpath('.//Extra/*')] |