tsl0922 / ttyd

Share your terminal over the web
https://tsl0922.github.io/ttyd
MIT License
8.02k stars 881 forks source link

Set group ownership of unix socket #508

Open bryfry opened 3 years ago

bryfry commented 3 years ago

Is your feature request related to a problem? Please describe. I have a command that I want to run as root wrapped up by ttyd but I'd like nginx user (www-data) to be able to access the unix socket created by ttyd.

Describe the solution you'd like This would be made possible by allowing the permissions (owner:group) for the newly created ttyd socket file.

Describe alternatives you've considered I've worked around this issue by modifying the permissions of the socket after it comes online.

Additional context I'm a huge fan of the unix socket interface. This was only a minor inconvenience in an otherwise awesome experience getting ttyd setup to accomplish my project needs.

tsl0922 commented 3 years ago

The underlying websocket feature (and unix socket) is based on libwebsockets, so if libwebsocket support it (didn't check yet), I'm OK to add it to ttyd.

cRoCx commented 9 months ago

I had the same or similar issue and solved it by having ttyd executed as user exampleuser and group www-data through a systemd service. An example of this service can be found in the wiki here. Instead of Group=root you could use Group=www-data. When ttyd is called with -i /tmp/ttyd.sock the socket file with have rw permissions for user exampleuser and group www-data.

xfl12345 commented 3 months ago

A solution is building docker image by yourself.
Like this https://github.com/xfl12345/docker-setup/tree/1e994e5d8bb17c1117061864e01dc7cf3b4b1bab/compose/standalone/ttyd