From 439b0ca3590bb60406628fe99aed8d8ec42b0a7efd4e6401d4f3b75c690fa2f7 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 20 May 2014 14:12:28 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=637 --- ...ic-to-query-IP-addresses-of-containe.patch | 729 ------------------ ...tate-behind-the-D-Bus-API-not-in-the.patch | 18 +- ...add-mir-to-the-list-of-session-types.patch | 90 +++ ...fix-Display-property-of-user-objects.patch | 0 systemd-mini.changes | 4 +- systemd-mini.spec | 8 +- systemd.changes | 4 +- systemd.spec | 8 +- 8 files changed, 110 insertions(+), 751 deletions(-) delete mode 100644 0003-machined-add-logic-to-query-IP-addresses-of-containe.patch create mode 100644 0006-login-add-mir-to-the-list-of-session-types.patch rename 0006-logind-fix-Display-property-of-user-objects.patch => 0007-logind-fix-Display-property-of-user-objects.patch (100%) diff --git a/0003-machined-add-logic-to-query-IP-addresses-of-containe.patch b/0003-machined-add-logic-to-query-IP-addresses-of-containe.patch deleted file mode 100644 index a2ee28b4..00000000 --- a/0003-machined-add-logic-to-query-IP-addresses-of-containe.patch +++ /dev/null @@ -1,729 +0,0 @@ -From 878cd7e95ca303f9851d227a22d2022bd49944b0 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Sun, 18 May 2014 20:48:53 +0900 -Subject: [PATCH] machined: add logic to query IP addresses of containers - ---- - src/libsystemd/sd-bus/bus-container.c | 8 +- - src/machine/machine-dbus.c | 217 ++++++++++++++++++++++++++++++++- - src/machine/machine.h | 4 + - src/machine/machinectl.c | 75 +++++++++++- - src/machine/machined-dbus.c | 45 ++++--- - src/shared/bus-errors.h | 1 + - src/shared/logs-show.c | 4 +- - src/shared/util.c | 103 ++++++++++------ - src/shared/util.h | 4 +- - 9 files changed, 384 insertions(+), 77 deletions(-) - -diff --git src/libsystemd/sd-bus/bus-container.c src/libsystemd/sd-bus/bus-container.c -index 6bd7ad6..dd4bf15 100644 ---- src/libsystemd/sd-bus/bus-container.c -+++ src/libsystemd/sd-bus/bus-container.c -@@ -42,7 +42,7 @@ int bus_container_connect_socket(sd_bus *b) { - if (r < 0) - return r; - -- r = namespace_open(leader, &pidnsfd, &mntnsfd, &rootfd); -+ r = namespace_open(leader, &pidnsfd, &mntnsfd, NULL, &rootfd); - if (r < 0) - return r; - -@@ -61,7 +61,7 @@ int bus_container_connect_socket(sd_bus *b) { - if (child == 0) { - pid_t grandchild; - -- r = namespace_enter(pidnsfd, mntnsfd, rootfd); -+ r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd); - if (r < 0) - _exit(255); - -@@ -140,7 +140,7 @@ int bus_container_connect_kernel(sd_bus *b) { - if (r < 0) - return r; - -- r = namespace_open(leader, &pidnsfd, &mntnsfd, &rootfd); -+ r = namespace_open(leader, &pidnsfd, &mntnsfd, NULL, &rootfd); - if (r < 0) - return r; - -@@ -156,7 +156,7 @@ int bus_container_connect_kernel(sd_bus *b) { - - pair[0] = safe_close(pair[0]); - -- r = namespace_enter(pidnsfd, mntnsfd, rootfd); -+ r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd); - if (r < 0) - _exit(EXIT_FAILURE); - ---- src/machine/machine-dbus.c -+++ src/machine/machine-dbus.c 2014-05-20 12:07:01.782736278 +0000 -@@ -22,10 +22,15 @@ - #include - #include - #include -+#include - -+#include "sd-rtnl.h" - #include "bus-util.h" -+#include "bus-label.h" - #include "strv.h" - #include "machine.h" -+#include "rtnl-util.h" -+#include "bus-errors.h" - - static int property_get_id( - sd_bus *bus, -@@ -78,7 +83,7 @@ static int property_get_state( - - static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_class, machine_class, MachineClass); - --static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { -+int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - Machine *m = userdata; - int r; - -@@ -93,7 +98,7 @@ static int method_terminate(sd_bus *bus, - return sd_bus_reply_method_return(message, NULL); - } - --static int method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { -+int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - Machine *m = userdata; - const char *swho; - int32_t signo; -@@ -126,6 +131,208 @@ static int method_kill(sd_bus *bus, sd_b - return sd_bus_reply_method_return(message, NULL); - } - -+int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { -+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; -+ _cleanup_close_pair_ int pair[2] = { -1, -1 }; -+ _cleanup_free_ char *us = NULL, *them = NULL; -+ _cleanup_close_ int netns_fd = -1; -+ Machine *m = userdata; -+ const char *p; -+ siginfo_t si; -+ pid_t child; -+ int r; -+ -+ assert(bus); -+ assert(message); -+ assert(m); -+ -+ r = readlink_malloc("/proc/self/ns/net", &us); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ p = procfs_file_alloca(m->leader, "ns/net"); -+ r = readlink_malloc(p, &them); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ if (streq(us, them)) -+ return sd_bus_error_setf(error, BUS_ERROR_NO_PRIVATE_NETWORKING, "Machine %s does not use private networking", m->name); -+ -+ r = namespace_open(m->leader, NULL, NULL, &netns_fd, NULL); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, pair) < 0) -+ return sd_bus_error_set_errno(error, -errno); -+ -+ child = fork(); -+ if (child < 0) -+ return sd_bus_error_set_errno(error, -errno); -+ -+ if (child == 0) { -+ _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL, *resp = NULL; -+ _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; -+ sd_rtnl_message *addr; -+ -+ pair[0] = safe_close(pair[0]); -+ -+ r = namespace_enter(-1, -1, netns_fd, -1); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ r = sd_rtnl_open(&rtnl, 0); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ r = sd_rtnl_message_new_addr(rtnl, &req, RTM_GETADDR, 0, AF_UNSPEC); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ r = sd_rtnl_message_request_dump(req, true); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ r = sd_rtnl_call(rtnl, req, 0, &resp); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ for (addr = resp; addr; addr = sd_rtnl_message_next(addr)) { -+ uint16_t type; -+ unsigned char family; -+ union { -+ struct in_addr in; -+ struct in6_addr in6; -+ } in_addr; -+ struct iovec iov[2]; -+ -+ r = sd_rtnl_message_get_type(addr, &type); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ if (type != RTM_NEWADDR) -+ continue; -+ -+ r = sd_rtnl_message_addr_get_family(addr, &family); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ iov[0] = (struct iovec) { .iov_base = &family, .iov_len = sizeof(family) }; -+ -+ switch (family) { -+ -+ case AF_INET: -+ -+ r = sd_rtnl_message_read_in_addr(addr, IFA_LOCAL, &in_addr.in); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ if (in_addr.in.s_addr == htobe32(INADDR_LOOPBACK)) -+ continue; -+ -+ iov[1] = (struct iovec) { .iov_base = &in_addr.in, .iov_len = sizeof(in_addr.in) }; -+ break; -+ -+ case AF_INET6: -+ -+ r = sd_rtnl_message_read_in6_addr(addr, IFA_ADDRESS, &in_addr.in6); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ -+ if (IN6_IS_ADDR_LOOPBACK(&in_addr.in6)) -+ continue; -+ -+ iov[1] = (struct iovec) { .iov_base = &in_addr.in6, .iov_len = sizeof(in_addr.in6) }; -+ break; -+ -+ default: -+ continue; -+ } -+ -+ r = writev(pair[1], iov, 2); -+ if (r < 0) -+ _exit(EXIT_FAILURE); -+ } -+ -+ _exit(EXIT_SUCCESS); -+ } -+ -+ pair[1] = safe_close(pair[1]); -+ -+ r = sd_bus_message_new_method_return(message, &reply); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ r = sd_bus_message_open_container(reply, 'a', "(yay)"); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ for (;;) { -+ unsigned char family; -+ ssize_t n; -+ union { -+ struct in_addr in; -+ struct in6_addr in6; -+ } in_addr; -+ struct iovec iov[2]; -+ struct msghdr mh = { -+ .msg_iov = iov, -+ .msg_iovlen = 2, -+ }; -+ -+ iov[0] = (struct iovec) { .iov_base = &family, .iov_len = sizeof(family) }; -+ iov[1] = (struct iovec) { .iov_base = &in_addr, .iov_len = sizeof(in_addr) }; -+ -+ n = recvmsg(pair[0], &mh, 0); -+ if (n < 0) -+ return sd_bus_error_set_errno(error, -errno); -+ if ((size_t) n < sizeof(family)) -+ break; -+ -+ r = sd_bus_message_open_container(reply, 'r', "yay"); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ r = sd_bus_message_append(reply, "y", family); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ switch (family) { -+ -+ case AF_INET: -+ if (n != sizeof(struct in_addr) + sizeof(family)) -+ return sd_bus_error_set_errno(error, EIO); -+ -+ r = sd_bus_message_append_array(reply, 'y', &in_addr.in, sizeof(in_addr.in)); -+ break; -+ -+ case AF_INET6: -+ if (n != sizeof(struct in6_addr) + sizeof(family)) -+ return sd_bus_error_set_errno(error, EIO); -+ -+ r = sd_bus_message_append_array(reply, 'y', &in_addr.in6, sizeof(in_addr.in6)); -+ break; -+ } -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ r = sd_bus_message_close_container(reply); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ } -+ -+ r = wait_for_terminate(child, &si); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ if (si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS) -+ return sd_bus_error_set_errno(error, EIO); -+ -+ r = sd_bus_message_close_container(reply); -+ if (r < 0) -+ return sd_bus_error_set_errno(error, r); -+ -+ return sd_bus_send(bus, reply, NULL); -+} -+ - const sd_bus_vtable machine_vtable[] = { - SD_BUS_VTABLE_START(0), - SD_BUS_PROPERTY("Name", "s", NULL, offsetof(Machine, name), SD_BUS_VTABLE_PROPERTY_CONST), -@@ -138,9 +345,10 @@ const sd_bus_vtable machine_vtable[] = { - SD_BUS_PROPERTY("Class", "s", property_get_class, offsetof(Machine, class), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("RootDirectory", "s", NULL, offsetof(Machine, root_directory), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("State", "s", property_get_state, 0, 0), -- SD_BUS_METHOD("Terminate", NULL, NULL, method_terminate, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), -- SD_BUS_METHOD("Kill", "si", NULL, method_kill, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), -- SD_BUS_VTABLE_END -+ SD_BUS_METHOD("Terminate", NULL, NULL, bus_machine_method_terminate, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), -+ SD_BUS_METHOD("Kill", "si", NULL, bus_machine_method_kill, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), -+ SD_BUS_METHOD("GetAddresses", NULL, "a(yay)", bus_machine_method_get_addresses, SD_BUS_VTABLE_UNPRIVILEGED), -+ SD_BUS_VTABLE_END - }; - - int machine_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) { -diff --git src/machine/machine.h src/machine/machine.h -index f4aefc5..a894a46 100644 ---- src/machine/machine.h -+++ src/machine/machine.h -@@ -96,6 +96,10 @@ char *machine_bus_path(Machine *s); - int machine_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error); - int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error); - -+int bus_machine_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -+int bus_machine_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -+int bus_machine_method_get_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error); -+ - int machine_send_signal(Machine *m, bool new_machine); - int machine_send_create_reply(Machine *m, sd_bus_error *error); - -diff --git src/machine/machinectl.c src/machine/machinectl.c -index 6337aa2..c2bf7e5 100644 ---- src/machine/machinectl.c -+++ src/machine/machinectl.c -@@ -27,6 +27,8 @@ - #include - #include - #include -+#include -+#include - - #include "sd-bus.h" - #include "log.h" -@@ -165,6 +167,63 @@ static int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) { - return 0; - } - -+static int print_addresses(sd_bus *bus, const char *name, const char *prefix, const char *prefix2) { -+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; -+ int r; -+ -+ assert(bus); -+ assert(name); -+ assert(prefix); -+ assert(prefix2); -+ -+ r = sd_bus_call_method(bus, -+ "org.freedesktop.machine1", -+ "/org/freedesktop/machine1", -+ "org.freedesktop.machine1.Manager", -+ "GetMachineAddresses", -+ NULL, -+ &reply, -+ "s", name); -+ if (r < 0) -+ return r; -+ -+ r = sd_bus_message_enter_container(reply, 'a', "(yay)"); -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ while ((r = sd_bus_message_enter_container(reply, 'r', "yay")) > 0) { -+ unsigned char family; -+ const void *a; -+ size_t sz; -+ char buffer[MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)]; -+ -+ r = sd_bus_message_read(reply, "y", &family); -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ r = sd_bus_message_read_array(reply, 'y', &a, &sz); -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ printf("%s%s\n", prefix, inet_ntop(family, a, buffer, sizeof(buffer))); -+ -+ r = sd_bus_message_exit_container(reply); -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ if (prefix != prefix2) -+ prefix = prefix2; -+ } -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ r = sd_bus_message_exit_container(reply); -+ if (r < 0) -+ return bus_log_parse_error(r); -+ -+ return 0; -+} -+ - typedef struct MachineStatusInfo { - char *name; - sd_id128_t id; -@@ -221,6 +280,10 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) { - if (i->root_directory) - printf("\t Root: %s\n", i->root_directory); - -+ print_addresses(bus, i->name, -+ "\t Address: ", -+ "\t "); -+ - if (i->unit) { - printf("\t Unit: %s\n", i->unit); - show_unit_cgroup(bus, i->unit, i->leader); -@@ -427,7 +490,7 @@ static int openpt_in_namespace(pid_t pid, int flags) { - pid_t child; - siginfo_t si; - -- r = namespace_open(pid, &pidnsfd, &mntnsfd, &rootfd); -+ r = namespace_open(pid, &pidnsfd, &mntnsfd, NULL, &rootfd); - if (r < 0) - return r; - -@@ -441,7 +504,7 @@ static int openpt_in_namespace(pid_t pid, int flags) { - if (child == 0) { - pair[0] = safe_close(pair[0]); - -- r = namespace_enter(pidnsfd, mntnsfd, rootfd); -+ r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd); - if (r < 0) - _exit(EXIT_FAILURE); - -@@ -466,10 +529,10 @@ static int openpt_in_namespace(pid_t pid, int flags) { - pair[1] = safe_close(pair[1]); - - r = wait_for_terminate(child, &si); -- if (r < 0 || si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS) { -- -- return r < 0 ? r : -EIO; -- } -+ if (r < 0) -+ return r; -+ if (si.si_code != CLD_EXITED || si.si_status != EXIT_SUCCESS) -+ return -EIO; - - if (recvmsg(pair[0], &mh, MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) < 0) - return -errno; -diff --git src/machine/machined-dbus.c src/machine/machined-dbus.c -index a32d7f5..0078a27 100644 ---- src/machine/machined-dbus.c -+++ src/machine/machined-dbus.c -@@ -27,7 +27,6 @@ - - #include "sd-id128.h" - #include "sd-messages.h" -- - #include "strv.h" - #include "mkdir.h" - #include "path-util.h" -@@ -343,50 +342,49 @@ static int method_terminate_machine(sd_bus *bus, sd_bus_message *message, void * - if (!machine) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - -- r = machine_stop(machine); -- if (r < 0) -- return sd_bus_error_set_errno(error, r); -- -- return sd_bus_reply_method_return(message, NULL); -+ return bus_machine_method_terminate(bus, message, machine, error); - } - - static int method_kill_machine(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { - Manager *m = userdata; - Machine *machine; - const char *name; -- const char *swho; -- int32_t signo; -- KillWho who; - int r; - - assert(bus); - assert(message); - assert(m); - -- r = sd_bus_message_read(message, "ssi", &name, &swho, &signo); -+ r = sd_bus_message_read(message, "s", &name); - if (r < 0) - return sd_bus_error_set_errno(error, r); - -- if (isempty(swho)) -- who = KILL_ALL; -- else { -- who = kill_who_from_string(swho); -- if (who < 0) -- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid kill parameter '%s'", swho); -- } -- -- if (signo <= 0 || signo >= _NSIG) -- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo); -- - machine = hashmap_get(m->machines, name); - if (!machine) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); - -- r = machine_kill(machine, who, signo); -+ return bus_machine_method_kill(bus, message, machine, error); -+} -+ -+static int method_get_machine_addresses(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { -+ Manager *m = userdata; -+ Machine *machine; -+ const char *name; -+ int r; -+ -+ assert(bus); -+ assert(message); -+ assert(m); -+ -+ r = sd_bus_message_read(message, "s", &name); - if (r < 0) - return sd_bus_error_set_errno(error, r); - -- return sd_bus_reply_method_return(message, NULL); -+ machine = hashmap_get(m->machines, name); -+ if (!machine) -+ return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); -+ -+ return bus_machine_method_get_addresses(bus, message, machine, error); - } - - const sd_bus_vtable manager_vtable[] = { -@@ -398,6 +396,7 @@ const sd_bus_vtable manager_vtable[] = { - SD_BUS_METHOD("RegisterMachine", "sayssus", "o", method_register_machine, 0), - SD_BUS_METHOD("KillMachine", "ssi", NULL, method_kill_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), - SD_BUS_METHOD("TerminateMachine", "s", NULL, method_terminate_machine, SD_BUS_VTABLE_CAPABILITY(CAP_KILL)), -+ SD_BUS_METHOD("GetMachineAddresses", "s", "a(yay)", method_get_machine_addresses, SD_BUS_VTABLE_UNPRIVILEGED), - SD_BUS_SIGNAL("MachineNew", "so", 0), - SD_BUS_SIGNAL("MachineRemoved", "so", 0), - SD_BUS_VTABLE_END -diff --git src/shared/bus-errors.h src/shared/bus-errors.h -index 5637935..45e1293 100644 ---- src/shared/bus-errors.h -+++ src/shared/bus-errors.h -@@ -42,6 +42,7 @@ - #define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine" - #define BUS_ERROR_NO_MACHINE_FOR_PID "org.freedesktop.machine1.NoMachineForPID" - #define BUS_ERROR_MACHINE_EXISTS "org.freedesktop.machine1.MachineExists" -+#define BUS_ERROR_NO_PRIVATE_NETWORKING "org.freedesktop.machine1.NoPrivateNetworking" - - #define BUS_ERROR_NO_SUCH_SESSION "org.freedesktop.login1.NoSuchSession" - #define BUS_ERROR_NO_SESSION_FOR_PID "org.freedesktop.login1.NoSessionForPID" -diff --git src/shared/logs-show.c src/shared/logs-show.c -index 72c9ad2..c3578ac 100644 ---- src/shared/logs-show.c -+++ src/shared/logs-show.c -@@ -1158,7 +1158,7 @@ static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { - if (r < 0) - return r; - -- r = namespace_open(pid, &pidnsfd, &mntnsfd, &rootfd); -+ r = namespace_open(pid, &pidnsfd, &mntnsfd, NULL, &rootfd); - if (r < 0) - return r; - -@@ -1174,7 +1174,7 @@ static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) { - - pair[0] = safe_close(pair[0]); - -- r = namespace_enter(pidnsfd, mntnsfd, rootfd); -+ r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd); - if (r < 0) - _exit(EXIT_FAILURE); - -diff --git src/shared/util.c src/shared/util.c -index 020c1da..0cc51e0 100644 ---- src/shared/util.c -+++ src/shared/util.c -@@ -6091,60 +6091,93 @@ int container_get_leader(const char *machine, pid_t *pid) { - return 0; - } - --int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *root_fd) { -- _cleanup_close_ int pidnsfd = -1, mntnsfd = -1; -- const char *pidns, *mntns, *root; -+int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *root_fd) { -+ _cleanup_close_ int pidnsfd = -1, mntnsfd = -1, netnsfd = -1; - int rfd; - - assert(pid >= 0); -- assert(pidns_fd); -- assert(mntns_fd); -- assert(root_fd); - -- mntns = procfs_file_alloca(pid, "ns/mnt"); -- mntnsfd = open(mntns, O_RDONLY|O_NOCTTY|O_CLOEXEC); -- if (mntnsfd < 0) -- return -errno; -+ if (mntns_fd) { -+ const char *mntns; - -- pidns = procfs_file_alloca(pid, "ns/pid"); -- pidnsfd = open(pidns, O_RDONLY|O_NOCTTY|O_CLOEXEC); -- if (pidnsfd < 0) -- return -errno; -+ mntns = procfs_file_alloca(pid, "ns/mnt"); -+ mntnsfd = open(mntns, O_RDONLY|O_NOCTTY|O_CLOEXEC); -+ if (mntnsfd < 0) -+ return -errno; -+ } - -- root = procfs_file_alloca(pid, "root"); -- rfd = open(root, O_RDONLY|O_NOCTTY|O_CLOEXEC|O_DIRECTORY); -- if (rfd < 0) -- return -errno; -+ if (pidns_fd) { -+ const char *pidns; -+ -+ pidns = procfs_file_alloca(pid, "ns/pid"); -+ pidnsfd = open(pidns, O_RDONLY|O_NOCTTY|O_CLOEXEC); -+ if (pidnsfd < 0) -+ return -errno; -+ } -+ -+ if (netns_fd) { -+ const char *netns; -+ -+ netns = procfs_file_alloca(pid, "ns/net"); -+ netnsfd = open(netns, O_RDONLY|O_NOCTTY|O_CLOEXEC); -+ if (netnsfd < 0) -+ return -errno; -+ } -+ -+ if (root_fd) { -+ const char *root; -+ -+ root = procfs_file_alloca(pid, "root"); -+ rfd = open(root, O_RDONLY|O_NOCTTY|O_CLOEXEC|O_DIRECTORY); -+ if (rfd < 0) -+ return -errno; -+ } -+ -+ if (pidns_fd) -+ *pidns_fd = pidnsfd; - -- *pidns_fd = pidnsfd; -- *mntns_fd = mntnsfd; -- *root_fd = rfd; -- pidnsfd = -1; -- mntnsfd = -1; -+ if (mntns_fd) -+ *mntns_fd = mntnsfd; -+ -+ if (netns_fd) -+ *netns_fd = netnsfd; -+ -+ if (root_fd) -+ *root_fd = rfd; -+ -+ pidnsfd = mntnsfd = netnsfd = -1; - - return 0; - } - --int namespace_enter(int pidns_fd, int mntns_fd, int root_fd) { -- assert(pidns_fd >= 0); -- assert(mntns_fd >= 0); -- assert(root_fd >= 0); -+int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int root_fd) { - -- if (setns(pidns_fd, CLONE_NEWPID) < 0) -- return -errno; -+ if (pidns_fd >= 0) -+ if (setns(pidns_fd, CLONE_NEWPID) < 0) -+ return -errno; - -- if (setns(mntns_fd, CLONE_NEWNS) < 0) -- return -errno; -+ if (mntns_fd >= 0) -+ if (setns(mntns_fd, CLONE_NEWNS) < 0) -+ return -errno; - -- if (fchdir(root_fd) < 0) -- return -errno; -+ if (netns_fd >= 0) -+ if (setns(netns_fd, CLONE_NEWNET) < 0) -+ return -errno; - -- if (chroot(".") < 0) -- return -errno; -+ if (root_fd >= 0) { -+ if (fchdir(root_fd) < 0) -+ return -errno; -+ -+ if (chroot(".") < 0) -+ return -errno; -+ } - - if (setresgid(0, 0, 0) < 0) - return -errno; - -+ if (setgroups(0, NULL) < 0) -+ return -errno; -+ - if (setresuid(0, 0, 0) < 0) - return -errno; - -diff --git src/shared/util.h src/shared/util.h -index f2ce4f0..7a7d15c 100644 ---- src/shared/util.h -+++ src/shared/util.h -@@ -910,8 +910,8 @@ int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value)); - - int container_get_leader(const char *machine, pid_t *pid); - --int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *root_fd); --int namespace_enter(int pidns_fd, int mntns_fd, int root_fd); -+int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *root_fd); -+int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int root_fd); - - bool pid_is_alive(pid_t pid); - bool pid_is_unwaited(pid_t pid); --- -1.7.9.2 - diff --git a/0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch b/0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch index d4f81196..361a1713 100644 --- a/0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch +++ b/0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch @@ -81,11 +81,9 @@ index a375dce..9dfca81 100644 send_member="ListUnitFiles"/> +Date: Wed, 9 Apr 2014 21:22:48 +0200 +Subject: [PATCH] login: add 'mir' to the list of session types + +Add Mir to the list of session types. This is implemented for LightDM +in lp:~robert-ancell/lightdm/xdg-session-desktop [1]. + +[1] https://code.launchpad.net/~robert-ancell/lightdm/xdg-session-desktop/+merge/214108 + +(david: adjusted commit-header and fixed whitespace issues) +--- + man/pam_systemd.xml | 5 +++-- + man/sd_session_is_active.xml | 6 +++--- + src/login/logind-session.c | 1 + + src/login/logind-session.h | 1 + + src/systemd/sd-login.h | 2 +- + 5 files changed, 9 insertions(+), 6 deletions(-) + +diff --git man/pam_systemd.xml man/pam_systemd.xml +index 3022cdb..f973899 100644 +--- man/pam_systemd.xml ++++ man/pam_systemd.xml +@@ -145,8 +145,9 @@ + variable takes precedence. One of + unspecified, + tty, +- x11 or +- wayland. See ++ x11, ++ wayland or ++ mir. See + sd_session_get_type3 + for details about the session type. + +diff --git man/sd_session_is_active.xml man/sd_session_is_active.xml +index ddb2bee..31a6119 100644 +--- man/sd_session_is_active.xml ++++ man/sd_session_is_active.xml +@@ -201,9 +201,9 @@ + be used to determine the type of the session + identified by the specified session identifier. The + returned string is one of x11, +- wayland, tty or +- unspecified and needs to be freed +- with the libc ++ wayland, tty, ++ mir or unspecified and ++ needs to be freed with the libc + free3 + call after use. + +--- src/login/logind-session.c ++++ src/login/logind-session.c 2014-05-20 12:49:07.150236121 +0000 +@@ -1124,6 +1124,7 @@ static const char* const session_type_ta + [SESSION_TTY] = "tty", + [SESSION_X11] = "x11", + [SESSION_WAYLAND] = "wayland", ++ [SESSION_MIR] = "mir", + [SESSION_UNSPECIFIED] = "unspecified", + }; + +diff --git src/login/logind-session.h src/login/logind-session.h +index c9af5eb..7ecc9f0 100644 +--- src/login/logind-session.h ++++ src/login/logind-session.h +@@ -55,6 +55,7 @@ typedef enum SessionType { + SESSION_TTY, + SESSION_X11, + SESSION_WAYLAND, ++ SESSION_MIR, + _SESSION_TYPE_MAX, + _SESSION_TYPE_INVALID = -1 + } SessionType; +diff --git src/systemd/sd-login.h src/systemd/sd-login.h +index a4ca231..776733a 100644 +--- src/systemd/sd-login.h ++++ src/systemd/sd-login.h +@@ -138,7 +138,7 @@ int sd_session_get_seat(const char *session, char **seat); + /* Determine the (PAM) service name this session was registered by. */ + int sd_session_get_service(const char *session, char **service); + +-/* Determine the type of this session, i.e. one of "tty", "x11" or "unspecified". */ ++/* Determine the type of this session, i.e. one of "tty", "x11", "wayland", "mir" or "unspecified". */ + int sd_session_get_type(const char *session, char **type); + + /* Determine the class of this session, i.e. one of "user", "greeter" or "lock-screen". */ +-- +1.7.9.2 + diff --git a/0006-logind-fix-Display-property-of-user-objects.patch b/0007-logind-fix-Display-property-of-user-objects.patch similarity index 100% rename from 0006-logind-fix-Display-property-of-user-objects.patch rename to 0007-logind-fix-Display-property-of-user-objects.patch diff --git a/systemd-mini.changes b/systemd-mini.changes index 431a3468..251bb0c4 100644 --- a/systemd-mini.changes +++ b/systemd-mini.changes @@ -4,10 +4,10 @@ Tue May 20 12:13:05 UTC 2014 - werner@suse.de - Add upstream patches 0001-conf-parser-silently-ignore-sections-starting-with-X.patch 0002-man-note-that-entire-sections-can-now-be-ignored.patch - 0003-machined-add-logic-to-query-IP-addresses-of-containe.patch 0004-machined-make-sure-GetMachineAddresses-is-available-.patch 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch - 0006-logind-fix-Display-property-of-user-objects.patch + 0006-login-add-mir-to-the-list-of-session-types.patch + 0007-logind-fix-Display-property-of-user-objects.patch ------------------------------------------------------------------- Tue May 20 11:31:46 UTC 2014 - werner@suse.de diff --git a/systemd-mini.spec b/systemd-mini.spec index c640db4d..e14474a5 100644 --- a/systemd-mini.spec +++ b/systemd-mini.spec @@ -472,13 +472,13 @@ Patch240: 0001-conf-parser-silently-ignore-sections-starting-with-X.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 Patch241: 0002-man-note-that-entire-sections-can-now-be-ignored.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch242: 0003-machined-add-logic-to-query-IP-addresses-of-containe.patch +Patch242: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch243: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch +Patch243: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch244: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch +Patch244: 0006-login-add-mir-to-the-list-of-session-types.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch245: 0006-logind-fix-Display-property-of-user-objects.patch +Patch245: 0007-logind-fix-Display-property-of-user-objects.patch # UDEV PATCHES # ============ diff --git a/systemd.changes b/systemd.changes index 431a3468..251bb0c4 100644 --- a/systemd.changes +++ b/systemd.changes @@ -4,10 +4,10 @@ Tue May 20 12:13:05 UTC 2014 - werner@suse.de - Add upstream patches 0001-conf-parser-silently-ignore-sections-starting-with-X.patch 0002-man-note-that-entire-sections-can-now-be-ignored.patch - 0003-machined-add-logic-to-query-IP-addresses-of-containe.patch 0004-machined-make-sure-GetMachineAddresses-is-available-.patch 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch - 0006-logind-fix-Display-property-of-user-objects.patch + 0006-login-add-mir-to-the-list-of-session-types.patch + 0007-logind-fix-Display-property-of-user-objects.patch ------------------------------------------------------------------- Tue May 20 11:31:46 UTC 2014 - werner@suse.de diff --git a/systemd.spec b/systemd.spec index 8d00b62b..074c1ea4 100644 --- a/systemd.spec +++ b/systemd.spec @@ -467,13 +467,13 @@ Patch240: 0001-conf-parser-silently-ignore-sections-starting-with-X.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 Patch241: 0002-man-note-that-entire-sections-can-now-be-ignored.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch242: 0003-machined-add-logic-to-query-IP-addresses-of-containe.patch +Patch242: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch243: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch +Patch243: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch244: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch +Patch244: 0006-login-add-mir-to-the-list-of-session-types.patch # PATCH-FIX-UPSTREAM added at 2014/05/20 -Patch245: 0006-logind-fix-Display-property-of-user-objects.patch +Patch245: 0007-logind-fix-Display-property-of-user-objects.patch # UDEV PATCHES # ============