Skip to content
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

Permissions on the socket file #5

Open
precisionpete opened this issue Jul 14, 2021 · 6 comments
Open

Permissions on the socket file #5

precisionpete opened this issue Jul 14, 2021 · 6 comments

Comments

@precisionpete
Copy link

I am trying to use this library to implement communications between a client running as a user and an elevated server running as root. e.g. I need to manipulate the network stack from a user app.

Everything works fine if both run as a user. But if the server runs as root, the socket file gets root permission and the client panics with a permission error.

Is there an undocumented way to have the socket created with write permission? For the moment, this is on Linux. But I am also hoping to use this on Windows and MacOS as well.

@james-barrow
Copy link
Owner

There's nothing in the library at the moment to specifically support this. I don't have the time to spend looking into this at the moment but have a look at:

https://stackoverflow.com/questions/35424970/unix-socket-permissions-linux

This is what I would start with to try and get it working.

@nickycakes
Copy link
Contributor

the safe way to do this is to call umask(0) before creating the socket, and then re-setting the umask immediately after. trying to chmod the permissions after creation is a race condition. works on linux, not sure about mac or other unix

@d1ss0nanz
Copy link

The Windows equivalent would be:
listener, err := winio.ListenPipe(path, &winio.PipeConfig{SecurityDescriptor: "D:P(A;;GA;;;AU)"})

@d1ss0nanz
Copy link

I can confirm that setting the Umask also works on darwin.

@james-barrow
Copy link
Owner

Thanks for your help everyone. I've merged the change for linux and Mac, when I get a chance to fire up a window machine I will test the change as well then add it.

@james-barrow
Copy link
Owner

I've added the change mentioned for Windows ( &winio.PipeConfig{SecurityDescriptor: "D:P(A;;GA;;;AU)"}) if unmask is set as true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants