X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fhostname%2Fhostnamed.c;h=6aa08cacb0385c5aca1af01638c55b30f69850c5;hp=e98bd42f2d8d7c06b17174ac0cc62d7507d008f0;hb=1b9e5b126359a2a2ec37de1f94f046093abc74b8;hpb=ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602 diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index e98bd42f2..6aa08cacb 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -123,7 +123,7 @@ static const char* fallback_chassis(void) { int r; char *type; unsigned t; - Virtualization v; + int v; v = detect_virtualization(NULL); @@ -546,11 +546,11 @@ static const sd_bus_vtable hostname_vtable[] = { SD_BUS_PROPERTY("PrettyHostname", "s", NULL, offsetof(Context, data) + sizeof(char*) * PROP_PRETTY_HOSTNAME, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("IconName", "s", property_get_icon_name, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Chassis", "s", property_get_chassis, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), - SD_BUS_METHOD("SetHostname", "sb", NULL, method_set_hostname, 0), - SD_BUS_METHOD("SetStaticHostname", "sb", NULL, method_set_static_hostname, 0), - SD_BUS_METHOD("SetPrettyHostname", "sb", NULL, method_set_pretty_hostname, 0), - SD_BUS_METHOD("SetIconName", "sb", NULL, method_set_icon_name, 0), - SD_BUS_METHOD("SetChassis", "sb", NULL, method_set_chassis, 0), + SD_BUS_METHOD("SetHostname", "sb", NULL, method_set_hostname, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetStaticHostname", "sb", NULL, method_set_static_hostname, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetPrettyHostname", "sb", NULL, method_set_pretty_hostname, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetIconName", "sb", NULL, method_set_icon_name, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetChassis", "sb", NULL, method_set_chassis, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_VTABLE_END, }; @@ -574,17 +574,12 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) { return r; } - r = sd_bus_request_name(bus, "org.freedesktop.hostname1", SD_BUS_NAME_DO_NOT_QUEUE); + r = sd_bus_request_name(bus, "org.freedesktop.hostname1", 0); if (r < 0) { log_error("Failed to register name: %s", strerror(-r)); return r; } - if (r != SD_BUS_NAME_PRIMARY_OWNER) { - log_error("Failed to acquire name."); - return -EEXIST; - } - r = sd_bus_attach_event(bus, event, 0); if (r < 0) { log_error("Failed to attach bus to event loop: %s", strerror(-r)); @@ -632,24 +627,24 @@ int main(int argc, char *argv[]) { goto finish; } + sd_event_set_watchdog(event, true); + r = connect_bus(&context, event, &bus); if (r < 0) goto finish; r = context_read_data(&context); if (r < 0) { - log_error("Failed to read timezone data: %s", strerror(-r)); + log_error("Failed to read hostname and machine information: %s", strerror(-r)); goto finish; } - r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC); + r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC, NULL, NULL); if (r < 0) { log_error("Failed to run event loop: %s", strerror(-r)); goto finish; } - r = 0; - finish: context_free(&context, bus);