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

Inherit supplementary groups if no group has been specified #341

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Inherit supplementary groups if no group has been specified #341

wants to merge 3 commits into from

Conversation

socram8888
Copy link

This PR changes the behaviour of permission dropping, by inheriting user's supplementary group if no group has been explicitely specified in the configuration file.

The reason behind this PR is that I need to connect from sniproxy to a stunnel4 UNIX socket. Said sockets are created in Debian with permission 775 and user stunnel4, which means only users in the stunnel4 user and group can connect to said tunnels.

I thought about adding the sniproxy user to stunnel4 group so it could access the pipe, but it didn't work, and I spent quite some time figuring out why it was getting a connection refused even though the groups were properly set.

This PR thus allows using more than one group in the sniproxy user, which is more natural and behaves as in sudo or start-stop-daemon where the supplementary groups are also setup.

@dlundquist
Copy link
Owner

Looks good. Is it worth using calloc() for group list allocation should the group list change during the operation? Mind adding updating the config man page?

@socram8888
Copy link
Author

socram8888 commented Oct 24, 2019

I've already updated the manual file with information regarding the groupname. English is not my first language so I am not sure how naturally written it is.

Regarding the race condition, I've handled that in dca7ed9 where I use the returned number of entries from the second call instead of those from the first. This means that if the user's group gets smaller the remaining entries in the gid array are ignored. If the group list gets larger, it will fail and get a fatal error.

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

Successfully merging this pull request may close these issues.

2 participants