From 8bc89cdde46cba913fff4e050d58deb32dd4e0af Mon Sep 17 00:00:00 2001 From: Коренберг Марк Date: Jan 26 2022 17:28:13 +0000 Subject: [PATCH 1/2] Update dynamic user id guidlines. --- diff --git a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc index 8c8f3fc..348f52a 100644 --- a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc +++ b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc @@ -137,32 +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): +Fedora 34 and higher: ``` +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}/%{name}.conf +[...] +%pre +%sysusers_create_package %{name} %{SOURCE3} +[...] +%files +%{_sysusersdir}/%{name}.conf +``` + +Historic Fedora versions used other macroses: +Fedora 33: +``` +Source3: %{name}-sysusers.conf +[...] +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}/%{name}.conf +``` +Fedora 32 and lower: +``` +Source3: %{name}-sysusers.conf +[...] +BuildRequires: systemd-rpm-macros +%sysusers_requires_compat +[...] +%install +install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf [...] %pre %sysusers_create_compat %{SOURCE3} - [...] %files -%{_sysusersdir}/munge.conf -[...] +%{_sysusersdir}/%{name}.conf ``` === Soft static allocation From 4d4af635ebcf12ed2bb1d2e19c02b88aa60b2538 Mon Sep 17 00:00:00 2001 From: Коренберг ☢️ Марк Date: Jan 26 2022 17:28:42 +0000 Subject: [PATCH 2/2] Removed dynamic user ID guidlines for obsolete Fedora versions --- diff --git a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc index 348f52a..5cc4337 100644 --- a/guidelines/modules/ROOT/pages/UsersAndGroups.adoc +++ b/guidelines/modules/ROOT/pages/UsersAndGroups.adoc @@ -144,7 +144,6 @@ For example for the `munge` package, this file contains: u munge - "Runs Uid 'N' Gid Emporium" /run/munge /sbin/nologin ``` -Fedora 34 and higher: ``` Source3: %{name}-sysusers.conf [...] @@ -162,43 +161,6 @@ install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf %{_sysusersdir}/%{name}.conf ``` -Historic Fedora versions used other macroses: - -Fedora 33: -``` -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 %{SOURCE3} -[...] -%files -%{_sysusersdir}/%{name}.conf -``` - -Fedora 32 and lower: -``` -Source3: %{name}-sysusers.conf -[...] -BuildRequires: systemd-rpm-macros -%sysusers_requires_compat -[...] -%install -install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf -[...] -%pre -%sysusers_create_compat %{SOURCE3} -[...] -%files -%{_sysusersdir}/%{name}.conf -``` - === Soft static allocation To allocate a UID and/or GID,