From 5b4c0131214cd99b7b4936b97c728ce0c5d9af32 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 13 Jun 2014 20:04:31 +0200 Subject: [PATCH] core: don't complain at early boot if /etc/mtab is not the right symlink When we boot up with an empty /etc it's ok if the symlink doesn't exist. We will create it later with tmpfiles. --- src/core/main.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 29f2d5a2a..3aac5d1d9 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1151,19 +1151,25 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) { } static void test_mtab(void) { - char *p; - /* Check that /etc/mtab is a symlink */ + static const char ok[] = + "/proc/self/mounts\0" + "/proc/mounts\0" + "../proc/self/mounts\0" + "../proc/mounts\0"; - if (readlink_malloc("/etc/mtab", &p) >= 0) { - bool b; + _cleanup_free_ char *p = NULL; + int r; - b = streq(p, "/proc/self/mounts") || streq(p, "/proc/mounts"); - free(p); + /* Check that /etc/mtab is a symlink to the right place or + * non-existing. But certainly not a file, or a symlink to + * some weird place... */ - if (b) - return; - } + r = readlink_malloc("/etc/mtab", &p); + if (r == -ENOENT) + return; + if (r >= 0 && nulstr_contains(ok, p)) + return; log_warning("/etc/mtab is not a symlink or not pointing to /proc/self/mounts. " "This is not supported anymore. " -- 2.30.2