[PATCHv2] macros: Add macro to apply sysusers based users/groups inside the jail

Message ID 20230402165659.3998-1-stefan.schantl@ipfire.org
State New
Headers
Series [PATCHv2] macros: Add macro to apply sysusers based users/groups inside the jail |

Commit Message

Stefan Schantl April 2, 2023, 4:56 p.m. UTC
  This macro can be called inside a build file and easily allows to apply
any kind of users/groups specified in a sysusers file.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 macros/systemd.macro | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Patch

diff --git a/macros/systemd.macro b/macros/systemd.macro
index 7a40cff6..0da90468 100644
--- a/macros/systemd.macro
+++ b/macros/systemd.macro
@@ -1,3 +1,14 @@ 
+MACRO_APPLY_SYSTEMD_SYSUSERS
+	mkdir -pv %{sysusersdir}
+
+	for file in %{DIR_SOURCE}/*.sysusers; do
+		[ -e "${file}" ] || continue
+		cat ${file} | \
+			systemd-sysusers --replace=%{sysusersdir}/$(basename ${file%*.sysusers}).conf -
+	done
+	unset file
+end
+
 MACRO_INSTALL_SYSTEMD_FILES
 	for file in %{DIR_SOURCE}/systemd/*; do
 		[ -e "${file}" ] || continue