Skip to content

Add --argv0 option - #598

Merged
smcv merged 1 commit into
containers:mainfrom
quag:argv0
Oct 1, 2023
Merged

smcv merged 1 commit into
containers:mainfrom
quag:argv0

Conversation

@quag

@quag quag commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

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.

Comment thread tests/test-run.sh Resolved

@smcv smcv left a comment

Copy link
Copy Markdown
Collaborator

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 <[email protected]>
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