diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-06 05:06:40 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-06 05:06:40 +0200 |
commit | 9a1ac7b9ae2fb218170d1bd106d5351a76d03a95 (patch) | |
tree | 8ecf93875c1a749fa68e15ccce05d7fa20c49968 /src/systemctl.c | |
parent | 59a3e1bc46819d69df6353a86aa0e796cd821024 (diff) |
install: implement --start option
Diffstat (limited to 'src/systemctl.c')
-rw-r--r-- | src/systemctl.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/src/systemctl.c b/src/systemctl.c index 76f6b84aa5..73b0fc48cc 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -41,6 +41,7 @@ #include "special.h" #include "initreq.h" #include "strv.h" +#include "dbus-common.h" static const char *arg_type = NULL; static const char *arg_property = NULL; @@ -106,32 +107,6 @@ static int bus_iter_get_basic_and_next(DBusMessageIter *iter, int type, void *da return 0; } -static int bus_check_peercred(DBusConnection *c) { - int fd; - struct ucred ucred; - socklen_t l; - - assert(c); - - assert_se(dbus_connection_get_unix_fd(c, &fd)); - - l = sizeof(struct ucred); - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0) { - log_error("SO_PEERCRED failed: %m"); - return -errno; - } - - if (l != sizeof(struct ucred)) { - log_error("SO_PEERCRED returned wrong size."); - return -E2BIG; - } - - if (ucred.uid != 0) - return -EPERM; - - return 1; -} - static int columns(void) { static int parsed_columns = 0; const char *e; @@ -3264,19 +3239,7 @@ int main(int argc, char*argv[]) { goto finish; } - /* If we are root, then let's not go via the bus */ - if (geteuid() == 0 && !arg_session) { - bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", &error); - - if (bus && bus_check_peercred(bus) < 0) { - log_error("Failed to verify owner of bus."); - goto finish; - } - } else - bus = dbus_bus_get(arg_session ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error); - - if (bus) - dbus_connection_set_exit_on_disconnect(bus, FALSE); + bus_connect(arg_session ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &bus, &error); switch (arg_action) { |