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

Non-zero exit codes not being sent to shell, error messages going to STDOUT #66

Open
rlue opened this issue Jan 12, 2018 · 0 comments
Open

Comments

@rlue
Copy link

rlue commented Jan 12, 2018

I've noticed that, for instance, wemux mirror returns exit code 0 (success) and prints the error message No wemux server to mirror on 'wemux' to STDOUT rather than STDERR. Is there any chance we could see this fixed to conform to UNIX standards?

Solution

After looking at the code, I see that the exit codes are in there already. However, since they're being sent with return rather than exit, they don't actually get sent upon the termination of the program. (According to this SO answer, “return has nothing to do with exit codes.”)

Error messages can be echoed to STDERR with >&2 echo.

@zolrath, would you be open to making these changes in wemux? If so, would you prefer to do it yourself, or would you like me to submit a PR?


Context

What I'm trying to do is use wemux to create a safe sandbox for other users to SSH into my machine for pair programming. I've created a new user solely for this purpose, whose .profile file consists only of the following:

wemux mirror 2>/dev/null || echo "Ryan isn't ready to pair yet!"
exit

If wemux conformed to UNIX standards, this code would work; unfortunately, the failure case (the part after ||) never runs, because wemux mirror always returns exit code 0.

Security implications

N.b. that if you consider doing this, you must separately disable users from directly executing commands on your machine via SSH (i.e., protect against ssh pair@your-machine <command>).

@rlue rlue changed the title Proper exit codes / outputting to STDERR vs STDOUT? Non-zero exit codes not being sent to shell, error messages going to STDOUT Jan 12, 2018
rlue added a commit to rlue/wemux that referenced this issue Jan 12, 2018
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

No branches or pull requests

1 participant