X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fhostnamed.c;h=ce690453445ba7db8c8605cf483aa7733ce051c7;hb=f8e08a77e7bbea802b50adcb442f99af462fa96e;hp=8c0035a03774c17ee837ce7cb22bf3747cebbda6;hpb=4f34ed54f854ff7eeede44cbb99a9fd27a5dce71;p=elogind.git diff --git a/src/hostnamed.c b/src/hostnamed.c index 8c0035a03..ce6904534 100644 --- a/src/hostnamed.c +++ b/src/hostnamed.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "util.h" #include "strv.h" @@ -110,6 +111,18 @@ static int read_data(void) { return 0; } +static bool check_nss(void) { + + void *dl; + + if ((dl = dlopen("libnss_myhostname.so.2", RTLD_LAZY))) { + dlclose(dl); + return true; + } + + return false; +} + static const char* fallback_icon_name(void) { #if defined(__i386__) || defined(__x86_64__) @@ -568,7 +581,13 @@ static DBusHandlerResult hostname_message_handler( if (!streq_ptr(name, data[k])) { - r = verify_polkit(connection, message, "org.freedesktop.hostname1.set-machine-info", interactive, &error); + /* Since the pretty hostname should always be + * changed at the same time as the static one, + * use the same policy action for both... */ + + r = verify_polkit(connection, message, k == PROP_PRETTY_HOSTNAME ? + "org.freedesktop.hostname1.set-static-hostname" : + "org.freedesktop.hostname1.set-machine-info", interactive, &error); if (r < 0) return bus_send_error_reply(connection, message, &error, r); @@ -657,6 +676,9 @@ int main(int argc, char *argv[]) { goto finish; } + if (!check_nss()) + log_warning("Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!"); + umask(0022); r = read_data();