uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

How to restrict permissions for Unix socket?

Open Densaugeo opened this issue 2 months ago • 0 comments

Initial Checks

  • [x] I confirm this was discussed, and the maintainers suggest I open an issue.
  • [x] I'm aware that if I created this issue without a discussion, it may be closed without a response.

Discussion Link

I asked about this on the Discord, but didn't receive a reply after several days. Sorry if this isn't the right place.

Description

When the --uds option is used Uvicorn creates a socket with 766 permissions, accessible to any user on the server, and this does not appear to be configurable. What is the recommended way to restrict a socket to 760 or similar?

I could separately chmod the socket after it is created, but this leads to tricky questions about error detection and handling if the chmod doesn't happen for some reason.

Example Code


Python, Uvicorn & OS Version

Fedora 41
Python 3.12.11
Uvicorn 0.37.0

Densaugeo avatar Oct 16 '25 23:10 Densaugeo