This patch makes ipactl fail if the hostname isn't fully-qualified. It
also fixes ipa-server-install to fail gracefully in such case, instead
of failing with unexpected error.
https://fedorahosted.org/freeipa/ticket/1035
Honza
--
Jan Cholasta
>From a73adeab91f294204ef8ca0d145320d7ef6aa172 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Thu, 23 Jun 2011 12:32:07 +0200
Subject: [PATCH] Verify that the hostname is fully-qualified before accessing
the service information in ipactl.
Fail gracefully if the supplied hostname isn't fully-qualified in
ipa-server-install.
ticket 1035
---
install/tools/ipa-server-install | 15 +++++++--------
install/tools/ipactl | 5 ++++-
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 019dfb1..d84627f 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -573,15 +573,14 @@ def main():
else:
host_default = get_fqdn()
- if options.unattended:
- try:
+ try:
+ if options.unattended:
verify_fqdn(host_default,options.no_host_dns)
- except RuntimeError, e:
- sys.exit(str(e) + "\n")
-
- host_name = host_default
- else:
- host_name = read_host_name(host_default,options.no_host_dns)
+ host_name = host_default
+ else:
+ host_name = read_host_name(host_default,options.no_host_dns)
+ except RuntimeError, e:
+ sys.exit(str(e) + "\n")
host_name = host_name.lower()
logging.debug("will use host_name: %s\n" % host_name)
diff --git a/install/tools/ipactl b/install/tools/ipactl
index 4ce2606..a944517 100755
--- a/install/tools/ipactl
+++ b/install/tools/ipactl
@@ -71,7 +71,7 @@ def emit_err(err):
sys.stderr.write(err + '\n')
def get_config():
- base = "cn=%s,cn=masters,cn=ipa,cn=etc,%s" % (socket.gethostname(),
+ base = "cn=%s,cn=masters,cn=ipa,cn=etc,%s" % (api.env.host,
api.env.basedn)
srcfilter = '(ipaConfigString=enabledService)'
attrs = ['cn', 'ipaConfigString']
@@ -295,6 +295,9 @@ def main():
api.bootstrap(context='cli', debug=options.debug)
api.finalize()
+ if '.' not in api.env.host:
+ raise IpactlError("Invalid hostname, must be fully-qualified")
+
if args[0].lower() == "start":
ipa_start()
elif args[0].lower() == "stop":
--
1.7.4.4
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel