]> git.ipfire.org Git - pakfire.git/commitdiff
macros: Add macro to apply sysusers based users/groups inside the jail
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 1 Apr 2023 08:20:34 +0000 (10:20 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Apr 2023 12:25:47 +0000 (12:25 +0000)
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>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
macros/build.macro
macros/systemd.macro

index c19430a42fb3f291a83f5587cb378082b526778f..e80301ac252a3e6ec0615568784daa4afe9d6df1 100644 (file)
@@ -243,6 +243,8 @@ build
                # Install
                %{make_install}
 
+               %{MACRO_APPLY_SYSTEMD_SYSUSERS}
+
                # Run custom commands
                %{install_cmds}
        end
index 7a40cff64f559677cc84c90b27937e1ee100524a..e8a66ee3096b4b4a7a75565290cb4cd6f7bd6c21 100644 (file)
@@ -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