summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-02-25 16:53:08 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-02-25 16:53:08 -0500
commit613a485c4798b38a65042e9d78968896c590fdd0 (patch)
tree7c62aedcb6a2128f07d6f0eea48a117221f8f8cf
parentd6dfdb25c4e8be31d77ba8db7c3499e3f10e0c4b (diff)
downloadcertmaster-613a485c4798b38a65042e9d78968896c590fdd0.tar.gz
certmaster-613a485c4798b38a65042e9d78968896c590fdd0.tar.xz
certmaster-613a485c4798b38a65042e9d78968896c590fdd0.zip
Certmaster hostname check is different than minion check
-rwxr-xr-xcertmaster/certmaster.py2
-rwxr-xr-xcertmaster/utils.py32
2 files changed, 17 insertions, 17 deletions
diff --git a/certmaster/certmaster.py b/certmaster/certmaster.py
index fe5dcbc..9ebd66b 100755
--- a/certmaster/certmaster.py
+++ b/certmaster/certmaster.py
@@ -39,7 +39,7 @@ class CertMaster(object):
def __init__(self, conf_file=CERTMASTER_CONFIG):
self.cfg = read_config(conf_file, CMConfig)
- usename = utils.get_hostname()
+ usename = utils.get_hostname(talk_to_certmaster=False)
mycn = '%s-CA-KEY' % usename
self.ca_key_file = '%s/funcmaster.key' % self.cfg.cadir
diff --git a/certmaster/utils.py b/certmaster/utils.py
index 7927c55..3dec6a5 100755
--- a/certmaster/utils.py
+++ b/certmaster/utils.py
@@ -75,7 +75,7 @@ def is_error(result):
return True
return False
-def get_hostname():
+def get_hostname(talk_to_certmaster=True):
"""
"localhost" is a lame hostname to use for a key, so try to get
a more meaningful hostname. We do this by connecting to the certmaster
@@ -94,23 +94,23 @@ def get_hostname():
if ip != "127.0.0.1":
return hostname
+ if talk_to_certmaster:
+ config_file = '/etc/certmaster/minion.conf'
+ config = read_config(config_file, MinionConfig)
- config_file = '/etc/certmaster/minion.conf'
- config = read_config(config_file, MinionConfig)
-
- server = config.certmaster
- port = 51235
+ server = config.certmaster
+ port = 51235
- try:
- s = socket.socket()
- s.settimeout(5)
- s.connect((server, port))
- (intf, port) = s.getsockname()
- hostname = socket.gethostbyaddr(intf)[0]
- s.close()
- except:
- s.close()
- raise
+ try:
+ s = socket.socket()
+ s.settimeout(5)
+ s.connect((server, port))
+ (intf, port) = s.getsockname()
+ hostname = socket.gethostbyaddr(intf)[0]
+ s.close()
+ except:
+ s.close()
+ raise
return hostname