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

No Passenger Issue (was: Invoke setgroup() with empty groups as fallback in switchGroup() in ExecHelperMain.cpp) #2096

Closed
kbabioch opened this issue Jun 20, 2018 · 3 comments

Comments

@kbabioch
Copy link

In the switchGroup() function there should be a fallback for the setgroup() invocation in case of failures, so that if anything goes wrong the user is not a member of any supplementary group(s) rather than being a member of some group(s).

These checks, for instance, could return an unexpected value:

int ret = getgrouplist(userInfo->pw_name, gid,

if (ngroups <= NGROUPS_MAX) {

In these cases setgroups() is not invoked at all. The default, however, should be that it is invoked with an empty list of groups. Since you already keep track of whether setgroups has been invoked with the setgroupsCalled flag, it should be easy to check for this in the end of the function.

@FooBarWidget
Copy link
Member

Thanks for reporting this issue, but I don't really get it. You're saying that if ngroups > NGROUPS_MAX, then setgroups() is not called at all. That's true. However, if setgroups() is not called then the if (!setgroupsCalled && initgroups(userInfo->pw_name, gid) == -1) ensures that in any case initgroups() is called. Doesn't that already ensure that the right supplementary groups are set?

Actually, now I look at the code, the getgrouplist()/setgroups() parts seem to be relics from an earlier version of the codebase, before a large refactoring happened. I think just calling initgroups() here is already sufficient.

@FooBarWidget
Copy link
Member

Closing this for now until the case is confirmed.

@kbabioch
Copy link
Author

@FooBarWidget You are right with your analysis. I've misjudged the situation and overlooked the setgroupsCalled logic. This issue can therefore be closed as invalid. Sorry for the noise.

@CamJN CamJN changed the title Invoke setgroup() with empty groups as fallback in switchGroup() in ExecHelperMain.cpp No Passenger Issue (was: Invoke setgroup() with empty groups as fallback in switchGroup() in ExecHelperMain.cpp) Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants