diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index b5315a30..588b21d6 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -315,6 +315,8 @@ All relevant changes are documented in this file. - Fix age `0` in a tmpfiles entry, it was read as no age. As in tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an 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 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 67ae8df3..da405a99 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -23,6 +23,7 @@ #include "config.h" /* Generated by configure script */ +#include #include #include #include @@ -190,9 +191,7 @@ static char *write_hex(FILE *fp, char *p) for (i = 0; p[i] && len < 2; i++) { char c = p[i]; - if ((c >= '0' && c <= '7') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')) + if (isxdigit((unsigned char)c)) num[len++] = c; else break; diff --git a/test/tmpfiles-arg.sh b/test/tmpfiles-arg.sh index 6d8272c7..20eabd85 100755 --- a/test/tmpfiles-arg.sh +++ b/test/tmpfiles-arg.sh @@ -64,3 +64,11 @@ CONF run "/libexec/finit/tmpfiles --create $CONF" 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' +run "cat > $CONF" <<'CONF' +f /tmp/arg/hex - - - - \x39\x41\x4a\x6b +CONF +run "/libexec/finit/tmpfiles --create $CONF" +assert "All hex digits" "$(texec cat $DIR/hex)" = "9AJk"