diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index b6752cc3..ea3ffc21 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -36,6 +36,8 @@ All relevant changes are documented in this file. `f~`, where the argument is Base64, for a file with binary content - tmpfiles: add `--cat-config`, to show the files that would be read, each below a line with its name +- tmpfiles: add `--graceful`, for scripts that give it. It changes + nothing, an unknown user or group is never an error in Finit - tmpfiles: add `--prefix=PATH`, to only run the entries for paths below it. `--prefix` and `--exclude-prefix` match whole path components, `--exclude-prefix=/dev` no longer skips `/devices` diff --git a/doc/tmpfiles-todo.md b/doc/tmpfiles-todo.md index 3537e5fd..03a3fd80 100644 --- a/doc/tmpfiles-todo.md +++ b/doc/tmpfiles-todo.md @@ -22,7 +22,7 @@ files or common packages already rely on, last what few will miss. 2. Command line --------------- -Missing options: `--root`, `--replace`, `--purge`, and `--graceful`. +Missing options: `--root`, `--replace`, and `--purge`. 3. Smaller things diff --git a/src/tmpfiles.c b/src/tmpfiles.c index 725e2df9..d0ebbf79 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -2036,6 +2036,7 @@ static int usage(int rc) " -n, --dry-run Only show the entries that would be run\n" " -E Exclude /dev, /proc, /run, and /sys\n" " --exclude-prefix=PFX Ignore rules for paths starting with PFX\n" + " --graceful Does nothing, an unknown user or group is never an error\n" " --prefix=PFX Only apply rules for paths starting with PFX\n" " -r, --remove Remove files and directories marked for removal\n" " -h, --help This help text\n" @@ -2052,6 +2053,7 @@ enum { OPT_BOOT, OPT_PREFIX, OPT_CAT_CONFIG, + OPT_GRACEFUL, }; int main(int argc, char *argv[]) @@ -2064,6 +2066,7 @@ int main(int argc, char *argv[]) { "debug", 0, NULL, 'd' }, { "dry-run", 0, NULL, 'n' }, { "exclude-prefix", 1, NULL, OPT_EXCLUDE_PREFIX }, + { "graceful", 0, NULL, OPT_GRACEFUL }, { "prefix", 1, NULL, OPT_PREFIX }, { "remove", 0, NULL, 'r' }, { "help", 0, NULL, 'h' }, @@ -2109,6 +2112,9 @@ int main(int argc, char *argv[]) cat_config = 1; break; + case OPT_GRACEFUL: + break; + case OPT_EXCLUDE_PREFIX: add_exclude_prefix(optarg); break; diff --git a/test/tmpfiles-arg.sh b/test/tmpfiles-arg.sh index 6b8c590c..e6bb738d 100755 --- a/test/tmpfiles-arg.sh +++ b/test/tmpfiles-arg.sh @@ -121,3 +121,8 @@ assert "Skipped when not Base64" "$(texec sh -c "ls $DIR | grep -c b64bad")" = " sep say '--cat-config shows the files that would be read' assert "Files with their name" "$(texec /libexec/finit/tmpfiles --cat-config $CONF | head -2 | tr '\n' ' ')" = "# $CONF f~ /tmp/arg/b64 - - - - aGVsbG8gJXQK " + +sep +say '--graceful is taken, and changes nothing' +run "rm $DIR/b64; /libexec/finit/tmpfiles --create --graceful $CONF" +assert "Runs with --graceful" "$(texec cat $DIR/b64)" = "hello %t"