summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/path-util.c11
-rw-r--r--src/basic/path-util.h1
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/load-fragment.c4
-rw-r--r--src/core/main.c7
-rw-r--r--src/network/networkd-link-bus.c131
-rw-r--r--src/network/networkd-link.h5
-rw-r--r--src/network/networkd-manager.c8
-rw-r--r--src/nspawn/nspawn-mount.c7
-rw-r--r--src/shared/bus-unit-util.c2
-rw-r--r--units/systemd-journal-upload.service.in3
11 files changed, 166 insertions, 15 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index c32e961af4..a76963aa9f 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -812,9 +812,14 @@ bool is_device_path(const char *path) {
/* Returns true on paths that refer to a device, either in
* sysfs or in /dev */
- return
- path_startswith(path, "/dev/") ||
- path_startswith(path, "/sys/");
+ return path_startswith(path, "/dev/") ||
+ path_startswith(path, "/sys/");
+}
+
+bool is_deviceallow_pattern(const char *path) {
+ return path_startswith(path, "/dev/") ||
+ startswith(path, "block-") ||
+ startswith(path, "char-");
}
int systemd_installation_has_version(const char *root, unsigned minimal_version) {
diff --git a/src/basic/path-util.h b/src/basic/path-util.h
index 78472f0961..66545f52d9 100644
--- a/src/basic/path-util.h
+++ b/src/basic/path-util.h
@@ -125,5 +125,6 @@ char *file_in_same_dir(const char *path, const char *filename);
bool hidden_or_backup_file(const char *filename) _pure_;
bool is_device_path(const char *path);
+bool is_deviceallow_pattern(const char *path);
int systemd_installation_has_version(const char *root, unsigned minimal_version);
diff --git a/src/core/execute.c b/src/core/execute.c
index 7079aeed6e..0c983f4953 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2350,7 +2350,7 @@ static int exec_child(
USER_PROCESS,
username ? "root" : context->user);
- if (context->user && is_terminal_input(context->std_input)) {
+ if (context->user) {
r = chown_terminal(STDIN_FILENO, uid);
if (r < 0) {
*exit_status = EXIT_STDIN;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 8f067b5586..06c156a623 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3084,9 +3084,7 @@ int config_parse_device_allow(
if (!path)
return log_oom();
- if (!startswith(path, "/dev/") &&
- !startswith(path, "block-") &&
- !startswith(path, "char-")) {
+ if (!is_deviceallow_pattern(path)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid device node path '%s'. Ignoring.", path);
return 0;
}
diff --git a/src/core/main.c b/src/core/main.c
index 4b82a57b3c..61f3828a36 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1614,11 +1614,10 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (arg_action == ACTION_TEST)
- skip_setup = true;
-
- if (arg_action == ACTION_TEST || arg_action == ACTION_HELP)
+ if (arg_action == ACTION_TEST || arg_action == ACTION_HELP) {
pager_open(arg_no_pager, false);
+ skip_setup = true;
+ }
if (arg_action == ACTION_HELP) {
retval = help();
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index 532557ed6c..10ec08351a 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -23,6 +23,7 @@
#include "networkd.h"
#include "parse-util.h"
#include "strv.h"
+#include "dhcp-lease-internal.h"
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_operational_state, link_operstate, LinkOperationalState);
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_administrative_state, link_state, LinkState);
@@ -36,6 +37,50 @@ const sd_bus_vtable link_vtable[] = {
SD_BUS_VTABLE_END
};
+static int get_private_options(sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+ sd_dhcp_lease *lease = userdata;
+ struct sd_dhcp_raw_option *option = NULL;
+ int r;
+
+ assert(bus);
+ assert(reply);
+ assert(lease);
+
+ r = sd_bus_message_open_container(reply, SD_BUS_TYPE_ARRAY, "{yay}");
+ if (r < 0)
+ return r;
+
+ LIST_FOREACH(options, option, lease->private_options) {
+ r = sd_bus_message_open_container(reply, SD_BUS_TYPE_DICT_ENTRY, "yay");
+ if (r < 0)
+ return r;
+ r = sd_bus_message_append(reply, "y", option->tag);
+ if (r < 0)
+ return r;
+ r = sd_bus_message_append_array(reply, 'y', option->data, option->length);
+ if (r < 0)
+ return r;
+ r = sd_bus_message_close_container(reply);
+ if (r < 0)
+ return r;
+ }
+ return sd_bus_message_close_container(reply);
+}
+
+const sd_bus_vtable lease_vtable[] = {
+ SD_BUS_VTABLE_START(0),
+
+ SD_BUS_PROPERTY("PrivateOptions", "a{yay}", get_private_options, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+
+ SD_BUS_VTABLE_END
+};
+
static char *link_bus_path(Link *link) {
_cleanup_free_ char *ifindex = NULL;
char *p;
@@ -54,6 +99,24 @@ static char *link_bus_path(Link *link) {
return p;
}
+static char *lease_bus_path(Link *link) {
+ _cleanup_free_ char *p = NULL;
+ char *ret = NULL;
+ int r;
+
+ assert(link);
+
+ p = link_bus_path(link);
+ if (!p)
+ return NULL;
+
+ r = sd_bus_path_encode(p, "lease", &ret);
+ if (r < 0)
+ return NULL;
+
+ return ret;
+}
+
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Manager *m = userdata;
@@ -87,6 +150,42 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
return 1;
}
+int lease_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
+ _cleanup_strv_free_ char **l = NULL;
+ Manager *m = userdata;
+ unsigned c = 0;
+ Link *link;
+ Iterator i;
+
+ assert(bus);
+ assert(path);
+ assert(m);
+ assert(nodes);
+
+ l = new0(char*, hashmap_size(m->links) + 1);
+ if (!l)
+ return -ENOMEM;
+
+ HASHMAP_FOREACH(link, m->links, i) {
+ char *p;
+
+ if (!link->dhcp_lease)
+ continue;
+
+ p = lease_bus_path(link);
+ if (!p)
+ return -ENOMEM;
+
+ l[c++] = p;
+ }
+
+ l[c] = NULL;
+ *nodes = l;
+ l = NULL;
+
+ return 1;
+}
+
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *identifier = NULL;
Manager *m = userdata;
@@ -116,6 +215,38 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void
return 1;
}
+int lease_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
+ _cleanup_free_ char *identifier = NULL;
+ Manager *m = userdata;
+ Link *link;
+ int ifindex, r;
+
+ assert(bus);
+ assert(path);
+ assert(interface);
+ assert(m);
+ assert(found);
+
+ r = sd_bus_path_decode_many(path, "/org/freedesktop/network1/link/%/lease", &identifier);
+ if (r <= 0)
+ return 0;
+
+ r = parse_ifindex(identifier, &ifindex);
+ if (r < 0)
+ return 0;
+
+ r = link_get(m, ifindex, &link);
+ if (r < 0)
+ return 0;
+
+ if (!link->dhcp_lease)
+ return 0;
+
+ *found = link->dhcp_lease;
+
+ return 1;
+}
+
int link_send_changed(Link *link, const char *property, ...) {
_cleanup_free_ char *p = NULL;
char **l;
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 77f72d070e..1178999bb4 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -179,6 +179,11 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
int link_send_changed(Link *link, const char *property, ...) _sentinel_;
+extern const sd_bus_vtable lease_vtable[];
+
+int lease_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
+int lease_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
+
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
#define _cleanup_link_unref_ _cleanup_(link_unrefp)
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 9174dcc7f4..0ad34e0cc2 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -176,6 +176,14 @@ int manager_connect_bus(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to add link enumerator: %m");
+ r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/network1/link", "org.freedesktop.network1.Link.Lease", lease_vtable, lease_object_find, m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to add lease object vtable: %m");
+
+ r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/network1/link", lease_node_enumerator, m);
+ if (r < 0)
+ return log_error_errno(r, "Failed to add lease enumerator: %m");
+
r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/network1/network", "org.freedesktop.network1.Network", network_vtable, network_object_find, m);
if (r < 0)
return log_error_errno(r, "Failed to add network object vtable: %m");
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index da5bc68a89..44dc9bfcf4 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -329,7 +329,7 @@ int mount_all(const char *dest,
{ "tmpfs", "/dev", "tmpfs", "mode=755", MS_NOSUID|MS_STRICTATIME, true, false, false },
{ "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true, false, false },
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME, true, false, false },
- { "tmpfs", "/tmp", "tmpfs", "mode=1777", MS_STRICTATIME, true, false, false },
+ { "tmpfs", "/tmp", "tmpfs", "mode=1777", MS_STRICTATIME, true, true, false },
#ifdef HAVE_SELINUX
{ "/sys/fs/selinux", "/sys/fs/selinux", NULL, NULL, MS_BIND, false, false, false }, /* Bind mount first */
{ NULL, "/sys/fs/selinux", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, false, false, false }, /* Then, make it r/o */
@@ -372,7 +372,10 @@ int mount_all(const char *dest,
o = mount_table[k].options;
if (streq_ptr(mount_table[k].type, "tmpfs")) {
- r = tmpfs_patch_options(o, use_userns, uid_shift, uid_range, false, selinux_apifs_context, &options);
+ if (in_userns)
+ r = tmpfs_patch_options(o, use_userns, 0, uid_range, true, selinux_apifs_context, &options);
+ else
+ r = tmpfs_patch_options(o, use_userns, uid_shift, uid_range, false, selinux_apifs_context, &options);
if (r < 0)
return log_oom();
if (r > 0)
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index c6bd2f145c..a550a370b5 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -303,7 +303,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
rwm = "";
}
- if (!path_startswith(path, "/dev")) {
+ if (!is_deviceallow_pattern(path)) {
log_error("%s is not a device file in /dev.", path);
return -EINVAL;
}
diff --git a/units/systemd-journal-upload.service.in b/units/systemd-journal-upload.service.in
index c709543af5..d8fd243620 100644
--- a/units/systemd-journal-upload.service.in
+++ b/units/systemd-journal-upload.service.in
@@ -8,7 +8,8 @@
[Unit]
Description=Journal Remote Upload Service
Documentation=man:systemd-journal-upload(8)
-After=network.target
+Wants=network-online.target
+After=network-online.target
[Service]
ExecStart=@rootlibexecdir@/systemd-journal-upload --save-state