X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdbus-manager.c;h=1f5a7d94fd1603c6607af64337dd4d3a6c2f5c03;hb=ef42202ac8ed27e7ff1fc90ef8bc2590046dff25;hp=8f4bbc59b786231d04efc368072623a3a6515b3d;hpb=37d3ab1b7e114f0fb6dfb2e7273569b42794b76a;p=elogind.git diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 8f4bbc59b..1f5a7d94f 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -290,8 +290,8 @@ " \n" \ " \n" \ " \n" \ - " \n" \ - " \n" \ + " \n" \ + " \n" \ " \n" #define BUS_MANAGER_INTERFACE_END \ @@ -1186,11 +1186,9 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, if (!client) goto oom; - r = set_put(s, client); - if (r < 0) { - free(client); + r = set_consume(s, client); + if (r < 0) return bus_send_error_reply(connection, message, NULL, r); - } reply = dbus_message_new_method_return(message); if (!reply) @@ -1481,7 +1479,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SwitchRoot")) { const char *switch_root, *switch_root_init; char *u, *v; - int k; + bool good; SELINUX_ACCESS_CHECK(connection, message, "reboot"); @@ -1506,19 +1504,18 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, /* Safety check */ if (isempty(switch_root_init)) - k = access(switch_root, F_OK); + good = path_is_os_tree(switch_root); else { - char *p; + _cleanup_free_ char *p = NULL; p = strjoin(switch_root, "/", switch_root_init, NULL); if (!p) goto oom; - k = access(p, X_OK); - free(p); + good = access(p, X_OK) >= 0; } - if (k < 0) - return bus_send_error_reply(connection, message, NULL, -errno); + if (!good) + return bus_send_error_reply(connection, message, NULL, -EINVAL); u = strdup(switch_root); if (!u) @@ -1894,7 +1891,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } if (reply) - if (!dbus_connection_send(connection, reply, NULL)) + if (!bus_maybe_send_reply(connection, message, reply)) goto oom; return DBUS_HANDLER_RESULT_HANDLED;