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

podman run: exit status 126/127 seem to be reversed in sense #367

Closed
edsantiago opened this issue Feb 20, 2018 · 7 comments
Closed

podman run: exit status 126/127 seem to be reversed in sense #367

edsantiago opened this issue Feb 20, 2018 · 7 comments
Assignees
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@edsantiago
Copy link
Member

podman-run(1) asserts that it will exit with 126 if command cannot be invoked (e.g. permission denied), and 127 if the command cannot be found. I believe the test sense in cmd/podman/run.go:83-86 is reversed:

# podman run --rm registry.access.redhat.com/rhel7/rhel:latest /etc;echo $?
container create failed: container_linux.go:348: starting container process caused "exec: \"/etc\": permission denied"
: internal libpod error
127

# podman run --rm registry.access.redhat.com/rhel7/rhel:latest nonexistent-command;echo $?
container create failed: container_linux.go:348: starting container process caused "exec: \"nonexistent-command\": executable file not found in $PATH"
: internal libpod error
126
@mheon
Copy link
Member

mheon commented Feb 20, 2018

This sounds like https://github.com/projectatomic/libpod/blob/5529143877778ef8bcdd05179e279bb7d662b431/cmd/podman/run.go#L81-L87

Either the error codes are switched in the code or in the manpages. We should fix whichever breaks with Docker convention.

@edsantiago
Copy link
Member Author

My bad: I meant to include this: docker is the opposite. That is: I believe the podman documentation should remain as-is, and the code itself should be adjusted.

As long as I'm blabbing, though: I'm not sure if grepping for "permission denied" is the best way to implement this. There may be other reasons why a command cannot be invoked. I can't think of any offhand, though, and don't have a better suggestion atm.

@mheon
Copy link
Member

mheon commented Feb 20, 2018

I tend to agree that manually manipulating the error seems like a bad idea. It might be a good idea to expose more explicit error codes of of libpod so we have a better idea of what's going on

@mheon
Copy link
Member

mheon commented Feb 20, 2018

I'm also far from certain ctr.Init() erroring means the command did not exist, given that Init failure could also be issues with storage and mounts.

@baude baude self-assigned this Feb 20, 2018
@rhatdan
Copy link
Member

rhatdan commented Feb 21, 2018

The convention that is followed in the chroot command.

info chroot
...
     125 if ‘chroot’ itself fails
     126 if COMMAND is found but cannot be invoked
     127 if COMMAND cannot be found
     the exit status of COMMAND otherwise

@rhatdan
Copy link
Member

rhatdan commented Feb 21, 2018

Permission denied should be 126

SO they are reversed.

baude added a commit to baude/podman that referenced this issue Feb 21, 2018
The exit codes for 126 and 127 were reversed.  For the record, the exit
codes used are as follows:

* 125 if ‘chroot’ itself fails
* 126 if COMMAND is found but cannot be invoked
* 127 if COMMAND cannot be found

This resolves issue containers#367

Signed-off-by: baude <[email protected]>
rh-atomic-bot pushed a commit that referenced this issue Feb 21, 2018
The exit codes for 126 and 127 were reversed.  For the record, the exit
codes used are as follows:

* 125 if ‘chroot’ itself fails
* 126 if COMMAND is found but cannot be invoked
* 127 if COMMAND cannot be found

This resolves issue #367

Signed-off-by: baude <[email protected]>

Closes: #378
Approved by: baude
@baude
Copy link
Member

baude commented Feb 21, 2018

Fixed!

@baude baude closed this as completed Feb 21, 2018
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants