forked from pool/systemd
.
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=636
This commit is contained in:
parent
5a532b4c42
commit
b6b9bda832
@ -0,0 +1,73 @@
|
||||
From 342aea195051633c69ba7b8c02c82a0e5f8cbde4 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Marineau <michael.marineau@coreos.com>
|
||||
Date: Fri, 16 May 2014 16:58:31 -0700
|
||||
Subject: [PATCH] conf-parser: silently ignore sections starting with "X-"
|
||||
|
||||
This allows external tools to keep additional unit information in a
|
||||
separate section without scaring users with a big warning.
|
||||
---
|
||||
src/shared/conf-parser.c | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git src/shared/conf-parser.c src/shared/conf-parser.c
|
||||
index d27b1b7..062b15b 100644
|
||||
--- src/shared/conf-parser.c
|
||||
+++ src/shared/conf-parser.c
|
||||
@@ -204,6 +204,7 @@ static int parse_line(const char* unit,
|
||||
bool allow_include,
|
||||
char **section,
|
||||
unsigned *section_line,
|
||||
+ bool *section_ignored,
|
||||
char *l,
|
||||
void *userdata) {
|
||||
|
||||
@@ -266,7 +267,7 @@ static int parse_line(const char* unit,
|
||||
|
||||
if (sections && !nulstr_contains(sections, n)) {
|
||||
|
||||
- if (!relaxed)
|
||||
+ if (!relaxed && !startswith(n, "X-"))
|
||||
log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
|
||||
"Unknown section '%s'. Ignoring.", n);
|
||||
|
||||
@@ -274,10 +275,12 @@ static int parse_line(const char* unit,
|
||||
free(*section);
|
||||
*section = NULL;
|
||||
*section_line = 0;
|
||||
+ *section_ignored = true;
|
||||
} else {
|
||||
free(*section);
|
||||
*section = n;
|
||||
*section_line = line;
|
||||
+ *section_ignored = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -285,7 +288,7 @@ static int parse_line(const char* unit,
|
||||
|
||||
if (sections && !*section) {
|
||||
|
||||
- if (!relaxed)
|
||||
+ if (!relaxed && !*section_ignored)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
|
||||
"Assignment outside of section. Ignoring.");
|
||||
|
||||
@@ -328,6 +331,7 @@ int config_parse(const char *unit,
|
||||
_cleanup_free_ char *section = NULL, *continuation = NULL;
|
||||
_cleanup_fclose_ FILE *ours = NULL;
|
||||
unsigned line = 0, section_line = 0;
|
||||
+ bool section_ignored = false;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
@@ -399,6 +403,7 @@ int config_parse(const char *unit,
|
||||
allow_include,
|
||||
§ion,
|
||||
§ion_line,
|
||||
+ §ion_ignored,
|
||||
p,
|
||||
userdata);
|
||||
free(c);
|
||||
--
|
||||
1.7.9.2
|
||||
|
35
0002-man-note-that-entire-sections-can-now-be-ignored.patch
Normal file
35
0002-man-note-that-entire-sections-can-now-be-ignored.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 2bcc2523711e69e6daa744641e56ed8b78646676 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Marineau <michael.marineau@coreos.com>
|
||||
Date: Sat, 17 May 2014 16:09:08 -0700
|
||||
Subject: [PATCH] man: note that entire sections can now be ignored
|
||||
|
||||
Prefixing a section name with "X-" will cause it and all of its contents
|
||||
to be silently ignored as of commit 342aea19.
|
||||
---
|
||||
man/systemd.unit.xml | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git man/systemd.unit.xml man/systemd.unit.xml
|
||||
index 157530b..e903156 100644
|
||||
--- man/systemd.unit.xml
|
||||
+++ man/systemd.unit.xml
|
||||
@@ -139,10 +139,12 @@
|
||||
<para>Unit files may contain additional options on top
|
||||
of those listed here. If systemd encounters an unknown
|
||||
option, it will write a warning log message but
|
||||
- continue loading the unit. If an option is prefixed
|
||||
- with <option>X-</option>, it is ignored completely by
|
||||
- systemd. Applications may use this to include
|
||||
- additional information in the unit files.</para>
|
||||
+ continue loading the unit. If an option or section name
|
||||
+ is prefixed with <option>X-</option>, it is ignored
|
||||
+ completely by systemd. Options within an ignored
|
||||
+ section do not need the prefix. Applications may use
|
||||
+ this to include additional information in the unit
|
||||
+ files.</para>
|
||||
|
||||
<para>Boolean arguments used in unit files can be
|
||||
written in various formats. For positive settings the
|
||||
--
|
||||
1.7.9.2
|
||||
|
729
0003-machined-add-logic-to-query-IP-addresses-of-containe.patch
Normal file
729
0003-machined-add-logic-to-query-IP-addresses-of-containe.patch
Normal file
@ -0,0 +1,729 @@
|
||||
From 878cd7e95ca303f9851d227a22d2022bd49944b0 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
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 <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/capability.h>
|
||||
+#include <arpa/inet.h>
|
||||
|
||||
+#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 <pwd.h>
|
||||
#include <locale.h>
|
||||
#include <fcntl.h>
|
||||
+#include <netinet/in.h>
|
||||
+#include <arpa/inet.h>
|
||||
|
||||
#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
|
||||
|
@ -0,0 +1,38 @@
|
||||
From d3152a09ac5804ec8603daee12f98cf03523cce0 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 19 May 2014 00:47:26 +0900
|
||||
Subject: [PATCH] machined: make sure GetMachineAddresses() is available for
|
||||
unprivileged processes
|
||||
|
||||
---
|
||||
src/machine/org.freedesktop.machine1.conf | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git src/machine/org.freedesktop.machine1.conf src/machine/org.freedesktop.machine1.conf
|
||||
index 970ccd8..ab349a5 100644
|
||||
--- src/machine/org.freedesktop.machine1.conf
|
||||
+++ src/machine/org.freedesktop.machine1.conf
|
||||
@@ -42,12 +42,20 @@
|
||||
|
||||
<allow send_destination="org.freedesktop.machine1"
|
||||
send_interface="org.freedesktop.machine1.Manager"
|
||||
+ send_member="GetMachineAddresses"/>
|
||||
+
|
||||
+ <allow send_destination="org.freedesktop.machine1"
|
||||
+ send_interface="org.freedesktop.machine1.Manager"
|
||||
send_member="GetMachine"/>
|
||||
|
||||
<allow send_destination="org.freedesktop.machine1"
|
||||
send_interface="org.freedesktop.machine1.Manager"
|
||||
send_member="GetMachineByPID"/>
|
||||
|
||||
+ <allow send_destination="org.freedesktop.machine1"
|
||||
+ send_interface="org.freedesktop.machine1.Machine"
|
||||
+ send_member="GetAddresses"/>
|
||||
+
|
||||
<allow receive_sender="org.freedesktop.machine1"/>
|
||||
</policy>
|
||||
|
||||
--
|
||||
1.7.9.2
|
||||
|
139
0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch
Normal file
139
0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch
Normal file
@ -0,0 +1,139 @@
|
||||
From cdc06ed7b6120c1049305fa7033f228ee9d86043 Mon Sep 17 00:00:00 2001
|
||||
From: David Strauss <david@davidstrauss.net>
|
||||
Date: Mon, 28 Apr 2014 12:08:32 -0700
|
||||
Subject: [PATCH] core: Filter by state behind the D-Bus API, not in the
|
||||
systemctl client.
|
||||
|
||||
---
|
||||
src/core/dbus-manager.c | 24 +++++++++++++++++++++++-
|
||||
src/core/org.freedesktop.systemd1.conf | 4 ++++
|
||||
src/systemctl/systemctl.c | 24 +++++++++++++-----------
|
||||
3 files changed, 40 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git src/core/dbus-manager.c src/core/dbus-manager.c
|
||||
index 58e484d..d5fab0a 100644
|
||||
--- src/core/dbus-manager.c
|
||||
+++ src/core/dbus-manager.c
|
||||
@@ -728,7 +728,7 @@ static int method_reset_failed(sd_bus *bus, sd_bus_message *message, void *userd
|
||||
return sd_bus_reply_method_return(message, NULL);
|
||||
}
|
||||
|
||||
-static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
+static int list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error, char **states) {
|
||||
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
|
||||
Manager *m = userdata;
|
||||
const char *k;
|
||||
@@ -761,6 +761,12 @@ static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdat
|
||||
|
||||
following = unit_following(u);
|
||||
|
||||
+ if (!strv_isempty(states) &&
|
||||
+ !strv_contains(states, unit_load_state_to_string(u->load_state)) &&
|
||||
+ !strv_contains(states, unit_active_state_to_string(unit_active_state(u))) &&
|
||||
+ !strv_contains(states, unit_sub_state_to_string(u)))
|
||||
+ continue;
|
||||
+
|
||||
unit_path = unit_dbus_path(u);
|
||||
if (!unit_path)
|
||||
return -ENOMEM;
|
||||
@@ -794,6 +800,21 @@ static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdat
|
||||
return sd_bus_send(bus, reply, NULL);
|
||||
}
|
||||
|
||||
+static int method_list_units(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
+ return list_units_filtered(bus, message, userdata, error, NULL);
|
||||
+}
|
||||
+
|
||||
+static int method_list_units_filtered(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
+ _cleanup_strv_free_ char **states = NULL;
|
||||
+ int r;
|
||||
+
|
||||
+ r = sd_bus_message_read_strv(message, &states);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+
|
||||
+ return list_units_filtered(bus, message, userdata, error, states);
|
||||
+}
|
||||
+
|
||||
static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
|
||||
Manager *m = userdata;
|
||||
@@ -1670,6 +1691,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
|
||||
SD_BUS_METHOD("ClearJobs", NULL, NULL, method_clear_jobs, 0),
|
||||
SD_BUS_METHOD("ResetFailed", NULL, NULL, method_reset_failed, 0),
|
||||
SD_BUS_METHOD("ListUnits", NULL, "a(ssssssouso)", method_list_units, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
+ SD_BUS_METHOD("ListUnitsFiltered", "as", "a(ssssssouso)", method_list_units_filtered, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("ListJobs", NULL, "a(usssoo)", method_list_jobs, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("Subscribe", NULL, NULL, method_subscribe, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("Unsubscribe", NULL, NULL, method_unsubscribe, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
diff --git src/core/org.freedesktop.systemd1.conf src/core/org.freedesktop.systemd1.conf
|
||||
index a375dce..9dfca81 100644
|
||||
--- src/core/org.freedesktop.systemd1.conf
|
||||
+++ src/core/org.freedesktop.systemd1.conf
|
||||
@@ -64,6 +64,10 @@
|
||||
|
||||
<allow send_destination="org.freedesktop.systemd1"
|
||||
send_interface="org.freedesktop.systemd1.Manager"
|
||||
+ send_member="ListUnitsFiltered"/>
|
||||
+
|
||||
+ <allow send_destination="org.freedesktop.systemd1"
|
||||
+ send_interface="org.freedesktop.systemd1.Manager"
|
||||
send_member="ListUnitFiles"/>
|
||||
|
||||
<allow send_destination="org.freedesktop.systemd1"
|
||||
diff --git src/systemctl/systemctl.c src/systemctl/systemctl.c
|
||||
index a99759f..b11fee5 100644
|
||||
--- src/systemctl/systemctl.c
|
||||
+++ src/systemctl/systemctl.c
|
||||
@@ -319,12 +319,6 @@ static int compare_unit_info(const void *a, const void *b) {
|
||||
static bool output_show_unit(const UnitInfo *u, char **patterns) {
|
||||
const char *dot;
|
||||
|
||||
- if (!strv_isempty(arg_states))
|
||||
- return
|
||||
- strv_contains(arg_states, u->load_state) ||
|
||||
- strv_contains(arg_states, u->sub_state) ||
|
||||
- strv_contains(arg_states, u->active_state);
|
||||
-
|
||||
if (!strv_isempty(patterns)) {
|
||||
char **pattern;
|
||||
|
||||
@@ -513,6 +507,7 @@ static int get_unit_list(
|
||||
int c,
|
||||
sd_bus_message **_reply) {
|
||||
|
||||
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
|
||||
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
|
||||
size_t size = c;
|
||||
@@ -523,15 +518,22 @@ static int get_unit_list(
|
||||
assert(unit_infos);
|
||||
assert(_reply);
|
||||
|
||||
- r = sd_bus_call_method(
|
||||
+ r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
+ &m,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
- "ListUnits",
|
||||
- &error,
|
||||
- &reply,
|
||||
- NULL);
|
||||
+ "ListUnitsFiltered");
|
||||
+
|
||||
+ if (r < 0)
|
||||
+ return bus_log_create_error(r);
|
||||
+
|
||||
+ r = sd_bus_message_append_strv(m, arg_states);
|
||||
+ if (r < 0)
|
||||
+ return bus_log_create_error(r);
|
||||
+
|
||||
+ r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
log_error("Failed to list units: %s", bus_error_message(&error, r));
|
||||
return r;
|
||||
--
|
||||
1.7.9.2
|
||||
|
147
0006-logind-fix-Display-property-of-user-objects.patch
Normal file
147
0006-logind-fix-Display-property-of-user-objects.patch
Normal file
@ -0,0 +1,147 @@
|
||||
From 952d32609f9bceee444fa2690afb4d28539b4b92 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Mon, 19 May 2014 09:03:20 +0900
|
||||
Subject: [PATCH] logind: fix Display property of user objects
|
||||
|
||||
When we dropped support for creating a per-user to the "main" X11
|
||||
display we stopped returning useful data in the "Display" user property.
|
||||
With this change this is fixed and we again expose an appropriate
|
||||
(graphical session) in the property that is useful as the "main" one, if
|
||||
one is needed.
|
||||
---
|
||||
src/login/logind-session.c | 8 ++++++--
|
||||
src/login/logind-session.h | 2 ++
|
||||
src/login/logind-user-dbus.c | 2 +-
|
||||
src/login/logind-user.c | 37 +++++++++++++++++++++++++++++++++++++
|
||||
src/login/logind-user.h | 1 +
|
||||
5 files changed, 47 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git src/login/logind-session.c src/login/logind-session.c
|
||||
index 4fb229e..9a54101 100644
|
||||
--- src/login/logind-session.c
|
||||
+++ src/login/logind-session.c
|
||||
@@ -545,6 +545,8 @@ int session_start(Session *s) {
|
||||
|
||||
s->started = true;
|
||||
|
||||
+ user_elect_display(s->user);
|
||||
+
|
||||
/* Save data */
|
||||
session_save(s);
|
||||
user_save(s->user);
|
||||
@@ -553,7 +555,7 @@ int session_start(Session *s) {
|
||||
|
||||
/* Send signals */
|
||||
session_send_signal(s, true);
|
||||
- user_send_changed(s->user, "Sessions", NULL);
|
||||
+ user_send_changed(s->user, "Sessions", "Display", NULL);
|
||||
if (s->seat) {
|
||||
if (s->seat->active == s)
|
||||
seat_send_changed(s->seat, "Sessions", "ActiveSession", NULL);
|
||||
@@ -612,6 +614,8 @@ int session_stop(Session *s, bool force) {
|
||||
|
||||
s->stopping = true;
|
||||
|
||||
+ user_elect_display(s->user);
|
||||
+
|
||||
session_save(s);
|
||||
user_save(s->user);
|
||||
|
||||
@@ -660,7 +664,7 @@ int session_finalize(Session *s) {
|
||||
}
|
||||
|
||||
user_save(s->user);
|
||||
- user_send_changed(s->user, "Sessions", NULL);
|
||||
+ user_send_changed(s->user, "Sessions", "Display", NULL);
|
||||
|
||||
return r;
|
||||
}
|
||||
diff --git src/login/logind-session.h src/login/logind-session.h
|
||||
index f78f309..81957df 100644
|
||||
--- src/login/logind-session.h
|
||||
+++ src/login/logind-session.h
|
||||
@@ -60,6 +60,8 @@ typedef enum SessionType {
|
||||
_SESSION_TYPE_INVALID = -1
|
||||
} SessionType;
|
||||
|
||||
+#define SESSION_TYPE_IS_GRAPHICAL(type) IN_SET(type, SESSION_X11, SESSION_WAYLAND, SESSION_MIR)
|
||||
+
|
||||
enum KillWho {
|
||||
KILL_LEADER,
|
||||
KILL_ALL,
|
||||
diff --git src/login/logind-user-dbus.c src/login/logind-user-dbus.c
|
||||
index 6266ccb..51793f6 100644
|
||||
--- src/login/logind-user-dbus.c
|
||||
+++ src/login/logind-user-dbus.c
|
||||
@@ -220,7 +220,7 @@ const sd_bus_vtable user_vtable[] = {
|
||||
SD_BUS_PROPERTY("RuntimePath", "s", NULL, offsetof(User, runtime_path), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Service", "s", NULL, offsetof(User, service), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Slice", "s", NULL, offsetof(User, slice), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
- SD_BUS_PROPERTY("Display", "(so)", property_get_display, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
+ SD_BUS_PROPERTY("Display", "(so)", property_get_display, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("State", "s", property_get_state, 0, 0),
|
||||
SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
diff --git src/login/logind-user.c src/login/logind-user.c
|
||||
index 5fffa65..fdbccb3 100644
|
||||
--- src/login/logind-user.c
|
||||
+++ src/login/logind-user.c
|
||||
@@ -713,6 +713,43 @@ int user_kill(User *u, int signo) {
|
||||
return manager_kill_unit(u->manager, u->slice, KILL_ALL, signo, NULL);
|
||||
}
|
||||
|
||||
+void user_elect_display(User *u) {
|
||||
+ Session *graphical = NULL, *text = NULL, *s;
|
||||
+
|
||||
+ assert(u);
|
||||
+
|
||||
+ /* This elects a primary session for each user, which we call
|
||||
+ * the "display". We try to keep the assignment stable, but we
|
||||
+ * "upgrade" to better choices. */
|
||||
+
|
||||
+ LIST_FOREACH(sessions_by_user, s, u->sessions) {
|
||||
+
|
||||
+ if (s->class != SESSION_USER)
|
||||
+ continue;
|
||||
+
|
||||
+ if (s->stopping)
|
||||
+ continue;
|
||||
+
|
||||
+ if (SESSION_TYPE_IS_GRAPHICAL(s->type))
|
||||
+ graphical = s;
|
||||
+ else
|
||||
+ text = s;
|
||||
+ }
|
||||
+
|
||||
+ if (graphical &&
|
||||
+ (!u->display ||
|
||||
+ u->display->class != SESSION_USER ||
|
||||
+ u->display->stopping ||
|
||||
+ !SESSION_TYPE_IS_GRAPHICAL(u->display->type)))
|
||||
+ u->display = graphical;
|
||||
+
|
||||
+ if (text &&
|
||||
+ (!u->display ||
|
||||
+ u->display->class != SESSION_USER ||
|
||||
+ u->display->stopping))
|
||||
+ u->display = text;
|
||||
+}
|
||||
+
|
||||
static const char* const user_state_table[_USER_STATE_MAX] = {
|
||||
[USER_OFFLINE] = "offline",
|
||||
[USER_OPENING] = "opening",
|
||||
diff --git src/login/logind-user.h src/login/logind-user.h
|
||||
index f237d2a..4e0568f 100644
|
||||
--- src/login/logind-user.h
|
||||
+++ src/login/logind-user.h
|
||||
@@ -80,6 +80,7 @@ int user_save(User *u);
|
||||
int user_load(User *u);
|
||||
int user_kill(User *u, int signo);
|
||||
int user_check_linger_file(User *u);
|
||||
+void user_elect_display(User *u);
|
||||
|
||||
extern const sd_bus_vtable user_vtable[];
|
||||
int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
|
||||
--
|
||||
1.7.9.2
|
||||
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue May 20 11:31:46 UTC 2014 - werner@suse.de
|
||||
|
||||
|
@ -467,6 +467,18 @@ Patch237: 0003-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
Patch238: 0004-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch239: 0005-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
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
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch243: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch244: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch245: 0006-logind-fix-Display-property-of-user-objects.patch
|
||||
|
||||
# UDEV PATCHES
|
||||
# ============
|
||||
@ -898,6 +910,12 @@ cp %{SOURCE7} m4/
|
||||
%patch237 -p0
|
||||
%patch238 -p0
|
||||
%patch239 -p0
|
||||
%patch240 -p0
|
||||
%patch241 -p0
|
||||
%patch242 -p0
|
||||
%patch243 -p0
|
||||
%patch244 -p0
|
||||
%patch245 -p0
|
||||
|
||||
# udev patches
|
||||
%patch1001 -p1
|
||||
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue May 20 11:31:46 UTC 2014 - werner@suse.de
|
||||
|
||||
|
18
systemd.spec
18
systemd.spec
@ -462,6 +462,18 @@ Patch237: 0003-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
Patch238: 0004-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch239: 0005-hwdb-Update-database-of-Bluetooth-company-identifier.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
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
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch243: 0004-machined-make-sure-GetMachineAddresses-is-available-.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch244: 0005-core-Filter-by-state-behind-the-D-Bus-API-not-in-the.patch
|
||||
# PATCH-FIX-UPSTREAM added at 2014/05/20
|
||||
Patch245: 0006-logind-fix-Display-property-of-user-objects.patch
|
||||
|
||||
# UDEV PATCHES
|
||||
# ============
|
||||
@ -893,6 +905,12 @@ cp %{SOURCE7} m4/
|
||||
%patch237 -p0
|
||||
%patch238 -p0
|
||||
%patch239 -p0
|
||||
%patch240 -p0
|
||||
%patch241 -p0
|
||||
%patch242 -p0
|
||||
%patch243 -p0
|
||||
%patch244 -p0
|
||||
%patch245 -p0
|
||||
|
||||
# udev patches
|
||||
%patch1001 -p1
|
||||
|
Loading…
Reference in New Issue
Block a user