Skip to content

Commit 8a03443

Browse files
Merge pull request #157 from Luap99/argv0
emulators should preserve argv0
2 parents 5245555 + 0f2c900 commit 8a03443

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

podman-image/build_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ dnf -y clean all
118118

119119
systemctl enable rhsmcertd.service
120120
# Patching qemu backed binfmt configurations to use the actual executable's permissions and not the interpreter's
121-
for x in /usr/lib/binfmt.d/*.conf; do sed 's/\(:[^C:]*\)$/\1C/' "$x" | tee /etc/binfmt.d/"$(basename "$x")"; done
121+
for x in /usr/lib/binfmt.d/*.conf; do sed 's/\(:[^C:]*\)$/\1PC/' "$x" | tee /etc/binfmt.d/"$(basename "$x")"; done

podman-image/rosetta-activation.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
mount -t virtiofs -o context=system_u:object_r:nfs_t:s0 rosetta /mnt || exit 0
66

77
# register rosetta handler
8-
echo ":rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/mnt/rosetta:FC" >/proc/sys/fs/binfmt_misc/register
8+
echo ":rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/mnt/rosetta:FPC" >/proc/sys/fs/binfmt_misc/register
99

1010
# unregister qemu handler
1111
echo -1 >/proc/sys/fs/binfmt_misc/qemu-x86_64

verify/basic_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ var _ = Describe("run basic podman commands", func() {
110110
Expect(err).ToNot(HaveOccurred())
111111
Expect(archSession).To(Exit(0))
112112
Expect(archSession.outputToString()).To(Equal(expectedArch))
113+
114+
// check that argv[0] is preserved
115+
argvTestCommand := []string{"run", "--quiet", "--platform", "linux/" + goArch, imgName, "sh", "-c", "echo $0"}
116+
argvSession, err := mb.setCmd(argvTestCommand).run()
117+
Expect(err).ToNot(HaveOccurred())
118+
Expect(argvSession).To(Exit(0))
119+
// Equal is important as we need an exact match for "sh" which means the emulator preserved argv[0].
120+
// Previously it would show the executable path "/bin/sh".
121+
Expect(argvSession.outputToString()).To(Equal("sh"))
113122
}
114123

115124
// Stop machine

0 commit comments

Comments
 (0)