From: Yu Watanabe Date: Sat, 12 Mar 2022 19:45:08 +0000 (+0900) Subject: udev: try to reload selinux label database less frequently X-Git-Tag: v251-rc1~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c02fb80479b23e70f4ad6f7717eec5c9444aa7f4;p=thirdparty%2Fsystemd.git udev: try to reload selinux label database less frequently Previously, `event_run()` was called repeatedly in one `event_queue_start()` invocation. Hence, the SELinux label database is reloaded many times needlessly. Other settings, e.g. udev rules or hwdata, are tried to be reloaded in the beginning of `event_queue_start()`. Let's also do so for the SELinux database. --- diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 8c690357b8d..1e90b94f5c7 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -760,10 +760,6 @@ static int event_run(Event *event) { /* Re-enable the debug message for the next batch of events */ log_children_max_reached = true; - /* fork with up-to-date SELinux label database, so the child inherits the up-to-date db - * and, until the next SELinux policy changes, we safe further reloads in future children */ - mac_selinux_maybe_reload(); - /* start new worker and pass initial device */ r = worker_spawn(manager, event); if (r < 0) @@ -945,6 +941,10 @@ static int event_queue_start(Manager *manager) { return log_warning_errno(r, "Failed to read udev rules: %m"); } + /* fork with up-to-date SELinux label database, so the child inherits the up-to-date db + * and, until the next SELinux policy changes, we safe further reloads in future children */ + mac_selinux_maybe_reload(); + LIST_FOREACH(event, event, manager->events) { if (event->state != EVENT_QUEUED) continue;