This patch replaces all calls to utils.get_hostname() with direct calls to
socket.getfqdn(). This is actually causing a problem in our company because
we're stuck with broken /etc/hosts files.
---
certmaster/certmaster.py | 2 +-
certmaster/utils.py | 24 ++----------------------
2 files changed, 3 insertions(+), 23 deletions(-)
diff --git a/certmaster/certmaster.py b/certmaster/certmaster.py
index 981efd8..24dcb5c 100644
--- a/certmaster/certmaster.py
+++ b/certmaster/certmaster.py
@@ -55,7 +55,7 @@ class CertMaster(object):
def __init__(self, conf_file=CERTMASTER_CONFIG):
self.cfg = read_config(conf_file, CMConfig)
- usename = utils.get_hostname(talk_to_certmaster=False)
+ usename = socket.getfqdn();
mycn = '%s-CA-KEY' % usename
self.ca_key_file = '%s/certmaster.key' % self.cfg.cadir
diff --git a/certmaster/utils.py b/certmaster/utils.py
index 968d697..7f219b3 100644
--- a/certmaster/utils.py
+++ b/certmaster/utils.py
@@ -99,26 +99,6 @@ def is_error(result):
return True
return False
-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
- and seeing what interface/ip it uses to make that connection, and looking
- up the hostname for that.
- """
- # FIXME: this code ignores http proxies (which granted, we don't
- # support elsewhere either.
- hostname = None
- hostname = socket.gethostname()
- # print "DEBUG: HOSTNAME TRY1: %s" % hostname
- try:
- ip = socket.gethostbyname(hostname)
- except:
- return hostname
- if ip != "127.0.0.1":
- return hostname
-
-
# FIXME: move to requestor module and also create a verbose mode
# prints to the screen for usage by /usr/bin/certmaster-request
@@ -133,9 +113,9 @@ def create_minion_keys(hostname=None):
hn = hostname
if hn is None:
- hn = get_hostname()
+ hn = socket.getfqdn();
- if hn is None:
+ if hn == 'localhost':
raise codes.CMException("Could not determine a hostname other than
localhost")
else:
# use lowercase letters for hostnames
-- 1.5.6.5
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list