[systemd-commits] 3 commits - TODO man/systemd-sysusers.xml src/core src/sysusers

Lennart Poettering lennart at kemper.freedesktop.org
Mon Aug 18 17:19:19 PDT 2014


 TODO                       |    1 -
 man/systemd-sysusers.xml   |    5 ++++-
 src/core/macros.systemd.in |    4 ++++
 src/sysusers/sysusers.c    |   21 ++++++++++++++-------
 4 files changed, 22 insertions(+), 9 deletions(-)

New commits:
commit 93aef81600437b96c96c6ca32ce85df32631c351
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 19 02:19:10 2014 +0200

    update TODO

diff --git a/TODO b/TODO
index cd51393..264b525 100644
--- a/TODO
+++ b/TODO
@@ -106,7 +106,6 @@ Features:
 * sysusers:
   - allow setting the home directory of system users
   - allow configuration of ranges to allocate items in
-  - add mode where we read sysusers data from stdin, so that we can run this from rpm scriptlets
 
 * Add a new verb "systemctl top"
 

commit 0e77023ea0ce315af6b0c4806b27c0140c91bbc7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 19 02:16:27 2014 +0200

    sysusers: add a new RPM macro for creating users directly from data passed in via stdin
    
    This allows encoding users to create directly in %pre, which is
    necessary so that files owned by the RPM can be assigned to the right
    users/groups.
    
    This new macro does create a redundancy, as user definitions for all
    users that shall own files need to to be listed twice, once with this
    new macro, and then secondly, in the sysusers file shipped with the
    package. But there's little way around that, as the users of this type
    need to exist before we install the first file, but we actually want to
    ship the user information in a file.

diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in
index 0d5f894..333f222 100644
--- a/src/core/macros.systemd.in
+++ b/src/core/macros.systemd.in
@@ -83,6 +83,10 @@ systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \
 systemd-sysusers %{?*} >/dev/null 2>&1 || : \
 %{nil}
 
+%sysusers_create_inline() \
+echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \
+%{nil}
+
 %sysctl_apply() \
 @rootlibexecdir@/systemd-sysctl %{?*} >/dev/null 2>&1 || : \
 %{nil}

commit dfc87cbfe5ec03190e5b2235b1ed477db11541ca
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 19 02:14:32 2014 +0200

    sysusers: optionally, read sysuers configuration from standard input

diff --git a/man/systemd-sysusers.xml b/man/systemd-sysusers.xml
index 4de1973..6871060 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
                 <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>
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 7daea28..f78fb4f 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) {



More information about the systemd-commits mailing list