X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fhostname%2Fhostnamed.c;h=ede818578817b08b782eee60684092d292fb1819;hb=b44787bd437f4051660272b37bd6f75392f17931;hp=970e8007690982abc503edbfc984c8300595c271;hpb=f7340ab269828d917cd1281e33e6dd4fdfee67b3;p=elogind.git diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 970e80076..ede818578 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "util.h" #include "strv.h" @@ -34,6 +33,7 @@ #include "label.h" #include "bus-util.h" #include "event-util.h" +#include "selinux-util.h" #define VALID_DEPLOYMENT_CHARS (DIGITS LETTERS "-.:") @@ -427,7 +427,14 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s if (streq_ptr(name, c->data[PROP_HOSTNAME])) return sd_bus_reply_method_return(m, NULL); - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.hostname1.set-hostname", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + "org.freedesktop.hostname1.set-hostname", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -469,7 +476,14 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME])) return sd_bus_reply_method_return(m, NULL); - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, "org.freedesktop.hostname1.set-static-hostname", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + "org.freedesktop.hostname1.set-static-hostname", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -534,10 +548,14 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop * same time as the static one, use the same policy action for * both... */ - r = bus_verify_polkit_async(m, CAP_SYS_ADMIN, - prop == PROP_PRETTY_HOSTNAME ? - "org.freedesktop.hostname1.set-static-hostname" : - "org.freedesktop.hostname1.set-machine-info", interactive, &c->polkit_registry, error); + r = bus_verify_polkit_async( + m, + CAP_SYS_ADMIN, + prop == PROP_PRETTY_HOSTNAME ? "org.freedesktop.hostname1.set-static-hostname" : "org.freedesktop.hostname1.set-machine-info", + interactive, + UID_INVALID, + &c->polkit_registry, + error); if (r < 0) return r; if (r == 0) @@ -552,7 +570,7 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop /* The icon name might ultimately be used as file * name, so better be safe than sorry */ - if (prop == PROP_ICON_NAME && !filename_is_safe(name)) + if (prop == PROP_ICON_NAME && !filename_is_valid(name)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid icon name '%s'", name); if (prop == PROP_PRETTY_HOSTNAME && string_has_cc(name, NULL)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid pretty host name '%s'", name);