Allow setting permission bits of created socket
See original GitHub issueFeature Description
Following up on #686, it should be possible to set permissions for the created socket file.
As it stands, socket files created by thelounge
are given default permissions:
cameron@myserver:~$ ls -l /run/thelounge/sock
srwxr-xr-x 1 thelounge thelounge 0 Dec 22 14:24 /run/thelounge/sock
This means that even if a webserver is in the thelounge
group, it cannot write to the created socket, negating the usefulness of a socket file.
Please add the ability to control permission bits to socket on startup.
I have a tiny npm module that is designed to help with this. It allows configs to specify host or socket and option ports or permission bits. It also removes any existing socket file if the socket is dead. https://www.npmjs.com/package/server-starter Unfortunately this would be a breaking change to the current config.js
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Allow one to specify file permissions for unix sockets #4675
ℹ️ A user only needs rw (read/write) access to a socket to be able to use it. x (execute) is not required. However,...
Read more >how can I change the permissions of a linux socket file?
Their owner, group and their permissions can be changed. Creation of a new socket will fail if the process does not have write...
Read more >What does x (execute) permission do on unix sockets?
The Linux man page unix(7) says that the permissions of the directory containing a socket apply normally (i.e. you need +x on /foo...
Read more >Setting Permissions (The GNU C Library)
To change the permission of an existing file given its name, call chmod . This function uses the specified permission bits and ignores...
Read more >Linux File Permissions, chmod, & umask | Tutonics
Understand how Ubuntu / Linux file permissions and special mode bits work. ... When the setgid bit is set for a directory, any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There are two issues that relate to getting permissions set correctly.
The first is the owner/group of the file. That, as I understand it, uses the user’s default group unless the “sticky bit” is set on the folder which changes which group is set on file creation.
I’m using systemd’s
RuntimeDirectory=thelounge
option (which creates/run/thelounge
on startup, owned bythelounge
user, and cleaned on shutdown). I could add anExecStartPre=
script that sets the sticky bit, but that’s getting excessively confusing compared to other options, imho.The second problem is setting the file permission bits. My system
umask
defaults to0002
which should make created files haverw
permissions for user & group. In practice, I need to addw
permissions for group. (Not sure why there is a discrepancy there). I’d also like to remove any permissions for any other user/group.I’m currently getting around these issues by adding
nginx
to thethelounge
group and adding this to my systemd service configuration:In any case, controlling the permissions of a created socket is, imho, an expected feature of creating a socket for other programs to interact with. As long as we’re not changing the user/group of the created file,
root
is not necessary.For those looking for a way to do this manually, here is my systemd service file that waits for the socket to be created and
chmod
’s it: