summaryrefslogtreecommitdiff
path: root/src/sysusers/sysusers.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-19 02:14:32 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-19 02:14:32 +0200
commitdfc87cbfe5ec03190e5b2235b1ed477db11541ca (patch)
treeb8ce6a02ba4b1cf78276277bb2af0807b41170d3 /src/sysusers/sysusers.c
parentd61bb44a89fde3042c7c15ea4975239f7dcb0cb0 (diff)
sysusers: optionally, read sysuers configuration from standard input
Diffstat (limited to 'src/sysusers/sysusers.c')
-rw-r--r--src/sysusers/sysusers.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 7daea28073..f78fb4fff3 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -1573,20 +1573,27 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
}
static int read_config_file(const char *fn, bool ignore_enoent) {
- _cleanup_fclose_ FILE *f = NULL;
+ _cleanup_fclose_ FILE *rf = NULL;
+ FILE *f = NULL;
char line[LINE_MAX];
unsigned v = 0;
int r;
assert(fn);
- r = search_and_fopen_nulstr(fn, "re", arg_root, conf_file_dirs, &f);
- if (r < 0) {
- if (ignore_enoent && r == -ENOENT)
- return 0;
+ if (streq(fn, "-"))
+ f = stdin;
+ else {
+ r = search_and_fopen_nulstr(fn, "re", arg_root, conf_file_dirs, &rf);
+ if (r < 0) {
+ if (ignore_enoent && r == -ENOENT)
+ return 0;
- log_error("Failed to open '%s', ignoring: %s", fn, strerror(-r));
- return r;
+ log_error("Failed to open '%s', ignoring: %s", fn, strerror(-r));
+ return r;
+ }
+
+ f = rf;
}
FOREACH_LINE(line, f, break) {