From 6b2229c6c60d0486f5eb9ed3088f9c780d7c0233 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Jun 2020 15:40:20 +0200 Subject: [PATCH] udev: set fewer process properties On systemd systems we generally don't need to chdir() to root, we don't need to setup /dev/ ourselves (as PID 1 does that during earliest boot), and we don't need to set the OOM adjustment values, as that's done via unit files. Hence, drop this. if people want to use udev from other init systems they should do this on their own, I am very sure it's a good thing to do it from outside of udevd, so that fewer privileges are required by udevd. In particular the dev_setup() stuff is something that people who build their own non-systemd distros want to set up themselves anyway, in particular as they already have to mount devtmpfs themselves anyway. Note that this only drops stuff that isn't really necessary for testing stuff, i.e. process properties and settings that don't matter if you quickly want to invoke udev from a terminal session to test something. --- src/udev/udevd.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index b3fa83993e..d86c1484c3 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1859,10 +1859,6 @@ int run_udevd(int argc, char *argv[]) { } /* set umask before creating any file/directory */ - r = chdir("/"); - if (r < 0) - return log_error_errno(errno, "Failed to change dir to '/': %m"); - umask(022); r = mac_selinux_init(); @@ -1873,8 +1869,6 @@ int run_udevd(int argc, char *argv[]) { if (r < 0 && r != -EEXIST) return log_error_errno(r, "Failed to create /run/udev: %m"); - dev_setup(NULL, UID_INVALID, GID_INVALID); - if (getppid() == 1 && sd_booted() > 0) { /* Get our own cgroup, we regularly kill everything udev has left behind. * We only do this on systemd systems, and only if we are directly spawned @@ -1917,10 +1911,6 @@ int run_udevd(int argc, char *argv[]) { /* child */ (void) setsid(); - - r = set_oom_score_adjust(-1000); - if (r < 0) - log_debug_errno(r, "Failed to adjust OOM score, ignoring: %m"); } return main_loop(manager);