Skip to content

Commit

Permalink
Fix ownership of VM files of unprivileged builds
Browse files Browse the repository at this point in the history
mkfs needs to see the files it copies into the fs as owned by root.
Otherwise the whole fs tree would be owned by the calling user. Doesn't
matter too much when setting up the build root initially as rpm is
called inside anyway to fix everything. However, when reusing an image
suddenly all ownerships would change.
  • Loading branch information
lnussel committed Sep 19, 2022
1 parent de70920 commit db0bf8d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ vm_img_mkfs() {
if test -n "$populate"; then
if test "$fs" = "ext2" -o "$fs" = "ext3" -o "$fs" = "ext4"; then
mkfs_extra_options="$mkfs_extra_options -d $populate"
# mkfs needs to see the files it copies into the fs as owned by root.
# Otherwise the whole fs tree would be owned by the calling user.
# Doesn't matter too much when setting up the build root initially as
# rpm is called inside anway to fix everything. However, when reusing
# an image suddenly all ownerships would change.
[ -x "/usr/bin/unshare" ] && mkfs="unshare --user --map-root-user $mkfs"
else
print "ERROR: populating filesystem is only supported with ext file systems"
cleanup_and_exit 1
Expand Down

0 comments on commit db0bf8d

Please sign in to comment.