# # spec file for package sysuser-tools # # Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: sysuser-tools Version: 3.1 Release: 4.7 Summary: Auto provides for system users License: MIT Group: System/Packages Source: sysusers.prov Source1: sysusers.attr Source2: sysusers-generate-pre Source3: macros.sysusers Source4: sysusers2shadow.sh BuildArch: noarch Requires: sysuser-shadow #!BuildIgnore: sysuser-shadow #!BuildIgnore: sysuser-tools BuildRequires: diffutils %description Generate auto provides for system users. %package -n sysuser-shadow Summary: Tool to execute sysusers.d with shadow utilities Group: System/Packages Requires(pre): (/usr/sbin/useradd or busybox) # prefer original shadow over busybox by default Suggests: shadow # sysusers2shdow uses sysusers2shadow uses systemd-sysusers if available. And we might pass --replace to it # --replace only appeared in systemd 238,so we want to ensure: if we have systemd, it must be recent enough # the Requires(pre) statement is to ensure we get it at any moment recent enough, not only at the end of # transactions, otherwise upgrades might randomly fail Requires(pre): (systemd >= 238 if systemd) Requires: (systemd >= 238 if systemd) %description -n sysuser-shadow This package contians a tool, which expects as input a sysusers.d configuration file and uses the shadow suite to create the users and groups from it like systemd-sysusers would do. %prep %setup -qcT %build %install install -D -m 755 %{SOURCE0} %{buildroot}%{_prefix}/lib/rpm/sysusers.prov install -D -m 644 %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/fileattrs/sysusers.attr install -D -m 755 %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/sysusers-generate-pre install -D -m 644 %{SOURCE3} %{buildroot}%{_rpmmacrodir}/macros.sysusers install -D -m 755 %{SOURCE4} %{buildroot}%{_sbindir}/sysusers2shadow %check mkdir -p subdir cat < subdir/me.conf # Type Name ID GECOS [HOME] Shell u me - "myself" /dev/null m me nogroup # foobar g asdf z welp invalid EOF cat < expected-account-pre /usr/sbin/sysusers2shadow me.conf <<"EOF" || [ -f /.buildenv ] u me - "myself" /dev/null m me nogroup g asdf EOF EOFF # copy pasta from macros.sysusers because the script sysusers-generate-pre is not in /usr/lib/rpm yet bash %{SOURCE2} $(pwd)/subdir/me.conf me.conf > account.pre diff account.pre expected-account-pre %files %defattr(-,root,root) %{_rpmmacrodir}/macros.sysusers %{_prefix}/lib/rpm/sysusers.prov %{_prefix}/lib/rpm/fileattrs/sysusers.attr %{_prefix}/lib/rpm/sysusers-generate-pre %files -n sysuser-shadow %defattr(-,root,root) %{_sbindir}/sysusers2shadow %changelog * Tue Feb 1 2022 Dirk Müller - invoke bash for bash scripts (bsc#1195391) * Wed Sep 8 2021 Thorsten Kukuk - Add support for new shell field [bsc#1189518] * Thu Jul 15 2021 Thorsten Kukuk - Use /bin/bash for sysusers-generate-pre * Tue Jun 29 2021 Dan Čermák - Remove usage of grep from sysusers-generate-pre - Add a simple test of sysusers-generate-pre to %%check * Mon Jun 21 2021 Dominique Leuenberger - Bump version up to 3.1. The --replace parameter only appeared in systemd 238, so we need to ensure to get the update order correct for sysuser-generate when using the 3rd command line parameters: * systemd -> sysuser-tools -> system-{user|group}-FOO. - Add dependency on systemd >=238 if systemd is installed to sysuser-shadow - update sysuser_requires to request sysuser-shadow 3.1 * Mon Jun 7 2021 Thorsten Kukuk - Support systemd-sysusers --replace=/usr/lib/sysusers.d/ option - sysusers-generate-pre: only use first argument for grep - sysusers2shadow.sh: use "run" prefix for systemd-sysusers call - macros.sysusers: fix typo * Sat May 8 2021 Callum Farmer - Use /usr/sbin/nologin instead of /sbin/nologin * Mon Feb 15 2021 Thorsten Kukuk - Don't abort on unbound first argument * Thu Feb 11 2021 Thorsten Kukuk - Remove sysusers/nscd workaround * Fri Jan 29 2021 Thorsten Kukuk - Use systemd-sysusers only if /proc is mounted, don't require it * Wed Jan 27 2021 Thorsten Kukuk - Set --replace option for systemd-sysusers * Wed Jan 20 2021 Thorsten Kukuk - Ignore nscd return code * Tue Jan 19 2021 Thorsten Kukuk - If systemd-sysusers is used to create a new user/group, invalidate the nscd passwd and group cache to make the new user/group visible immediately as workaround [bsc#1181121]. Needs to be removed after sytemd-sysusers get's fixed, since we invalidate the cache even if the user/group file wasn't changed. * Sun Jan 17 2021 Thorsten Kukuk - An "u" in a sysusers.d file will create an user and a group. Create provides for both, user and group. * Thu Jan 14 2021 Thorsten Kukuk - Use systemd-sysusers as default to create and update the user account. Fixes the problem that a modified sysusers config file get's ignored by useradd and adduser [bsc#1180549]. * Fri Dec 4 2020 Ludwig Nussel - useradd_or_adduser_dep must be PreReq so ordering makes sure it gets installed before. - suggest shadow where useradd_or_adduser_dep is actually required * Fri Sep 18 2020 Fabian Vogt - Avoid useless use of cat - Simplify %%sysusers_requires - Drop shebang, rpm passes it to /bin/sh itself * Fri Aug 21 2020 Thorsten Kukuk - Packages providing users need /usr/bin/cat installed to create them. Add that to the PreRequires. * Fri Aug 21 2020 Thorsten Kukuk - Create system groups for system users * Wed Mar 25 2020 Fabian Vogt - Fix bug introduced by simplification of check for useradd -g - Refactor use of sed away * Tue Mar 24 2020 Fabian Vogt - Use eval set -- $LINE instead of read for parsing * Fri Mar 20 2020 Fabian Vogt - Clean up sysusers2shadow and make it use only /bin/sh - Don't let busybox adduser create the home directory, it breaks permissions of e.g. /sbin (home of daemon) - Use only /bin/sh in sysusers-generate-pre and the generated code * Tue Mar 17 2020 Fabian Vogt - Drop use of tail from the generated %%pre scriptlets * Sun Dec 29 2019 kukuk@suse.de - Look for /bin/busybox, too - Add special handling for busybox and groups * Fri Jul 26 2019 kukuk@suse.de - Use suggests shadow to prefer that over busybox in normal systems * Thu Jul 25 2019 kukuk@suse.de - Add support for busybox adduser/addgroup - Change requirements from shadow to useradd_or_adduser_dep * Thu May 9 2019 kukuk@suse.de - Fix default home directory [bsc#1105934] - Use _rpmmacrodir for macro file * Mon Oct 9 2017 dimstar@opensuse.org - Further enhance sysusers-generate-pre: inside the build environment, it can be acceptable to be failing to create the users (e.g when building sysuser-tools or system-user-root, since those two packages have to be speificallty excluded). Always return with error code 0 if /.buildenv exists. * Wed Sep 27 2017 dimstar@opensuse.org - sysusers2shadow.sh: Exit if one of the useradd/groupadd/usermod call fails: the resulting system is quite undefined if this should happen. - sysusers-generate-pre: exit the pre script with the exit code of sysusers2shadow.sh. * Mon Jun 19 2017 kukuk@suse.de - sysuser-tools needs to require sysuser-shadow * Mon Jun 19 2017 kukuk@suse.de - Add requires for shadow to sysuser-shadow * Sun Jun 18 2017 kukuk@suse.de - Put helper script into own subpackage * Sat Jun 17 2017 kukuk@suse.de - Convert sysusers config file to shadow arguments and use shadow suite to create user and groups. Fixes [bsc#1041497] and serveral dependency loops. * Tue May 30 2017 kukuk@suse.de - Don't ignore errors of systemd-sysusers [bsc#1039708] * Wed Mar 15 2017 kukuk@suse.de - Don't remove 'm' and 'r' entries from sysusers configuration * Fri Jan 20 2017 kukuk@suse.de - Add macros.sysusers * Wed Dec 21 2016 lnussel@suse.de - initial package