Ticket #7667: image.mk-preserve-permissions.patch

File image.mk-preserve-permissions.patch, 1.1 KB (added by ermo <rune.morling+openwrt@…, 8 years ago)

include/image.mk -- don't clobber SUID/SGID bits in rootfs binaries and preserve permissions in rootfs.tar.gz

  • include/image.mk

    old new  
    105105 
    106106ifneq ($(CONFIG_TARGET_ROOTFS_TARGZ),) 
    107107  define Image/mkfs/targz 
    108                 $(TAR) -zcf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ . 
     108                # Preserve permissions when creating rootfs.tar.gz as non-root user (-p). 
     109                $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ . 
    109110  endef 
    110111endif 
    111112 
     
    127128 
    128129define Image/mkfs/prepare/default 
    129130        - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -print0 | $(XARGS) -0 chmod 0644 
    130         - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod 0755 
     131        # Don't touch binaries with SUID/SGID bits set (! -perm /6000) and report which binaries are changed. 
     132        - $(FIND) $(TARGET_DIR) -type f -perm +0100 ! -perm /6000 -print0 | $(XARGS) --verbose -0 chmod --changes 0755 
    131133        - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod 0755 
    132134        $(INSTALL_DIR) $(TARGET_DIR)/tmp 
    133135        chmod 0777 $(TARGET_DIR)/tmp