Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --argv0 option #598

Merged
merged 1 commit into from
Oct 1, 2023
Merged

Add --argv0 option #598

merged 1 commit into from
Oct 1, 2023

Conversation

quag
Copy link
Contributor

@quag quag commented Sep 28, 2023

Fixes #91

Add the ability to overwrite argv[0] when starting a process in a container. Using --argv0 to be consistent with ld.so --argv0.

Overwriting argv[0] is useful as some tools change their behavior based on the value of argv[0]. For example, when bash is symlinked to sh it behaves as sh. Similarly, unxz is a symlink to xz and changes the default from compressing to decompressing. An extreme example is on many systems, date, df, cat and so on are all symlinks to the coreutils binary.

Example usage:

bwrap --bind / / --argv0 sh bash

PS: Thank you for the kind advice on my previous pull-request to add a --exec option.

tests/test-run.sh Show resolved Hide resolved
Copy link
Collaborator

@smcv smcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash the bug fix into the commit that it's fixing, so that each commit in the series is individually correct (in this case, the trivial implementation of that, with a single commit). Other than that, assuming the CI passes, this looks good to merge.

Fixes containers#91

Add the ability to overwrite argv[0] when starting a process in a
container. Using --argv0 to be consistent with ld.so --argv0.

Overwriting argv[0] is useful as some tools change their behavior based
on the value of argv[0]. For example, when bash is symlinked to sh it
behaves as sh. Similarly, unxz is a symlink to xz and changes the
default from compressing to decompressing. An extreme example is on many
systems, date, df, cat and so on are all symlinks to the coreutils
binary.

Example usage: bwrap --bind / / --argv0 sh bash

Signed-off-by: Jonathan Wright <quaggy@gmail.com>
@smcv smcv merged commit 71aa850 into containers:main Oct 1, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provide an option to set argv[0]
2 participants