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

Added boolean return value to lowerPrivileges #355

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

Conversation

Tusanga
Copy link
Contributor

@Tusanga Tusanga commented Apr 18, 2023

No description provided.

@Tusanga
Copy link
Contributor Author

Tusanga commented Apr 18, 2023

Is this a timeout for (macOS-latest, dmd-latest, x86_64) or is there an error in new code?

@s-ludwig
Copy link
Member

Not sure what happened there, it doesn't look like a timeout. But it also can't really be related to the changes here, so let's ignore it...

@s-ludwig
Copy link
Member

What is the use case you have in mind for the return value? I'm asking because it seems not really clear whether the return value for the uname == "" && gname == "" case should be true or false. Depending on the situation, this could be something that is not wanted, or something that works as requested.

When looking at the code as is stands, it seems like it might be a better idea to forbid that case altogether (e.g. throw an exception) and move the warning message to the lowerPrivileges overload that takes no arguments. There just doesn't seem to be a point in explicitly passing empty arguments, fully expecting nothing to happen.

@Tusanga
Copy link
Contributor Author

Tusanga commented Apr 18, 2023

Background: I have experienced accidentally started a service as the wrong not-root user only to find out later (not at startup but during later request processing) that I can't open specific files. I would like to be able to prevent that with a false return value immediately after the call to lowerPrivileges. With a check one can detect if the process runs as a non-root. If uname == "" && gname == "" I expect true as I do not want act on that. Always starting the service as root allows me during debugging to bind to ports below and above 1024 without having to change any code.

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