mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: read a file named - from standard input
A package script that has its entries at hand, and not yet in a file,
gives them to systemd-tmpfiles on standard input:
echo 'd /var/lib/app 0750 app app' | tmpfiles --create -
Finit's tmpfiles took - as the name of a file and failed to open it.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
3 files changed
+19
-10
No files matched your search
+12
-10
@@ -2351,12 +2351,14 @@ static void run_entries(int create)
|
||||
|
||||
static void process_file(const char *fn)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp = stdin;
|
||||
|
||||
fp = fopen(fn, "r");
|
||||
if (!fp) {
|
||||
warn("Failed to open %s", fn);
|
||||
return;
|
||||
if (strcmp(fn, "-")) {
|
||||
fp = fopen(fn, "r");
|
||||
if (!fp) {
|
||||
warn("Failed to open %s", fn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
conf = fn;
|
||||
|
||||
@@ -2364,11 +2366,9 @@ static void process_file(const char *fn)
|
||||
printf("# %s\n", fn);
|
||||
fcopyfile(fp, stdout);
|
||||
puts("");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof(fp)) {
|
||||
while (!cat_config && !feof(fp)) {
|
||||
/* No comment character, a # is only a comment at the start of a line */
|
||||
const char delim[3] = { '\\', '\\', 0 };
|
||||
char *line;
|
||||
@@ -2381,7 +2381,8 @@ static void process_file(const char *fn)
|
||||
free(line);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
static int by_name(const void *a, const void *b)
|
||||
@@ -2466,7 +2467,8 @@ static int usage(int rc)
|
||||
" -h, --help This help text\n"
|
||||
"\n"
|
||||
"If no CONFIGFILE is specified, all *.conf files in the standard\n"
|
||||
"tmpfiles.d directories are processed.\n"
|
||||
"tmpfiles.d directories are processed. A CONFIGFILE of - is read\n"
|
||||
"from standard input.\n"
|
||||
"\n");
|
||||
|
||||
return rc;
|
||||
|
||||
Reference in new issue
Block a user