chiark / gitweb /
sysusers: optionally, read sysuers configuration from standard input
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Aug 2014 00:14:32 +0000 (02:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Aug 2014 00:14:32 +0000 (02:14 +0200)
man/systemd-sysusers.xml
src/sysusers/sysusers.c

index 4de1973dc6dfbb3ad3bf26e24a5b0964ac7f494c..68710603ad2810c2e20c0dad6d92ec957d94a018 100644 (file)
                 basename of a file is specified, all directories as
                 specified in
                 <citerefentry><refentrytitle>sysusers.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
                 basename of a file is specified, all directories as
                 specified in
                 <citerefentry><refentrytitle>sysusers.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-                are searched for a matching file.</para>
+                are searched for a matching file. If the string
+                <filename>-</filename> is specified as filenames
+                entries from the standard input of the process are
+                read.</para>
         </refsect1>
 
         <refsect1>
         </refsect1>
 
         <refsect1>
index 7daea28073d00653f1e30c196a41fd966ab068e4..f78fb4fff374c4a20c4c51a6998503e7940d6d07 100644 (file)
@@ -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) {
 }
 
 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);
 
         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) {
         }
 
         FOREACH_LINE(line, f, break) {