From 034c3e7baf00c5b069ec0124f8f39398120b9315 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 1 Apr 2023 10:20:34 +0200 Subject: [PATCH] macros: Add macro to apply sysusers based users/groups inside the jail 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 --- macros/build.macro | 2 ++ macros/systemd.macro | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/macros/build.macro b/macros/build.macro index c19430a4..e80301ac 100644 --- a/macros/build.macro +++ b/macros/build.macro @@ -243,6 +243,8 @@ build # Install %{make_install} + %{MACRO_APPLY_SYSTEMD_SYSUSERS} + # Run custom commands %{install_cmds} end diff --git a/macros/systemd.macro b/macros/systemd.macro index 7a40cff6..e8a66ee3 100644 --- a/macros/systemd.macro +++ b/macros/systemd.macro @@ -1,3 +1,20 @@ +build + export APPLY_SYSUSERS_FILE= + + MACRO_APPLY_SYSTEMD_SYSUSERS + if [ -n "$APPLY_SYSUSERS_FILE" ] && [ -x "$(command -v systemd-sysusers)" ]; then + mkdir -pv %{sysusersdir} + + for file in ${APPLY_SYSUSERS_FILE}; do + [ -e "${file}" ] || continue + cat ${file} | \ + systemd-sysusers --replace=%{sysusersdir}/$(basename ${file%*.*}).conf - + done + unset file + fi + end +end + MACRO_INSTALL_SYSTEMD_FILES for file in %{DIR_SOURCE}/systemd/*; do [ -e "${file}" ] || continue -- 2.47.2