diff options
Diffstat (limited to 'src/hostname/hostnamed.c')
-rw-r--r-- | src/hostname/hostnamed.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index a78516c8b5..dd508aefb5 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -63,10 +63,8 @@ static void context_reset(Context *c) { assert(c); - for (p = 0; p < _PROP_MAX; p++) { - free(c->data[p]); - c->data[p] = NULL; - } + for (p = 0; p < _PROP_MAX; p++) + c->data[p] = mfree(c->data[p]); } static void context_free(Context *c) { @@ -114,12 +112,11 @@ static int context_read_data(Context *c) { "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME], "CPE_NAME", &c->data[PROP_OS_CPE_NAME], NULL); - if (r == -ENOENT) { + if (r == -ENOENT) r = parse_env_file("/usr/lib/os-release", NEWLINE, "PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME], "CPE_NAME", &c->data[PROP_OS_CPE_NAME], NULL); - } if (r < 0 && r != -ENOENT) return r; @@ -155,11 +152,11 @@ static const char* fallback_chassis(void) { unsigned t; int v; - v = detect_virtualization(NULL); + v = detect_virtualization(); - if (v == VIRTUALIZATION_VM) + if (VIRTUALIZATION_IS_VM(v)) return "vm"; - if (v == VIRTUALIZATION_CONTAINER) + if (VIRTUALIZATION_IS_CONTAINER(v)) return "container"; r = read_one_line_file("/sys/firmware/acpi/pm_profile", &type); @@ -434,6 +431,7 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error * m, CAP_SYS_ADMIN, "org.freedesktop.hostname1.set-hostname", + NULL, interactive, UID_INVALID, &c->polkit_registry, @@ -486,6 +484,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_ m, CAP_SYS_ADMIN, "org.freedesktop.hostname1.set-static-hostname", + NULL, interactive, UID_INVALID, &c->polkit_registry, @@ -496,8 +495,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ if (isempty(name)) { - free(c->data[PROP_STATIC_HOSTNAME]); - c->data[PROP_STATIC_HOSTNAME] = NULL; + c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]); } else { char *h; @@ -557,6 +555,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess m, CAP_SYS_ADMIN, prop == PROP_PRETTY_HOSTNAME ? "org.freedesktop.hostname1.set-static-hostname" : "org.freedesktop.hostname1.set-machine-info", + NULL, interactive, UID_INVALID, &c->polkit_registry, @@ -567,8 +566,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ if (isempty(name)) { - free(c->data[prop]); - c->data[prop] = NULL; + c->data[prop] = mfree(c->data[prop]); } else { char *h; @@ -711,12 +709,6 @@ int main(int argc, char *argv[]) { goto finish; } - if (argc != 1) { - log_error("This program takes no arguments."); - r = -EINVAL; - goto finish; - } - r = sd_event_default(&event); if (r < 0) { log_error_errno(r, "Failed to allocate event loop: %m"); |