Skip to content

Commit 89bee1b

Browse files
committed
depends: tar: Always extract as yourself
For normal users, --no-same-owner is default, but not so for root, where it is assumed that root can change ownership willy-nilly. This is not the case for privilege-limited container environments where we gaslight the process into thinking it's root.
1 parent 340ef50 commit 89bee1b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

depends/funcs.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))
7676

7777

7878
#default commands
79+
# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior
7980
$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash))
80-
$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source)
81+
$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --no-same-owner --strip-components=1 -xf $$($(1)_source)
8182
$(1)_preprocess_cmds ?=
8283
$(1)_build_cmds ?=
8384
$(1)_config_cmds ?=
@@ -178,7 +179,7 @@ $($(1)_preprocessed): | $($(1)_dependencies) $($(1)_extracted)
178179
$(AT)touch $$@
179180
$($(1)_configured): | $($(1)_preprocessed)
180181
$(AT)echo Configuring $(1)...
181-
$(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar xf $($(package)_cached); )
182+
$(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar --no-same-owner -xf $($(package)_cached); )
182183
$(AT)mkdir -p $$(@D)
183184
$(AT)+cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1))
184185
$(AT)touch $$@

depends/packages/native_cctools.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ define $(package)_extract_cmds
2222
echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
2323
$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \
2424
mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \
25-
tar --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \
25+
tar --no-same-owner --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \
2626
rm -f toolchain/lib/libc++abi.so* && \
2727
echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \
2828
echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \
2929
chmod +x toolchain/bin/$(host)-dsymutil && \
30-
tar --strip-components=1 -xf $($(package)_source)
30+
tar --no-same-owner --strip-components=1 -xf $($(package)_source)
3131
endef
3232

3333
define $(package)_set_vars

depends/packages/qt.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ define $(package)_extract_cmds
125125
echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \
126126
$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \
127127
mkdir qtbase && \
128-
tar --strip-components=1 -xf $($(package)_source) -C qtbase && \
128+
tar --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \
129129
mkdir qttranslations && \
130-
tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \
130+
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \
131131
mkdir qttools && \
132-
tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools
132+
tar --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools
133133
endef
134134

135135
define $(package)_preprocess_cmds

0 commit comments

Comments
 (0)