[systemd-commits] 4 commits - TODO src/core

Lennart Poettering lennart at kemper.freedesktop.org
Mon Jun 16 18:30:29 PDT 2014


 TODO                        |    2 --
 src/core/kmod-setup.c       |    6 +++++-
 src/core/machine-id-setup.c |   17 +++++++++++------
 src/core/main.c             |   20 ++++++++++++++++----
 4 files changed, 32 insertions(+), 13 deletions(-)

New commits:
commit 75183a9be0651ec220ceaad26570da5fedba151c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 17 03:30:11 2014 +0200

    update TODO

diff --git a/TODO b/TODO
index 7a3a5d0..f767f1c 100644
--- a/TODO
+++ b/TODO
@@ -35,8 +35,6 @@ Features:
 * tmpfiles: add support for "+" suffix for more commands
 
 * support empty /etc boots nicely:
-  - apply presets at first boot
-  - tmpfiles: allow overriding of /etc/mtab
   - tmpfiles: add nice way to copy files /usr/share/etc → /etc
 
 * generator that automatically discovers btrfs subvolumes, identifies their purpose based on some xattr on them.

commit 5f5c2f3855a87566e8885c7c0ae504782917a9b0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 17 03:25:34 2014 +0200

    core: populate unit file set with preset data if we boot with empty /etc

diff --git a/src/core/main.c b/src/core/main.c
index 82852d6..c4dfe8c 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1307,6 +1307,7 @@ int main(int argc, char *argv[]) {
         bool loaded_policy = false;
         bool arm_reboot_watchdog = false;
         bool queue_default_job = false;
+        bool empty_etc = false;
         char *switch_root_dir = NULL, *switch_root_init = NULL;
         static struct rlimit saved_rlimit_nofile = { 0, 0 };
 
@@ -1578,6 +1579,9 @@ int main(int argc, char *argv[]) {
                 if (in_initrd())
                         log_info("Running in initial RAM disk.");
 
+                empty_etc = dir_is_empty("/etc") > 0;
+                if (empty_etc)
+                        log_info("Running with unpopulated /etc.");
         } else {
                 _cleanup_free_ char *t = uid_to_name(getuid());
                 log_debug(PACKAGE_STRING " running in user mode for user "PID_FMT"/%s. (" SYSTEMD_FEATURES ")",
@@ -1634,9 +1638,18 @@ int main(int argc, char *argv[]) {
                 }
         }
 
-        if (arg_running_as == SYSTEMD_SYSTEM)
+        if (arg_running_as == SYSTEMD_SYSTEM) {
                 bump_rlimit_nofile(&saved_rlimit_nofile);
 
+                if (empty_etc) {
+                        r = unit_file_preset_all(UNIT_FILE_SYSTEM, false, NULL, UNIT_FILE_PRESET_FULL, false, NULL, 0);
+                        if (r < 0)
+                                log_warning("Failed to populate /etc with preset unit settings, ignoring: %s", strerror(-r));
+                        else
+                                log_info("Populated /etc with preset unit settings.");
+                }
+        }
+
         r = manager_new(arg_running_as, &m);
         if (r < 0) {
                 log_error("Failed to allocate manager object: %s", strerror(-r));

commit 489388fbc0be89e2b978258d277b5ff2da573174
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 17 03:25:02 2014 +0200

    machine-id-setup: allow passing NULL as function argument, for simplicity

diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 3efcd5f..e2e6d02 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -157,18 +157,23 @@ static int generate(char id[34], const char *root) {
 }
 
 int machine_id_setup(const char *root) {
+        const char *etc_machine_id, *run_machine_id;
         _cleanup_close_ int fd = -1;
-        int r;
         bool writable = false;
         struct stat st;
         char id[34]; /* 32 + \n + \0 */
-        char *etc_machine_id, *run_machine_id;
+        int r;
 
-        etc_machine_id = strappenda(root, "/etc/machine-id");
-        path_kill_slashes(etc_machine_id);
+        if (isempty(root))  {
+                etc_machine_id = "/etc/machine-id";
+                run_machine_id = "/run/machine-id";
+        } else {
+                etc_machine_id = strappenda(root, "/etc/machine-id");
+                path_kill_slashes((char*) etc_machine_id);
 
-        run_machine_id = strappenda(root, "/run/machine-id");
-        path_kill_slashes(run_machine_id);
+                run_machine_id = strappenda(root, "/run/machine-id");
+                path_kill_slashes((char*) run_machine_id);
+        }
 
         RUN_WITH_UMASK(0000) {
                 /* We create this 0444, to indicate that this isn't really
diff --git a/src/core/main.c b/src/core/main.c
index 899233b..82852d6 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1592,7 +1592,7 @@ int main(int argc, char *argv[]) {
                 kmod_setup();
 #endif
                 hostname_setup();
-                machine_id_setup("");
+                machine_id_setup(NULL);
                 loopback_setup();
 
                 test_mtab();

commit c47fc1f025dd4b4c22d4650385748dc8486df0b6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 17 03:23:23 2014 +0200

    kmod: conditionalize kmod setup on CAP_SYS_MODULE, not whether we run in a container
    
    It's generally preferrable to conditionalize on the actual ability to do
    something then the context we run in.

diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 0791ae8..2f3f608 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -27,7 +27,7 @@
 
 #include "macro.h"
 #include "execute.h"
-
+#include "capability.h"
 #include "kmod-setup.h"
 
 static void systemd_kmod_log(
@@ -54,6 +54,7 @@ static bool cmdline_check_kdbus(void) {
 }
 
 int kmod_setup(void) {
+
         static const struct {
                 const char *module;
                 const char *path;
@@ -76,6 +77,9 @@ int kmod_setup(void) {
         unsigned int i;
         int r;
 
+        if (have_effective_cap(CAP_SYS_MODULE) == 0)
+                return 0;
+
         for (i = 0; i < ELEMENTSOF(kmod_table); i++) {
                 struct kmod_module *mod;
 
diff --git a/src/core/main.c b/src/core/main.c
index 4ad3bc2..899233b 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1589,8 +1589,7 @@ int main(int argc, char *argv[]) {
                         status_welcome();
 
 #ifdef HAVE_KMOD
-                if (detect_container(NULL) <= 0)
-                        kmod_setup();
+                kmod_setup();
 #endif
                 hostname_setup();
                 machine_id_setup("");



More information about the systemd-commits mailing list