From 393f4bc548888ffbeb6e1484d9988a3a077db940 Mon Sep 17 00:00:00 2001 From: Mike McCallister Date: Thu, 4 Aug 2011 23:54:29 -0500 Subject: Removed the explicit calls to AddEntry from SSHbase.py in favor of allowing the normal FileMonitor events to populate the data structures. We now call the File Monitor's handle_events_in_interval() method after generating new host keys, so that the normal code paths can populate the data structures used for binding to file data. We need the explicit call because we can't wait for the server's normal event queue processing to discover the changes; we need the newly-generated keys available immediately for binding during the current connection with the client. (cherry picked from commit 74a6e4707725710f6629b292902f2312710e4980) --- src/lib/Server/Plugins/SSHbase.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib/Server/Plugins/SSHbase.py') diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index 8cc4ef6f7..5e6acd39d 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -223,6 +223,13 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, filename = "%s.H_%s" % (entry.get('name').split('/')[-1], client) if filename not in list(self.entries.keys()): self.GenerateHostKeys(client) + # Service the FAM events queued up by the key generation so + # the data structure entries will be available for binding. + # NOTE: We're only waiting for one second. This seems ripe for + # a potential race condition, because if the file monitor + # doesn't get notified about the new key files in time, those + # entries won't be available for binding. + self.fam.handle_events_in_interval(1) if not filename in self.entries: self.logger.error("%s still not registered" % filename) raise Bcfg2.Server.Plugin.PluginExecutionError @@ -264,9 +271,6 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, os.system(cmd % (temploc, keytype, client)) shutil.copy(temploc, fileloc) shutil.copy("%s.pub" % temploc, publoc) - self.AddEntry(hostkey) - self.AddEntry(".".join([hostkey.split('.')[0]] + ['pub', "H_%s" \ - % client])) try: os.unlink(temploc) os.unlink("%s.pub" % temploc) -- cgit v1.2.3-1-g7c22