diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 588b21d6..d09b0dad 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -317,6 +317,10 @@ All relevant changes are documented in this file. entry - Fix `\x` escapes with the digits 8 or 9 in the argument of a tmpfiles entry, `\x39` was written as the byte 3 and a `9` +- Fix a `#` in the argument of a tmpfiles entry, it and the rest of the + line were dropped as a comment. As in tmpfiles.d(5), only a line that + starts with `#` is a comment. **Note:** a comment at the end of an + entry is now read as its argument - Fix logins refused after boot on a system with systemd's tmpfiles.d files installed. They create `/run/nologin` at boot, and on systemd it is removed by systemd-user-sessions. Finit now removes it when leaving diff --git a/src/tmpfiles.c b/src/tmpfiles.c index da405a99..fffe8af0 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -1374,7 +1374,7 @@ static void tmpfiles(char *line) glob_t gl; type = strtok(line, "\t "); - if (!type) + if (!type || type[0] == '#') return; for (char *mod = &type[1]; *mod; mod++) { @@ -1821,9 +1821,11 @@ static void process_file(const char *fn) } while (!feof(fp)) { + /* No comment character, a # is only a comment at the start of a line */ + const char delim[3] = { '\\', '\\', 0 }; char *line; - line = fparseln(fp, NULL, NULL, NULL, FPARSELN_UNESCCOMM); + line = fparseln(fp, NULL, NULL, delim, 0); if (!line) continue; diff --git a/test/tmpfiles-arg.sh b/test/tmpfiles-arg.sh index 20eabd85..489dd067 100755 --- a/test/tmpfiles-arg.sh +++ b/test/tmpfiles-arg.sh @@ -66,9 +66,13 @@ assert "First match" "$(texec cat $DIR/w1 | tr '\n' ' ')" = "one two" assert "Second match" "$(texec cat $DIR/w2 | tr '\n' ' ')" = "one two" sep -say 'Escapes in the argument' +say 'Escapes, and a # that is not at the start of the line' run "cat > $CONF" <<'CONF' +# A comment + # and one more f /tmp/arg/hex - - - - \x39\x41\x4a\x6b +f /tmp/arg/hash - - - - a#b c CONF run "/libexec/finit/tmpfiles --create $CONF" assert "All hex digits" "$(texec cat $DIR/hex)" = "9AJk" +assert "No comment in line" "$(texec cat $DIR/hash)" = "a#b c"