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

unix domain sockets are created with the wrong owner #64

Closed
redneb opened this issue Nov 27, 2016 · 5 comments
Closed

unix domain sockets are created with the wrong owner #64

redneb opened this issue Nov 27, 2016 · 5 comments

Comments

@redneb
Copy link

redneb commented Nov 27, 2016

Suppose that you are running gocryptfs as root with the -allow_other option. Then if a non-root user creates a (regular) file in the gocryptfs, it will be owned by that user. But that doesn't seem to happen with unix domain sockets, they are instead always owned by root.

Here's how to reproduce this (with the help of socat):
As root, run the following:

mkdir /tmp/gocryptfs-sock-test{,.enc}
gocryptfs -init -extpass="echo test" /tmp/gocryptfs-sock-test.enc
gocryptfs -allow_other -extpass="echo test" /tmp/gocryptfs-sock-test{.enc,}
chmod 0777 /tmp/gocryptfs-sock-test

Then as a non-root user run this:

socat unix-listen:/tmp/gocryptfs-sock-test/test.sock -

You can check now that the socket /tmp/gocryptfs-sock-test/test.sock will be owned by root.

encfs with the --public option, doesn't seem to have that problem:

# as root:
mkdir /tmp/encfs-sock-test{,.enc}
encfs --public --standard --extpass="echo test" /tmp/encfs-sock-test{.enc,}
chmod 0777 /tmp/encfs-sock-test

# as non-root:
socat unix-listen:/tmp/encfs-sock-test/test.sock -
# /tmp/encfs-sock-test/test.sock is owned by the non root user
@rfjakob
Copy link
Owner

rfjakob commented Nov 27, 2016 via email

@redneb
Copy link
Author

redneb commented Nov 27, 2016

I was just doing some more testing and it appears that this issue does not only affect unix domain sockets, it also affects all other special file types: character devices, block devices, pipes, and even symlinks.

@rfjakob
Copy link
Owner

rfjakob commented Nov 28, 2016

Should be fixed via e3c5e3f and 55df8ac , just pushed to master!

Edit: Owner preservation was only implemented for files and directories till now, that was of course an oversight.

@redneb
Copy link
Author

redneb commented Nov 29, 2016

It now works like a charm. Thanks for the quick fix.

@rfjakob
Copy link
Owner

rfjakob commented Nov 29, 2016

Thanks for testing! Closing the ticket.

@rfjakob rfjakob closed this as completed Nov 29, 2016
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

2 participants