mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: add --cat-config, to show the files that would be read
With files in five directories, where one in /etc replaces the one
with the same name in /usr/lib, it is not easy to tell what tmpfiles
goes by. systemd-tmpfiles has --cat-config for this.
Add the option. It prints each file that would be read below a line
with its name, and exits:
/libexec/finit/tmpfiles --cat-config
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+28
-2
No files matched your search
@@ -34,6 +34,8 @@ All relevant changes are documented in this file.
|
|||||||
escapes, for a path with a space in it: `d "/srv/my files"`
|
escapes, for a path with a space in it: `d "/srv/my files"`
|
||||||
- tmpfiles: add the `~` modifier for `f`, `F`, and `w` entries, as in
|
- tmpfiles: add the `~` modifier for `f`, `F`, and `w` entries, as in
|
||||||
`f~`, where the argument is Base64, for a file with binary content
|
`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 `--prefix=PATH`, to only run the entries for paths below
|
- tmpfiles: add `--prefix=PATH`, to only run the entries for paths below
|
||||||
it. `--prefix` and `--exclude-prefix` match whole path components,
|
it. `--prefix` and `--exclude-prefix` match whole path components,
|
||||||
`--exclude-prefix=/dev` no longer skips `/devices`
|
`--exclude-prefix=/dev` no longer skips `/devices`
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ files or common packages already rely on, last what few will miss.
|
|||||||
2. Command line
|
2. Command line
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Missing options: `--root`, `--replace`, `--purge`, `--graceful`, and
|
Missing options: `--root`, `--replace`, `--purge`, and `--graceful`.
|
||||||
`--cat-config`.
|
|
||||||
|
|
||||||
|
|
||||||
3. Smaller things
|
3. Smaller things
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ int clean_flag = 0;
|
|||||||
int remove_flag = 0;
|
int remove_flag = 0;
|
||||||
int boot_flag = 0;
|
int boot_flag = 0;
|
||||||
int dry_run = 0;
|
int dry_run = 0;
|
||||||
|
int cat_config = 0;
|
||||||
|
|
||||||
/* Set for the first of two passes, the second one does the complaining */
|
/* Set for the first of two passes, the second one does the complaining */
|
||||||
static int quiet;
|
static int quiet;
|
||||||
@@ -1941,6 +1942,14 @@ static void process_file(const char *fn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cat_config) {
|
||||||
|
printf("# %s\n", fn);
|
||||||
|
fcopyfile(fp, stdout);
|
||||||
|
puts("");
|
||||||
|
fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
/* No comment character, a # is only a comment at the start of a line */
|
/* No comment character, a # is only a comment at the start of a line */
|
||||||
const char delim[3] = { '\\', '\\', 0 };
|
const char delim[3] = { '\\', '\\', 0 };
|
||||||
@@ -2020,6 +2029,7 @@ static int usage(int rc)
|
|||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --boot Also run boot-only entries, marked with !\n"
|
" --boot Also run boot-only entries, marked with !\n"
|
||||||
|
" --cat-config Show the files that would be read, and exit\n"
|
||||||
" -C, --clean Clean files and directories based on age\n"
|
" -C, --clean Clean files and directories based on age\n"
|
||||||
" -c, --create Create files and directories\n"
|
" -c, --create Create files and directories\n"
|
||||||
" -d, --debug Show developer debug messages\n"
|
" -d, --debug Show developer debug messages\n"
|
||||||
@@ -2041,12 +2051,14 @@ enum {
|
|||||||
OPT_EXCLUDE_PREFIX = 256,
|
OPT_EXCLUDE_PREFIX = 256,
|
||||||
OPT_BOOT,
|
OPT_BOOT,
|
||||||
OPT_PREFIX,
|
OPT_PREFIX,
|
||||||
|
OPT_CAT_CONFIG,
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{ "boot", 0, NULL, OPT_BOOT },
|
{ "boot", 0, NULL, OPT_BOOT },
|
||||||
|
{ "cat-config", 0, NULL, OPT_CAT_CONFIG },
|
||||||
{ "clean", 0, NULL, 'C' },
|
{ "clean", 0, NULL, 'C' },
|
||||||
{ "create", 0, NULL, 'c' },
|
{ "create", 0, NULL, 'c' },
|
||||||
{ "debug", 0, NULL, 'd' },
|
{ "debug", 0, NULL, 'd' },
|
||||||
@@ -2093,6 +2105,10 @@ int main(int argc, char *argv[])
|
|||||||
add_prefix(optarg);
|
add_prefix(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPT_CAT_CONFIG:
|
||||||
|
cat_config = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPT_EXCLUDE_PREFIX:
|
case OPT_EXCLUDE_PREFIX:
|
||||||
add_exclude_prefix(optarg);
|
add_exclude_prefix(optarg);
|
||||||
break;
|
break;
|
||||||
@@ -2110,6 +2126,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cat_config) {
|
||||||
|
process(argc - optind, &argv[optind]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (create_flag + clean_flag + remove_flag == 0) {
|
if (create_flag + clean_flag + remove_flag == 0) {
|
||||||
fprintf(stderr, "You need to specify at least one of --clean, --create, or --remove.\n");
|
fprintf(stderr, "You need to specify at least one of --clean, --create, or --remove.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -117,3 +117,7 @@ assert "Decoded, no specifiers" "$(texec cat $DIR/b64)" = "hello %t"
|
|||||||
assert "Padded" "$(texec cat $DIR/b64pad)" = "hi"
|
assert "Padded" "$(texec cat $DIR/b64pad)" = "hi"
|
||||||
assert "Written with w" "$(texec cat $DIR/w1)" = "XYcdef"
|
assert "Written with w" "$(texec cat $DIR/w1)" = "XYcdef"
|
||||||
assert "Skipped when not Base64" "$(texec sh -c "ls $DIR | grep -c b64bad")" = "0"
|
assert "Skipped when not Base64" "$(texec sh -c "ls $DIR | grep -c b64bad")" = "0"
|
||||||
|
|
||||||
|
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 "
|
||||||
Reference in new issue
Block a user