-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
ProcessMonitor is too restrictive with execute bit check #2714
Comments
If we remove the check, and let the OS check the executable bit, what kind of error will we see in case of those OS checks failing? |
Unfortunately we get no error. Right now the parent process does not call anything upon the child's exit, so we don't get the -1 exit code that the code currently returns from the child after forking but failing to exec. It seems like the ProcessNotifier interface is not working as intended. It might be worth checking that the file exists but I'm not sure if there is an exotic case where we can't stat a file but can exec it. I'm looking at what other runtimes do here and it doesn't always seem to be consistent. At the very least, our notifier should have a method of detecting that the child process has exited and what the code is. |
python for example uses a pipe to signal an error in the child process: https://github.com/python/cpython/blob/e756f66c83786ee82f5f7d45931ae50a6931dd7f/Lib/subprocess.py#L1389 The model here could be to write the return code of execve to the pipe, which only happens on error. On success there is nothing to read. The current check is incomplete and, looking at the manpage of execve, there are a lot more error conditions even with the executable bit for the current user being set correctly. e.g. the file being on a file system mounted with the |
@mfelsche I agree here. It seems like this is a good path forward. To break this up into a couple steps, I think changing the local code to check that the file exists is a good sanity check for now. In order to keep compatibility, I can leave the current error code in place since it's unused otherwise. Moving forward from there, we can use the additional pipe. I can look a bit closer at what we already have but it shouldn't be hard to add the pipe. The other trick will be to fix some of the otherwise impossible notifications. I'd really like to get an exit notification with a code working properly. This might be a bigger and more complex patch so I'm in favor of doing it separately. |
This is part one of addressing issue ponylang#2714. We avoid breaking compatibility with the API in this change. We should rely on the system to do these checks properly. Since we don't currently have a clean way to signal failure of execv, we'll assert that the path is a proper file first.
This is part one of addressing issue ponylang#2714. We avoid breaking compatibility with the API in this change. We should rely on the system to do these checks properly. Since we don't currently have a clean way to signal failure of execv, we'll assert that the path is a proper file first.
This is part one of addressing issue #2714. We avoid breaking compatibility with the API in this change. We should rely on the system to do these checks properly. Since we don't currently have a clean way to signal failure of execv, we'll assert that the path is a proper file first.
@strmpnk does #2717 close this? |
I feel like the PR does close this issue, but we should open another ticket for the piped exit code improvement. Do you agree, @strmpnk? |
I was going to keep this issue for addressing the follow up but I'm happy to close this and create an follow up issue which references this. |
This is part one of addressing issue ponylang#2714. We avoid breaking compatibility with the API in this change. We should rely on the system to do these checks properly. Since we don't currently have a clean way to signal failure of execv, we'll assert that the path is a proper file first.
Currently we have ProcessMonitor checking that execute is set for all users (not just the user or group):
https://github.com/ponylang/ponyc/blob/0.22.1/packages/process/process_monitor.pony#L245
As pointed out in IRC, this could cause problems on systems with more advanced ACLs and also cause unneeded restriction when a user has proper ownership for execution via the other two execute bits (commonly the only ones set via the default session umask).
The original change for this code was there to require authority in order to execute something. This seems to work fine but I'm not sure why we also check these bits since the host system will be doing these checks as well (and more accurately).
I'd suggest we either remove the check or otherwise return a more specific error type since it's not the execve call itself that is failing and add documentation for this specific restriction.
The text was updated successfully, but these errors were encountered: