tmpfiles: take --graceful

Package scripts written for systemd-tmpfiles may call it with
--graceful, to not fail on an entry for a user or group that does not
exist.  tmpfiles then stops at the unknown option and prints its usage
text:

    tmpfiles --create --graceful /usr/lib/tmpfiles.d/foo.conf

Take the option and do nothing.  An entry with an unknown user is
already skipped without an error, and an unknown group left alone.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-21 17:14:02 +01:00
1 parent 6b5a8e0386
commit c349d564d4
4 files changed
+14 -1

No files matched your search

+6
View File
@@ -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;