diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ima-setup.c | 15 | ||||
-rw-r--r-- | src/core/main.c | 8 | ||||
-rw-r--r-- | src/core/manager.c | 3 | ||||
-rw-r--r-- | src/core/mount.c | 3 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 26 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.h | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/kdbus.h | 8 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-kernel.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator.c | 18 | ||||
-rw-r--r-- | src/libsystemd/sd-event/sd-event.c | 6 | ||||
-rw-r--r-- | src/libudev/libudev-enumerate.c | 21 | ||||
-rw-r--r-- | src/login/71-seat.rules.in | 1 | ||||
-rw-r--r-- | src/login/logind-dbus.c | 1 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 2 | ||||
-rw-r--r-- | src/test/test-util.c | 2 |
15 files changed, 64 insertions, 54 deletions
diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c index 7721b3ecaf..4d8b638115 100644 --- a/src/core/ima-setup.c +++ b/src/core/ima-setup.c @@ -24,9 +24,10 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> +#include <sys/stat.h> +#include <sys/mman.h> #include "ima-setup.h" -#include "copy.h" #include "util.h" #include "log.h" @@ -39,6 +40,8 @@ int ima_setup(void) { #ifdef HAVE_IMA _cleanup_close_ int policyfd = -1, imafd = -1; + struct stat st; + char *policy; if (access(IMA_SECFS_DIR, F_OK) < 0) { log_debug("IMA support is disabled in the kernel, ignoring."); @@ -63,12 +66,20 @@ int ima_setup(void) { return 0; } - r = copy_bytes(policyfd, imafd, (off_t) -1, false); + if (fstat(policyfd, &st) < 0) + return log_error_errno(errno, "Failed to fstat "IMA_POLICY_PATH": %m"); + + policy = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, policyfd, 0); + if (policy == MAP_FAILED) + return log_error_errno(errno, "Failed to mmap "IMA_POLICY_PATH": %m"); + + r = loop_write(imafd, policy, (size_t) st.st_size, false); if (r < 0) log_error_errno(r, "Failed to load the IMA custom policy file "IMA_POLICY_PATH": %m"); else log_info("Successfully loaded the IMA custom policy "IMA_POLICY_PATH"."); + munmap(policy, st.st_size); #endif /* HAVE_IMA */ return r; } diff --git a/src/core/main.c b/src/core/main.c index 674e47e788..29ccff7b63 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1606,14 +1606,10 @@ int main(int argc, char *argv[]) { } } - if (arg_running_as == MANAGER_USER) { + if (arg_running_as == MANAGER_USER) /* Become reaper of our children */ - if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) { + if (prctl(PR_SET_CHILD_SUBREAPER, 1) < 0) log_warning_errno(errno, "Failed to make us a subreaper: %m"); - if (errno == EINVAL) - log_info("Perhaps the kernel version is too old (< 3.4?)"); - } - } if (arg_running_as == MANAGER_SYSTEM) { bump_rlimit_nofile(&saved_rlimit_nofile); diff --git a/src/core/manager.c b/src/core/manager.c index ae473d05c2..a1c54339ea 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -741,9 +741,6 @@ static int manager_setup_kdbus(Manager *m) { if (!is_kdbus_available()) return -ESOCKTNOSUPPORT; - if (m->running_as == MANAGER_SYSTEM && detect_container(NULL) <= 0) - bus_kernel_fix_attach_mask(); - m->kdbus_fd = bus_kernel_create_bus( m->running_as == MANAGER_SYSTEM ? "system" : "user", m->running_as == MANAGER_SYSTEM, &p); diff --git a/src/core/mount.c b/src/core/mount.c index ba1dcf1e85..851b41351e 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1522,6 +1522,9 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { options = mnt_fs_get_options(fs); fstype = mnt_fs_get_fstype(fs); + if (!device || !path) + continue; + if (cunescape(device, UNESCAPE_RELAX, &d) < 0) return log_oom(); diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index d5cc8100ce..417e4d5903 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -1770,32 +1770,6 @@ int bus_kernel_realize_attach_flags(sd_bus *bus) { return 0; } -int bus_kernel_fix_attach_mask(void) { - _cleanup_free_ char *mask = NULL; - uint64_t m = (uint64_t) -1; - char buf[2+16+2]; - int r; - - /* By default we don't want any kdbus metadata fields to be - * suppressed, hence we reset the kernel mask for it to - * (uint64_t) -1. If the module argument was overwritten by - * the kernel cmdline, we leave it as is. */ - - r = get_proc_cmdline_key("kdbus.attach_flags_mask=", &mask); - if (r < 0) - return log_warning_errno(r, "Failed to read kernel command line: %m"); - - if (r == 0) { - sprintf(buf, "0x%" PRIx64 "\n", m); - r = write_string_file("/sys/module/kdbus/parameters/attach_flags_mask", buf); - if (r < 0) - return log_full_errno(IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r, - "Failed to write kdbus attach mask: %m"); - } - - return 0; -} - int bus_kernel_get_bus_name(sd_bus *bus, char **name) { struct kdbus_cmd_info cmd = { .size = sizeof(struct kdbus_cmd_info), diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h index b9f31ba790..bb4dff6d82 100644 --- a/src/libsystemd/sd-bus/bus-kernel.h +++ b/src/libsystemd/sd-bus/bus-kernel.h @@ -90,8 +90,6 @@ int bus_kernel_drop_one(int fd); int bus_kernel_realize_attach_flags(sd_bus *bus); -int bus_kernel_fix_attach_mask(void); - int bus_kernel_get_bus_name(sd_bus *bus, char **name); int bus_kernel_cmd_free(sd_bus *bus, uint64_t offset); diff --git a/src/libsystemd/sd-bus/kdbus.h b/src/libsystemd/sd-bus/kdbus.h index fc1d77dd7c..00a6e142c9 100644 --- a/src/libsystemd/sd-bus/kdbus.h +++ b/src/libsystemd/sd-bus/kdbus.h @@ -5,8 +5,8 @@ * your option) any later version. */ -#ifndef _KDBUS_UAPI_H_ -#define _KDBUS_UAPI_H_ +#ifndef _UAPI_KDBUS_H_ +#define _UAPI_KDBUS_H_ #include <linux/ioctl.h> #include <linux/types.h> @@ -544,7 +544,7 @@ struct kdbus_msg_info { * reply to this message. The * KDBUS_CMD_SEND ioctl() will block * until the reply is received, and - * offset_reply in struct kdbus_msg will + * reply in struct kdbus_cmd_send will * yield the offset in the sender's pool * where the reply can be found. * This flag is only valid if @@ -976,4 +976,4 @@ enum kdbus_ioctl_type { struct kdbus_cmd_match), }; -#endif /* _KDBUS_UAPI_H_ */ +#endif /* _UAPI_KDBUS_H_ */ diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c index 8f4f60b65f..6506eaab2e 100644 --- a/src/libsystemd/sd-bus/test-bus-kernel.c +++ b/src/libsystemd/sd-bus/test-bus-kernel.c @@ -43,8 +43,6 @@ int main(int argc, char *argv[]) { assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0); - bus_kernel_fix_attach_mask(); - bus_ref = bus_kernel_create_bus(name, false, &bus_name); if (bus_ref == -ENOENT) return EXIT_TEST_SKIP; diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 3692d46e06..7fd77e9480 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -137,7 +137,6 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer assert_return(enumerator, -EINVAL); assert_return(_sysattr, -EINVAL); - assert_return(_value, -EINVAL); if (match) hashmap = &enumerator->match_sysattr; @@ -152,9 +151,11 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer if (!sysattr) return -ENOMEM; - value = strdup(_value); - if (!value) - return -ENOMEM; + if (_value) { + value = strdup(_value); + if (!value) + return -ENOMEM; + } r = hashmap_put(*hashmap, sysattr, value); if (r < 0) @@ -174,7 +175,6 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume assert_return(enumerator, -EINVAL); assert_return(_property, -EINVAL); - assert_return(_value, -EINVAL); r = hashmap_ensure_allocated(&enumerator->match_property, NULL); if (r < 0) @@ -184,9 +184,11 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume if (!property) return -ENOMEM; - value = strdup(_value); - if (!value) - return -ENOMEM; + if (_value) { + value = strdup(_value); + if (!value) + return -ENOMEM; + } r = hashmap_put(enumerator->match_property, property, value); if (r < 0) diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index cc8bc50c04..2b8d1b87ed 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -474,6 +474,9 @@ static int source_io_unregister(sd_event_source *s) { assert(s); assert(s->type == SOURCE_IO); + if (event_pid_changed(s->event)) + return 0; + if (!s->io.registered) return 0; @@ -604,6 +607,9 @@ static int event_update_signal_fd(sd_event *e) { assert(e); + if (event_pid_changed(e)) + return 0; + add_to_epoll = e->signal_fd < 0; r = signalfd(e->signal_fd, &e->sigset, SFD_NONBLOCK|SFD_CLOEXEC); diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index 255fbe808d..df088946df 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -196,6 +196,9 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume _public_ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) { assert_return(udev_enumerate, -EINVAL); + if (!subsystem) + return 0; + return sd_device_enumerator_add_match_subsystem(udev_enumerate->enumerator, subsystem, true); } @@ -211,6 +214,9 @@ _public_ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enum _public_ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) { assert_return(udev_enumerate, -EINVAL); + if (!subsystem) + return 0; + return sd_device_enumerator_add_match_subsystem(udev_enumerate->enumerator, subsystem, false); } @@ -227,6 +233,9 @@ _public_ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_en _public_ int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) { assert_return(udev_enumerate, -EINVAL); + if (!sysattr) + return 0; + return sd_device_enumerator_add_match_sysattr(udev_enumerate->enumerator, sysattr, value, true); } @@ -243,6 +252,9 @@ _public_ int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumer _public_ int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) { assert_return(udev_enumerate, -EINVAL); + if (!sysattr) + return 0; + return sd_device_enumerator_add_match_sysattr(udev_enumerate->enumerator, sysattr, value, false); } @@ -259,6 +271,9 @@ _public_ int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enum _public_ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value) { assert_return(udev_enumerate, -EINVAL); + if (!property) + return 0; + return sd_device_enumerator_add_match_property(udev_enumerate->enumerator, property, value); } @@ -274,6 +289,9 @@ _public_ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enume _public_ int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag) { assert_return(udev_enumerate, -EINVAL); + if (!tag) + return 0; + return sd_device_enumerator_add_match_tag(udev_enumerate->enumerator, tag); } @@ -335,6 +353,9 @@ _public_ int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev _public_ int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname) { assert_return(udev_enumerate, -EINVAL); + if (!sysname) + return 0; + return sd_device_enumerator_add_match_sysname(udev_enumerate->enumerator, sysname); } diff --git a/src/login/71-seat.rules.in b/src/login/71-seat.rules.in index ad26acbbb3..ab7b66f651 100644 --- a/src/login/71-seat.rules.in +++ b/src/login/71-seat.rules.in @@ -11,6 +11,7 @@ TAG=="uaccess", SUBSYSTEM!="sound", TAG+="seat" SUBSYSTEM=="sound", KERNEL=="card*", TAG+="seat" SUBSYSTEM=="input", KERNEL=="input*", TAG+="seat" SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat", TAG+="master-of-seat" +SUBSYSTEM=="drm", KERNEL=="card[0-9]*", TAG+="seat", TAG+="master-of-seat" SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat" # 'Plugable' USB hub, sound, network, graphics adapter diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 10a9df0961..b272401e5b 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2522,6 +2522,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err session_jobs_reply(session, unit, result); session_save(session); + user_save(session->user); session_add_to_gc_queue(session); } diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index a7b8e54a9c..b3d90d2c33 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -5879,7 +5879,7 @@ static int run_editor(char **paths) { execvp(editor, (char* const*) args); } - FOREACH_STRING(p, "nano", "vim", "vi") { + FOREACH_STRING(p, "editor", "nano", "vim", "vi") { args[0] = p; execvp(p, (char* const*) args); /* We do not fail if the editor doesn't exist diff --git a/src/test/test-util.c b/src/test/test-util.c index 7a398fafbe..9d5516a18d 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -460,6 +460,8 @@ static void test_cunescape(void) { assert_se(cunescape("\\u0000", 0, &unescaped) < 0); assert_se(cunescape("\\u00DF\\U000000df\\u03a0\\U00000041", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "ßßΠA")); + free(unescaped); + unescaped = NULL; assert_se(cunescape("\\073", 0, &unescaped) >= 0); assert_se(streq_ptr(unescaped, ";")); |