From b9112f310cb117b3ab72a642e09ab8cce552668a Mon Sep 17 00:00:00 2001 From: Adrian Serrano Date: Fri, 1 Jun 2018 21:48:00 +0700 Subject: [PATCH] Fix tar packages permissions When Docker is run in Mac under Virtualbox, volumes in docker don't have the expected uid=0,gid=0 permissions, but those that Docker is using inside it's VM (uid=1000(docker) gid=50(staff). This caused files in the TAR archives to have wrong permissions, triggering a packaging test error later on. --- dev-tools/package_test.go | 6 +++--- dev-tools/packer/platforms/binary/run.sh.j2 | 2 +- dev-tools/packer/platforms/darwin/run.sh.j2 | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dev-tools/package_test.go b/dev-tools/package_test.go index bc99374e50d..46cfce4eccd 100644 --- a/dev-tools/package_test.go +++ b/dev-tools/package_test.go @@ -149,7 +149,7 @@ func checkConfigOwner(t *testing.T, p *packageFile) { for _, entry := range p.Contents { if configFilePattern.MatchString(entry.File) { if expectedConfigUID != entry.UID { - t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigGID, entry.UID) + t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigUID, entry.UID) } if expectedConfigGID != entry.GID { t.Errorf("file %v should be owned by group %v, group=%v", entry.File, expectedConfigGID, entry.GID) @@ -182,7 +182,7 @@ func checkManifestOwner(t *testing.T, p *packageFile) { for _, entry := range p.Contents { if manifestFilePattern.MatchString(entry.File) { if expectedConfigUID != entry.UID { - t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigGID, entry.UID) + t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigUID, entry.UID) } if expectedConfigGID != entry.GID { t.Errorf("file %v should be owned by group %v, group=%v", entry.File, expectedConfigGID, entry.GID) @@ -219,7 +219,7 @@ func checkModulesOwner(t *testing.T, p *packageFile) { for _, entry := range p.Contents { if modulesFilePattern.MatchString(entry.File) || modulesDirPattern.MatchString(entry.File) { if expectedConfigUID != entry.UID { - t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigGID, entry.UID) + t.Errorf("file %v should be owned by user %v, owner=%v", entry.File, expectedConfigUID, entry.UID) } if expectedConfigGID != entry.GID { t.Errorf("file %v should be owned by group %v, group=%v", entry.File, expectedConfigGID, entry.GID) diff --git a/dev-tools/packer/platforms/binary/run.sh.j2 b/dev-tools/packer/platforms/binary/run.sh.j2 index 05eaadeecff..52542b43830 100644 --- a/dev-tools/packer/platforms/binary/run.sh.j2 +++ b/dev-tools/packer/platforms/binary/run.sh.j2 @@ -23,7 +23,7 @@ fi cp fields.yml /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/ cp -a modules.d-linux/ /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}}/modules.d || true -tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}} +tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-linux-{{.bin_arch}}.tar.gz --owner=0 --group=0 /{{.beat_name}}-${VERSION}-linux-{{.bin_arch}} echo "Created /upload/{{.beat_name}}{{.beat_pkg_suffix}}--${VERSION}-linux-{{.bin_arch}}.tar.gz" cd /upload diff --git a/dev-tools/packer/platforms/darwin/run.sh.j2 b/dev-tools/packer/platforms/darwin/run.sh.j2 index 18c8f62e5fc..e2d0f36ff3e 100644 --- a/dev-tools/packer/platforms/darwin/run.sh.j2 +++ b/dev-tools/packer/platforms/darwin/run.sh.j2 @@ -20,7 +20,7 @@ fi cp fields.yml /{{.beat_name}}-${VERSION}-darwin-x86_64/ cp -a modules.d-darwin/ /{{.beat_name}}-${VERSION}-darwin-x86_64/modules.d || true -tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz /{{.beat_name}}-${VERSION}-darwin-x86_64 +tar czvf /upload/{{.beat_name}}{{.beat_pkg_suffix}}-${VERSION}-darwin-x86_64.tar.gz --owner=0 --group=0 /{{.beat_name}}-${VERSION}-darwin-x86_64 echo "Created /upload/{{.beat_name}}-${VERSION}-darwin-x86_64.tar.gz" cd /upload