diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 37524834..68e67b2c 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -301,6 +301,8 @@ All relevant changes are documented in this file. - Fix `tmpfiles --clean` for an `e` entry with a glob in the path, like `e /var/cache/* - - - 10d`, nothing was cleaned. The age of a `C` entry is now used as well +- Fix tmpfiles `w` entries with a glob that matches several paths, all + but the first got the argument only up to its first backslash escape - 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 diff --git a/doc/tmpfiles-todo.md b/doc/tmpfiles-todo.md index 397784fb..207f6832 100644 --- a/doc/tmpfiles-todo.md +++ b/doc/tmpfiles-todo.md @@ -39,9 +39,6 @@ Missing options: `--root`, `--replace`, `--dry-run`, `--purge`, that mode and owner could not be set * An `x` or `X` entry with an age should have what it names cleaned by that age, the age is not read -* A `w` entry with a glob that matches several paths writes its - argument only up to the first backslash for all but the first, - `write_arg()` cuts the argument up as it goes * The `%T` and `%V` specifiers are always `/tmp` and `/var/tmp`, they do not look at `$TMPDIR` * `mksubsys()` in `src/util.c` is unused diff --git a/src/tmpfiles.c b/src/tmpfiles.c index 92de730d..0a35f35e 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -252,7 +252,7 @@ static void write_arg(FILE *fp, char *arg) while (*arg && (p = strchr(arg, '\\'))) { fwrite(arg, sizeof(char), p - arg, fp); - *p++ = 0; + p++; switch (*p) { case '\\': fputc('\\', fp); diff --git a/test/tmpfiles-arg.sh b/test/tmpfiles-arg.sh index fcb06f10..b96502f3 100755 --- a/test/tmpfiles-arg.sh +++ b/test/tmpfiles-arg.sh @@ -50,3 +50,13 @@ f $DIR/input CONF run "/libexec/finit/tmpfiles --create --prefix=$DIR/in $CONF" assert "Only below the prefix" "$(texec sh -c "ls -d $DIR/in* $DIR/out* 2>/dev/null" | tr '\n' ' ')" = "$DIR/in " + +sep +say 'w writes all of its argument to every path a glob matches' +run "touch $DIR/w1 $DIR/w2" +run "cat > $CONF" <<'CONF' +w /tmp/arg/w? - - - - one\ntwo +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"