summaryrefslogtreecommitdiff
path: root/src/tmpfiles
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-10 17:11:34 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-10 21:50:37 +0100
commit01131684ac66e82faae18e40e110089003d7c536 (patch)
treeb410298626a57a7982bcbfb19e90f126a75d0a0d /src/tmpfiles
parent23c32ff830458ba11590a1551aa4c73b1c7f43c8 (diff)
downloadsystemd-01131684ac66e82faae18e40e110089003d7c536.tar.gz
tmpfiles: explicitly say we need /proc/ to run
I don't think it's realistic to operate without /proc/. Hence, let's make this explicit. If one day someone finds a way to do what we need without /proc/ we can certainly drop this check again, but for now I think it's a lot friendlier to users to make this explicitly early on instead continuing to run and then not do what we need to do, oftentimes failing in cryptic ways. After all, invoking the tool without /proc/ is not an error that was specific to some of the lines we process, but it's systematic error that will show its ugly face in many codepaths down the line. Fixes: #14745
Diffstat (limited to 'src/tmpfiles')
-rw-r--r--src/tmpfiles/tmpfiles.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 63427ae659..97de00e3dc 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -3371,6 +3371,16 @@ static int run(int argc, char *argv[]) {
log_setup();
+ /* We require /proc/ for a lot of our operations, i.e. for adjusting access modes, for anything
+ * SELinux related, for recursive operation, for xattr, acl and chattr handling, for btrfs stuff and
+ * a lot more. It's probably the majority of invocations where /proc/ is required. Since people
+ * apparently invoke it without anyway and are surprised about the failures, let's catch this early
+ * and output a nice and friendly warning. */
+ if (proc_mounted() == 0)
+ return log_error_errno(SYNTHETIC_ERRNO(ENOSYS),
+ "/proc/ is not mounted, but required for successful operation of systemd-tmpfiles. "
+ "Please mount /proc/. Alternatively, consider using the --root= or --image= switches.");
+
/* Descending down file system trees might take a lot of fds */
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);