From 27c4afd725a3024f72fafc11bd1d5b88bbbeabe9 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 20 Apr 2019 15:32:30 +0200 Subject: [hostname] T1336: sanitize FQDN before passing to hostnamectl Remove possible trialing (.) when invoking hostnamectl. A hostname with a trailing (.) is not supported in hostnamectl. --- src/conf_mode/host_name.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/conf_mode/host_name.py') diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index b0972a8f1..81a52e87f 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -237,7 +237,7 @@ def apply(config): if config['domain_name']: fqdn += '.' + config['domain_name'] - os.system("hostnamectl set-hostname --static {0}".format(fqdn)) + os.system("hostnamectl set-hostname --static {0}".format(fqdn.rstrip('.'))) # Restart services that use the hostname os.system("systemctl restart rsyslog.service") @@ -245,7 +245,7 @@ def apply(config): # If SNMP is running, restart it too if os.system("pgrep snmpd > /dev/null") == 0: os.system("systemctl restart snmpd.service") - + # restart pdns if it is used if os.system("/usr/bin/rec_control ping >/dev/null 2>&1") == 0: os.system("/etc/init.d/pdns-recursor restart >/dev/null") -- cgit v1.2.3