You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently installed supervisor in Termux on Android and Python there does not support os.link, but does support rename. After this change, I could use supervisor in Termux via pip.
$ touch foo
$ touch bar
$ python -c "import os; os.link('foo', 'bar')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
OSError: [Errno 17] File exists
$
os.rename()
$ touch foo
$ touch bar
$ python -c "import os; os.rename('foo', 'bar')"
$ ls
bar
os.link() guarantees the destination filename does not exist. os.rename() overwrites it. Changing from os.link() to os.rename() would no longer have the guarantee that the socket file does not exist. A check like os.path.exists() would need to be added before it, and then the code would no longer be atomic. A race condition would then be possible, which likely has security implications.
I'd rather not change anything here. Supporting systems without hard links is not a goal of this project, sorry. supervisorctl can communicate with supervisord over both a UNIX domain socket (what this code is for) or over a TCP socket. Perhaps a TCP socket bound to localhost could be used instead.
Activity
mnaberez commentedon Mar 3, 2018
Some context would be useful, such as the file/line you're asking about.
SaavdhaanCyber commentedon Mar 3, 2018
https://github.com/Supervisor/supervisor/blob/70720a0311d868fbf58a31cd26a7147921dcff29/supervisor/http.py
Line no. 578
FAKERINHEART commentedon Mar 3, 2018
@lkdevil @mnaberez The system hard link of socket codes in supervisord, which are referenced by @lkdevil, are the reason that partially result in the failure of the overylay fs system (docker uses) using supervisord. moby/moby#12080
and
https://github.com/analytically/docker-overlayfs-bug
rqcy commentedon Jul 24, 2018
Yes, please merge the PR #1069 !
os.rename is cleaner, shorter and easier to understand in code than os.link/os.unlink, unless there's some good reason to use the later one. For reference: https://stackoverflow.com/questions/18653112/which-is-costlier-rename-or-link-and-unlink-in-c
I've recently installed supervisor in Termux on Android and Python there does not support os.link, but does support rename. After this change, I could use supervisor in Termux via pip.
Thanks for your work!
mnaberez commentedon Dec 11, 2021
os.link()os.rename()os.link()guarantees the destination filename does not exist.os.rename()overwrites it. Changing fromos.link()toos.rename()would no longer have the guarantee that the socket file does not exist. A check likeos.path.exists()would need to be added before it, and then the code would no longer be atomic. A race condition would then be possible, which likely has security implications.I'd rather not change anything here. Supporting systems without hard links is not a goal of this project, sorry.
supervisorctlcan communicate withsupervisordover both a UNIX domain socket (what this code is for) or over a TCP socket. Perhaps a TCP socket bound to localhost could be used instead.