From: Lennart Poettering Date: Fri, 13 Jun 2014 18:04:31 +0000 (+0200) Subject: core: don't complain at early boot if /etc/mtab is not the right symlink X-Git-Tag: v215~431 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5b4c0131214cd99b7b4936b97c728ce0c5d9af32;p=elogind.git 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. --- 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. "