]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(systemd-sysusers): silence "Creating " on stderr
authorBenjamin Drung <benjamin.drung@canonical.com>
Fri, 21 Feb 2025 22:49:04 +0000 (23:49 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Mon, 24 Feb 2025 03:28:57 +0000 (04:28 +0100)
dracut prints 20 lines when creating users and groups even with
`--quiet` option. Sample output:

```
Creating group 'nobody' with GID 65534.
Creating group 'audio' with GID 997.
Creating group 'disk' with GID 995.
Creating group 'input' with GID 994.
Creating group 'kmem' with GID 993.
Creating group 'kvm' with GID 992.
Creating group 'lp' with GID 991.
Creating group 'optical' with GID 990.
Creating group 'render' with GID 989.
Creating group 'sgx' with GID 988.
Creating group 'storage' with GID 987.
Creating group 'tty' with GID 5.
Creating group 'uucp' with GID 986.
Creating group 'video' with GID 985.
Creating group 'users' with GID 984.
Creating group 'systemd-journal' with GID 983.
Creating user 'root' (Super User) with UID 0 and GID 0.
Creating user 'nobody' (Kernel Overflow User) with UID 65534 and GID 65534.
Creating group 'nobody' with GID 65534.
Creating group 'audio' with GID 997.
```

Filter "Creating " messages from stderr, but keep the other messages on
stderr and all messages on stdout untouched.

Fixes: https://github.com/dracut-ng/dracut-ng/issues/1195
Fixes: f3dacc013d90 ("feat(systemd-sysusers): run systemd-sysusers as part of the build process")
modules.d/60systemd-sysusers/module-setup.sh

index 977695e61be1e225a3244ed64df0d174f5955aff..0bddd19dd85b1459cd4c5098fefec2f3a087d5fe 100755 (executable)
@@ -15,5 +15,9 @@ check() {
 install() {
     inst_sysusers basic.conf
 
-    systemd-sysusers --root="$initdir" > /dev/null
+    # redirect stdout temporarily to FD 3 to use filter stderr
+    {
+        set -o pipefail
+        systemd-sysusers --root="$initdir" 2>&1 >&3 | grep -v "^Creating " >&2
+    } 3>&1
 }