From 048c1724bfc3dde09be46ff3d2a432583c49a9d1 Mon Sep 17 00:00:00 2001 From: "Gerd v. Egidy" Date: Mon, 10 Jan 2022 22:47:21 +0100 Subject: [PATCH] easy way to use squashfs pseudofile: allows to override mode uid gid of files in the SRM When using a non-root user to execute sysrescue-customize with the srm building function, you won't have the rights to create files owned by root. When you want to keep the build_into_srm dir in a git tree, you won't be able to store the file mode there. But using a specific file mode is important for example for /root/.ssh The mksquashfs pseudo file allows to solve this by overriding individual file modes like this: cat <recipe_dir/build_into_srm/.squashfs-pseudo /root/.ssh m 700 root root /root/.ssh/authorized_keys m 600 root root EOF --- .../share/sysrescue/bin/sysrescue-customize | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/airootfs/usr/share/sysrescue/bin/sysrescue-customize b/airootfs/usr/share/sysrescue/bin/sysrescue-customize index eb4d9ff..f1338e1 100755 --- a/airootfs/usr/share/sysrescue/bin/sysrescue-customize +++ b/airootfs/usr/share/sysrescue/bin/sysrescue-customize @@ -506,16 +506,28 @@ create_srm() fi local squashfs_options="" + local squashfs_exclude="" + + # did the user specify a "pseudo-file"? a list with mode, uid, gid etc. overrides for files + if [[ -f "${SRM_DIR}/.squashfs-pseudo" ]]; then + squashfs_options+=" -pf \"${SRM_DIR}/.squashfs-pseudo\" " + + # exclude the pseudeo file from the filesystem + squashfs_exclude+=" -e .squashfs-pseudo" + fi + # load options for the mksquashfs call from options file if [[ -f "${SRM_DIR}/.squashfs-options" ]]; then # strip comment lines, replace newlines with spaces to allow using multiple lines easily - squashfs_options=$(cat "${SRM_DIR}/.squashfs-options" | grep -v "^#" | tr '\n' ' ') + squashfs_options+=$(cat "${SRM_DIR}/.squashfs-options" | grep -v "^#" | tr '\n' ' ') # exclude the options file from the filesystem - # excludes must come after other options, so add it after the content of the options file - squashfs_options+=" -e .squashfs-options" + squashfs_exclude+=" -e .squashfs-options" fi + # excludes must come after all other options + squashfs_options+="$squashfs_exclude" + # prepare the directory options to be correctly quoted for eval local dir_options="\"${SRM_DIR}\" \"${DEST_SRM}\""