diff mbox series

[OpenWrt-Devel] download.mk, image.mk: add --mode=a-s option to tar

Message ID mailman.30266.1553792286.2376.openwrt-devel@lists.openwrt.org
State Accepted, archived
Delegated to: Christian Lamparter
Headers show
Series [OpenWrt-Devel] download.mk, image.mk: add --mode=a-s option to tar | expand

Commit Message

gio--- via openwrt-devel March 28, 2019, 4:58 p.m. UTC
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
Otherwise tar will keep the sgid bit when running from a sgid-set
directory, resulting in a different file being generated.

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
---

Notes:
    This fixes an issue exposed in
    https://github.com/openwrt/packages/pull/8513
    
    Tested it by reproducing the wrong tarball with master by setting ./tmp
    sgid.  Then applied the patch and ran it again, ending up with the right
    file.

Comments

Bjørn Mork March 28, 2019, 5:07 p.m. UTC | #1
Eneas U de Queiroz via openwrt-devel <openwrt-devel@lists.openwrt.org>
writes:

> Otherwise tar will keep the sgid bit when running from a sgid-set
> directory, resulting in a different file being generated.

Doh! Thanks a lot for looking at this.

Yes, I often set sgid on build-dirs to make sharing with other local
users easier.  I guess that's not very common.


Bjørn
diff mbox series

Patch

diff --git a/include/download.mk b/include/download.mk
index 33141910fc..09794e155e 100644
--- a/include/download.mk
+++ b/include/download.mk
@@ -55,7 +55,8 @@  define dl_pack
 	$(if $(dl_pack/$(call ext,$(1))),$(dl_pack/$(call ext,$(1))),$(dl_pack/unknown))
 endef
 define dl_tar_pack
-	$(TAR) --numeric-owner --owner=0 --group=0 --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
+	$(TAR) --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
+		$$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c $(2) | $(call dl_pack,$(1))
 endef
 
 ifdef CHECK
diff --git a/include/image.mk b/include/image.mk
index 9e40a54f51..b91a3a3d7a 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -291,7 +291,7 @@  endef
 
 ifdef CONFIG_TARGET_ROOTFS_TARGZ
   define Image/Build/targz
-	$(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \
+	$(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
 		$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
 		-C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
   endef