diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Generators/SSHbase.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/Server/Generators/SSHbase.py b/src/lib/Server/Generators/SSHbase.py index eab268ec0..36c06b0fe 100644 --- a/src/lib/Server/Generators/SSHbase.py +++ b/src/lib/Server/Generators/SSHbase.py @@ -4,6 +4,7 @@ __revision__ = '$Revision$' from binascii import b2a_base64 from os import rename, system from socket import gethostbyname, gaierror +from syslog import syslog, LOG_ERR from Bcfg2.Server.Generator import Generator, DirectoryBacked @@ -50,11 +51,14 @@ class SSHbase(Generator): '''This function builds builds a host specific known_hosts file''' client = metadata.hostname filedata = self.repository.entries['ssh_known_hosts'].data - ipaddr = gethostbyname(client) - keylist = [keytmpl % client for keytmpl in self.pubkeys] - for hostkey in keylist: - filedata += "%s,%s,%s %s" % (client, "%s.mcs.anl.gov"%(client), - ipaddr, self.repository.entries[hostkey].data) + try: + ipaddr = gethostbyname(client) + # add client-specific key lines + for hostkey in [keytmpl % client for keytmpl in self.pubkeys]: + filedata += "%s,%s,%s %s" % (client, "%s.mcs.anl.gov"%(client), + ipaddr, self.repository.entries[hostkey].data) + except gaierror: + syslog(LOG_ERR, "SSHbase: DNS lookup failed for client %s" % client) entry.attrib.update({'owner':'root', 'group':'root', 'perms':'0644'}) entry.text = filedata |