summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McCallister <mike@mccllstr.com>2011-08-04 23:54:29 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-08-05 07:50:56 -0500
commit393f4bc548888ffbeb6e1484d9988a3a077db940 (patch)
tree461e4ed020161a24d0c10f5961533bb361207352
parentf4a35efec1b6a1e54d61cf1b8bfc83dd1d89eef7 (diff)
downloadbcfg2-393f4bc548888ffbeb6e1484d9988a3a077db940.tar.gz
bcfg2-393f4bc548888ffbeb6e1484d9988a3a077db940.tar.bz2
bcfg2-393f4bc548888ffbeb6e1484d9988a3a077db940.zip
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)
-rw-r--r--src/lib/Server/Plugins/SSHbase.py10
1 files changed, 7 insertions, 3 deletions
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)