From c9355ad94a207f4f79b6d688d2280171dbbd1739 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 11 Aug 2025 14:48:57 +0300 Subject: [PATCH] BuildSystem: Fix file permission bits on image creation If a file had setuid/setgid/sticky bits set, they were not copied to the sysroot --- script/image.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/script/image.sh b/script/image.sh index a8f9f232..d8cd8867 100755 --- a/script/image.sh +++ b/script/image.sh @@ -47,21 +47,23 @@ if sudo mount $ROOT_PARTITION $MOUNT_DIR; then else sudo rsync -rulHpt $BANAN_SYSROOT/ $MOUNT_DIR - fakeroot -i $BANAN_FAKEROOT find $BANAN_SYSROOT -printf './%P|%U|%G\n' >$BANAN_BUILD_DIR/sysroot-perms.txt + fakeroot -i $BANAN_FAKEROOT find $BANAN_SYSROOT -printf './%P|%U|%G|%04m\n' >$BANAN_BUILD_DIR/sysroot-perms.txt sudo bash -c " if enable stat &>/dev/null; then - while IFS='|' read -r path uid gid; do + while IFS='|' read -r path uid gid mode; do full=\"$MOUNT_DIR/\$path\" stat \"\$full\" - if [[ \${STAT[uid]} != \$uid ]] || [[ \${STAT[gid]} != \$gid ]]; then + if [[ \${STAT[uid]} != \$uid ]] || [[ \${STAT[gid]} != \$gid ]] || [[ \${STAT[perms]} != \$mode ]]; then chown -h \"\$uid:\$gid\" \"\$full\" + chmod -h \"\$mode\" \"\$full\" fi done <$BANAN_BUILD_DIR/sysroot-perms.txt else - while IFS='|' read -r path uid gid; do + while IFS='|' read -r path uid gid mode; do full=\"$MOUNT_DIR/\$path\" - if [[ \$(stat -c '%u %g' \"\$full\") != \"\$uid \$gid\" ]]; then + if [[ \$(stat -c '%u %g %a' \"\$full\") != \"\$uid \$gid \$mode\" ]]; then chown -h \"\$uid:\$gid\" \"\$full\" + chmod -h \"\$mode\" \"\$full\" fi done <$BANAN_BUILD_DIR/sysroot-perms.txt fi