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.
This commit is contained in:
Lubomir Rintel
2015-12-04 18:01:16 +01:00
parent 546272b216
commit d6d343ef65

View File

@@ -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); nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
ret = sethostname (name, strlen (name)); ret = sethostname (name, strlen (name));
if (ret != 0) { if (ret != 0) {
int errsv = errno;
nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s", 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); return (ret == 0);