I've been playing around with trying to resolve file ownership in the squashfs partition at build time. The default build system in include/image.mk
uses the -root-owned
flag which allows a non-privileged user to create root-owned files in the image.
define Image/mkfs/squashfs
$(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \
-nopad -noappend -root-owned \
-comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \
-processors 1 \
$(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
endef
I had hoped that the pseudo-definition/file feature could also be used to have specific overrides of ownership:group.
-SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
+SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1' -p '/test-file f 600 50 50 echo test-file contents'
Unfortunately it seems that the file, while generated, ends up being root:root for ownership.
Does anyone know a "trick" that a non-privileged user can use, short of find
everything and generating a pseudo-file that contains every file in the image?