]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Preset user units on first boot as well
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Sep 2024 07:16:14 +0000 (09:16 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 21 Sep 2024 04:57:29 +0000 (13:57 +0900)
We need to make sure the presets from /usr/lib/systemd/user-preset
are applied as well. Currently only the ones from
/usr/lib/systemd/system-preset are applied.

NEWS
src/core/manager.c

diff --git a/NEWS b/NEWS
index 17b79e31afdfde1f884b4e04a2b94ec64e506569..166c337cbc50a92481871f7277ecb6c3aa6c6309 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -73,6 +73,9 @@ CHANGES WITH 257 in spe:
 
         Service and system management:
 
+        * Global user units are now enabled or disabled based on preset files
+          on first boot as well just like system units are already.
+
         * Environment variable $REMOTE_ADDR is now set when using socket
           activation for AF_UNIX sockets.
 
index 2dddc797222686472135417ebee221bd6e121869..844a91b605e458bc57baec888a8644c53d640576 100644 (file)
@@ -1936,12 +1936,16 @@ static void manager_preset_all(Manager *m) {
         UnitFilePresetMode mode =
                 ENABLE_FIRST_BOOT_FULL_PRESET ? UNIT_FILE_PRESET_FULL : UNIT_FILE_PRESET_ENABLE_ONLY;
 
-        r = unit_file_preset_all(RUNTIME_SCOPE_SYSTEM, 0, NULL, mode, NULL, 0);
-        if (r < 0)
-                log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r,
-                               "Failed to populate /etc with preset unit settings, ignoring: %m");
-        else
-                log_info("Populated /etc with preset unit settings.");
+        RuntimeScope scope;
+
+        FOREACH_ARGUMENT(scope, RUNTIME_SCOPE_SYSTEM, RUNTIME_SCOPE_GLOBAL) {
+                r = unit_file_preset_all(scope, 0, NULL, mode, NULL, 0);
+                if (r < 0)
+                        log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r,
+                                       "Failed to populate /etc with %s preset unit settings, ignoring: %m", runtime_scope_to_string(scope));
+                else
+                        log_info("Populated /etc with %s preset unit settings.", runtime_scope_to_string(scope));
+        }
 }
 
 static void manager_ready(Manager *m) {