From cb77da9a7e1881ae3f3620fe465df461045b63c2 Mon Sep 17 00:00:00 2001 From: Коренберг Марк Date: Jun 16 2021 05:13:33 +0000 Subject: [PATCH 1/2] Introduce %sysusers_create --- diff --git a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc index 7363a31..e180a35 100644 --- a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc +++ b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc @@ -165,6 +165,29 @@ install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/munge.conf [...] ``` +Starting from Fedora 33 new macroses shall be used: +``` +[...] +BuildRequires: systemd-rpm-macros + +[...] +Requires(pre): /usr/bin/systemd-sysusers + +[...] +%install +install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/munge.conf + +[...] +%pre +%sysusers_create %{SOURCE3} + +[...] +%files +%{_sysusersdir}/munge.conf + +[...] +``` + === Soft static allocation To allocate a UID and/or GID, From 1b60d46341e7ce15bd9009053322d023e6c9b7ba Mon Sep 17 00:00:00 2001 From: Коренберг Марк Date: Dec 01 2021 19:08:19 +0000 Subject: [PATCH 2/2] Update guidelines/modules/ROOT/pages/UsersAndGroups.adoc --- diff --git a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc index e180a35..ee2f7f3 100644 --- a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc +++ b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc @@ -137,55 +137,66 @@ In these cases, apply only the `+groupadd+` parts of the below recipes. To create users and groups in packages using dynamic allocation, do the following: -Create a `.sysusers` file with the user definition and add it to the specfile as a source. +Create a `-sysusers.conf` file with the user definition and add it to the specfile as a source. For example for the `munge` package, this file contains: ``` #Type Name ID GECOS Home directory Shell u munge - "Runs Uid 'N' Gid Emporium" /run/munge /sbin/nologin ``` -In the specfile, add a BuildRequires for systemd-rpm-macros, install the sysusers file, - and use the `%sysusers_create_compat` macro to consume it in the `%pre` section -(in this example the sysusers config file is `Source3` of the specfile): +For different Fedora version, different macroses are recommended. Use the following hints: + +For Fedora 32 and lower: ``` +Source3: %{name}-sysusers.conf [...] BuildRequires: systemd-rpm-macros - +%sysusers_requires_compat [...] %install -install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/munge.conf - +install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf [...] %pre %sysusers_create_compat %{SOURCE3} - [...] %files -%{_sysusersdir}/munge.conf -[...] +%{_sysusersdir}/%{name}.conf ``` -Starting from Fedora 33 new macroses shall be used: +For Fedora 33: ``` +Source3: %{name}-sysusers.conf [...] -BuildRequires: systemd-rpm-macros - +BuildRequires: systemd-rpm-macros [...] Requires(pre): /usr/bin/systemd-sysusers - [...] %install -install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/munge.conf - +install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf [...] %pre %sysusers_create %{SOURCE3} - [...] %files -%{_sysusersdir}/munge.conf +%{_sysusersdir}/%{name}.conf +``` +Fedora 34 and higher: +``` +Source3: %{name}-sysusers.conf +[...] +BuildRequires: systemd-rpm-macros +[...] +Requires(pre): /usr/bin/systemd-sysusers [...] +%install +install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf +[...] +%pre +%sysusers_create_package %{name} %{SOURCE3} +[...] +%files +%{_sysusersdir}/%{name}.conf ``` === Soft static allocation