summaryrefslogtreecommitdiffstats
path: root/src/tmpfiles
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-09-26 14:46:08 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-09-27 16:59:24 +0200
commit1401882fdd0ac5c024b2c50ef584c1e06c911c0d (patch)
tree234b9360bcf0e3dff31491debcda8334bdf3abaa /src/tmpfiles
parenttmpfiles: fix detection of unitialized-/etc (diff)
downloadsystemd-1401882fdd0ac5c024b2c50ef584c1e06c911c0d.tar.xz
systemd-1401882fdd0ac5c024b2c50ef584c1e06c911c0d.zip
tmpfiles: downgrade message about unitialized-/etc
If we're running with --root, or in a chroot (*), it's expected that machine-id and other specifiers will be unresolvable, so downgrade the warning to debug. Fixes #24655. (*) sd_booted() in principle means more than that, but nowadays systemd dominates and those others things are infrequently seen.
Diffstat (limited to 'src/tmpfiles')
-rw-r--r--src/tmpfiles/tmpfiles.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 6cd19d929b..020219b176 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -69,6 +69,7 @@
#include "terminal-util.h"
#include "umask-util.h"
#include "user-util.h"
+#include "virt.h"
/* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
* them in the file system. This is intended to be used to create
@@ -285,20 +286,28 @@ static int specifier_directory(char specifier, const void *data, const char *roo
static int log_unresolvable_specifier(const char *filename, unsigned line) {
static bool notified = false;
- /* In system mode, this is called when /etc is not fully initialized (e.g.
- * in a chroot environment) where some specifiers are unresolvable. In user
- * mode, this is called when some variables are not defined. These cases are
- * not considered as an error so log at LOG_NOTICE only for the first time
- * and then downgrade this to LOG_DEBUG for the rest. */
+ /* In system mode, this is called when /etc is not fully initialized and some specifiers are
+ * unresolvable. In user mode, this is called when some variables are not defined. These cases are
+ * not considered a fatal error, so log at LOG_NOTICE only for the first time and then downgrade this
+ * to LOG_DEBUG for the rest.
+ *
+ * If we're running in a chroot (--root was used or sd_booted() reports that systemd is not running),
+ * always use LOG_DEBUG. We may be called to initialize a chroot before booting and there is no
+ * expectation that machine-id and other files will be populated.
+ */
+
+ int log_level = notified || arg_root || running_in_chroot() > 0 ?
+ LOG_DEBUG : LOG_NOTICE;
log_syntax(NULL,
- notified ? LOG_DEBUG : LOG_NOTICE,
+ log_level,
filename, line, 0,
- "Failed to resolve specifier: %s, skipping",
+ "Failed to resolve specifier: %s, skipping.",
arg_user ? "Required $XDG_... variable not defined" : "uninitialized /etc/ detected");
if (!notified)
- log_notice("All rules containing unresolvable specifiers will be skipped.");
+ log_full(log_level,
+ "All rules containing unresolvable specifiers will be skipped.");
notified = true;
return 0;