From: Lennart Poettering Date: Tue, 19 Aug 2014 00:14:32 +0000 (+0200) Subject: sysusers: optionally, read sysuers configuration from standard input X-Git-Tag: v216~37 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=dfc87cbfe5ec03190e5b2235b1ed477db11541ca sysusers: optionally, read sysuers configuration from standard input --- diff --git a/man/systemd-sysusers.xml b/man/systemd-sysusers.xml index 4de1973dc..68710603a 100644 --- a/man/systemd-sysusers.xml +++ b/man/systemd-sysusers.xml @@ -75,7 +75,10 @@ basename of a file is specified, all directories as specified in sysusers.d5 - are searched for a matching file. + are searched for a matching file. If the string + - is specified as filenames + entries from the standard input of the process are + read. diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 7daea2807..f78fb4fff 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) {