From d6d343ef65cd2f04c33a2b4790cfad24e5bc463d Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 4 Dec 2015 18:01:16 +0100 Subject: [PATCH] policy: add a friendly warning We don't want to admin CAP_SYS_ADMIN to our capability set in our .service file: If we're running with systemd then hostnamed should be used to manage the hostname, otherwise we likely have all capabilities anyway. Let the user know. Really, use systemd-hostnamed. Use it. --- src/nm-policy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index 3d67e7af0..0fc761642 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -148,8 +148,12 @@ set_system_hostname (const char *new_hostname, const char *msg) nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg); ret = sethostname (name, strlen (name)); if (ret != 0) { + int errsv = errno; + nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s", - name, errno, strerror (errno)); + name, errsv, strerror (errsv)); + if (errsv == EPERM) + nm_log_warn (LOGD_DNS, "You should use hostnamed when systemd hardening is in effect!"); } return (ret == 0);