diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2004-11-11 15:49:05 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2004-11-11 15:49:05 +0000 |
commit | 7baf3d842699f819522d4a960e82750aff596402 (patch) | |
tree | 4ae84e70112425394720131c93dddb08a8e25798 /src/lib/Server | |
parent | 6d2a3aa863882c0b6d0e5642c4906b08375e1689 (diff) | |
download | bcfg2-7baf3d842699f819522d4a960e82750aff596402.tar.gz bcfg2-7baf3d842699f819522d4a960e82750aff596402.tar.bz2 bcfg2-7baf3d842699f819522d4a960e82750aff596402.zip |
add syslog imports
2004/11/10 16:06:00-06:00 anl.gov!desai
fix lookup error
(Logical change 1.151)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@670 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-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 |