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

Fix permissions conflict in tmp folder and allow running from root on linux. #23

Closed
wants to merge 1 commit into from

Conversation

jameshilliard
Copy link

This splits the tmp folders by UID to avoid getting permission errors when running tests from multiple users on the same system. It also adds a workaround so that tests can be run from a root user.

if (SystemUtils.IS_OS_LINUX) {
Long uid = new com.sun.security.auth.module.UnixSystem().getUid();
if (uid == 0) {
command.addAll(Arrays.asList("unshare", "-Uu"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please refer me to documentation where the following parameters are mentioned and described what they do? Because I can't find them anywhere in the official documentation, see the attached links.

https://www.postgresql.org/docs/10/app-initdb.html
https://www.postgresql.org/docs/10/app-pg-ctl.html
https://www.postgresql.org/docs/10/app-postgres.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at this again unshare -U may be all that's needed, going to test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that worked, updated PR with changes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response. Now I get it. This is not a postgres parameter but a linux command. In that case I am a bit afraid that some linux distributions may not include this command out of the box. Also, when I tested your branch the unshare command was on some docker containers failing with unshare: unshare failed: Operation not permitted error.

So my concerns have increased and I would like to address this problem in some other way. For example, changing the default permissions to make binaries accessible and executable by all users. So, could you please review and test the following pull request #28? Would this solution be sufficient for you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since unshare is only used in cases where postgresql is guaranteed to otherwise error it won't cause regressions or make the situation any worse.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what about the unshare: unshare failed: Operation not permitted error? Isn't that worse? :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worse than poestgresql just throwing an error? I mean they are both fatal errors so not really sure how one is worse than the other.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be reworked a bit to add capability checks(to check that there are appropriate permissions and that unshare exists) before actually running unshare I suppose, the main reason I didn't bother was just because this was already a fully fatal error as postgres uses essentially the exact same uid check as I'm doing here. I should note that from my understanding unshare is somewhat similar in regards to how docker namespace isolation works and may not necessarily place nice with it in all cases.

@tomix26
Copy link
Collaborator

tomix26 commented May 22, 2020

Closed in favor of #28

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