Content-Length: 364625 | pFad | http://github.com/SerenityOS/serenity/commit/0feefef996b7d80cb2629f027c9e6e595099edbe

4E Meta: Use fuse2fs if available to avoid root when building image · SerenityOS/serenity@0feefef · GitHub
Skip to content

Commit 0feefef

Browse files
committed
Meta: Use fuse2fs if available to avoid root when building image
The fuse2fs tool that is part of e2fsprogs-1.46 has a 'fakeroot' mount option. This allows a non-root users to modify file ownership and permissions without actually being root. This package is available in Debian bullseye and buster-backports. If available, the script assumes the user wants to use it. Otherwise, it falls back to the usual root requirements. Now that root is not required, the root check in build-root-filesystem.sh is not necessary. Since build-root-filesystem.sh has 'set -e' enabled, removing this check will not cause a change in functionality.
1 parent 2f4c863 commit 0feefef

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Meta/build-image-qemu.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ die() {
77
exit 1
88
}
99

10+
USE_FUSE2FS=0
11+
1012
if [ "$(id -u)" != 0 ]; then
11-
sudo -E -- "$0" "$@" || die "this script needs to run as root"
12-
exit 0
13+
if [ -x /usr/sbin/fuse2fs ] && /usr/sbin/fuse2fs --help 2>&1 |grep fakeroot > /dev/null; then
14+
USE_FUSE2FS=1
15+
else
16+
sudo -E -- "$0" "$@" || die "this script needs to run as root"
17+
exit 0
18+
fi
1319
else
1420
: "${SUDO_UID:=0}" "${SUDO_GID:=0}"
1521
fi
@@ -68,7 +74,7 @@ if [ -f _disk_image ]; then
6874

6975
echo "checking existing image"
7076
result=0
71-
e2fsck -f -y _disk_image || result=$?
77+
/usr/sbin/e2fsck -f -y _disk_image || result=$?
7278
if [ $result -ge 4 ]; then
7379
rm -f _disk_image
7480
USE_EXISTING=0
@@ -116,7 +122,9 @@ fi
116122
printf "mounting filesystem... "
117123
mkdir -p mnt
118124
use_genext2fs=0
119-
if [ "$(uname -s)" = "Darwin" ]; then
125+
if [ $USE_FUSE2FS -eq 1 ]; then
126+
mount_cmd="/usr/sbin/fuse2fs _disk_image mnt/ -o fakeroot,rw"
127+
elif [ "$(uname -s)" = "Darwin" ]; then
120128
mount_cmd="fuse-ext2 _disk_image mnt -o rw+,allow_other,uid=501,gid=20"
121129
elif [ "$(uname -s)" = "OpenBSD" ]; then
122130
mount_cmd="mount -t ext2fs "/dev/${VND}i" mnt/"
@@ -141,7 +149,11 @@ cleanup() {
141149
if [ -d mnt ]; then
142150
if [ $use_genext2fs = 0 ] ; then
143151
printf "unmounting filesystem... "
144-
umount mnt || ( sleep 1 && sync && umount mnt )
152+
if [ $USE_FUSE2FS -eq 1 ]; then
153+
fusermount -u mnt || (sleep 1 && sync && fusermount -u mnt)
154+
else
155+
umount mnt || ( sleep 1 && sync && umount mnt )
156+
fi
145157
rmdir mnt
146158
else
147159
rm -rf mnt

Meta/build-root-filesystem.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ die() {
2222
exit 1
2323
}
2424

25-
if [ "$(id -u)" != 0 ]; then
26-
die "this script needs to run as root"
27-
fi
28-
2925
[ -z "$SERENITY_SOURCE_DIR" ] && die "SERENITY_SOURCE_DIR is not set"
3026
[ -d "$SERENITY_SOURCE_DIR/Base" ] || die "$SERENITY_SOURCE_DIR/Base doesn't exist"
3127

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/SerenityOS/serenity/commit/0feefef996b7d80cb2629f027c9e6e595099edbe

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy