-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
SubprocessTransport .close() can fail with PermissionError with setuid programs #112800
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
Labels
Comments
allisonkarlitskaya
added a commit
to allisonkarlitskaya/cpython
that referenced
this issue
Dec 6, 2023
In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
This was referenced Dec 6, 2023
allisonkarlitskaya
added a commit
to allisonkarlitskaya/cpython
that referenced
this issue
Dec 6, 2023
In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
allisonkarlitskaya
added a commit
to allisonkarlitskaya/cpython
that referenced
this issue
Dec 6, 2023
In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
allisonkarlitskaya
added a commit
to allisonkarlitskaya/ferny
that referenced
this issue
Dec 6, 2023
allisonkarlitskaya
added a commit
to allisonkarlitskaya/ferny
that referenced
this issue
Dec 6, 2023
gvanrossum
pushed a commit
that referenced
this issue
Dec 24, 2023
…syncio (#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
ryan-duve
pushed a commit
to ryan-duve/cpython
that referenced
this issue
Dec 26, 2023
…) in asyncio (python#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
kulikjak
pushed a commit
to kulikjak/cpython
that referenced
this issue
Jan 22, 2024
…) in asyncio (python#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
…) in asyncio (python#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
…) in asyncio (python#112803) In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Bug description:
aka
python3-3.12.0-1.fc39.x86_64
.Run this code on your Linux system with pkexec setup. That should work on any normalish GNOME system, I'd guess. I'm using Fedora 39.
You should get a popup to enter your admin password. Do that within 10 seconds. Then
cat
(which now has the same PID as we spawnedpkexec
with) will be running as root.transport.close()
attempts tokill()
that PID, which fails:Probably the call to
self._proc.kill()
in.close()
should be guarded to ignorePermissionError
. It already ignoresProcessLookupError
:There are many other setuid utilities that this doesn't seem to be a problem with. The shadow-utils tools like
passwd
seem to remain killable, as doessudo
(which keeps a process running around and forks off to spawn the desired command as root). In fact,pkexec
was the only tool I could find that causes this issue, but as viewed from the Python side, we clearly cannot necessarily rely on being able to.kill()
a PID that we created.Thanks!
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: