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

Avoid errors when the process does not have enough permissions #120

Closed
wants to merge 7 commits into from

Conversation

hhorak
Copy link
Member

@hhorak hhorak commented Apr 24, 2017

Sometimes there is not enough permissions to change attributes by fix-permissions. It was for example reported in sclorg/mariadb-container#32. This change should make these warnings disappeared.

@pkubatrh
Copy link
Member

I wonder, is there a chance we might mask some future issues when suppressing warnings and errors while running fix-permissions? Nothing comes to my mind right now but in general it seems like a bad idea.

There is also #112 that might get influenced by this change.

How about making fix-permissions take the GID via an argument (would default to 0 so we do not have to change all existing calls) instead? That would get rid of the warnings while additionally making sure the process has the correct access permissions for the files.

@hhorak
Copy link
Member Author

hhorak commented Apr 24, 2017

I wonder, is there a chance we might mask some future issues when suppressing warnings and errors while running fix-permissions? Nothing comes to my mind right now but in general it seems like a bad idea.

I share the general worry, but thinking more about it it looks to me like the only real issue that we might mask is when some directory we pass to the script does not exist. That's why there is a check if ! [ -e "$1" ] ; then.. But I agree that we never can be sure.

How about making fix-permissions take the GID via an argument (would default to 0 so we do not have to change all existing calls) instead? That would get rid of the warnings while additionally making sure the process has the correct access permissions for the files.

I don't think it would make all errors disappeared, because symlinks mentioned in #112 that point to root-owned files (correctly read-only) would still produce warnings/errors IMO.. the reason of not having enough permissions is different there.

@omron93
Copy link
Contributor

omron93 commented Apr 24, 2017

Problem is that the user is not in root group. So it is not possible to chgrp to such group.

@hhorak For example for mongodb-container - adding usermod -a -G root mongodb in Dockerfile solves this issue.

@pkubatrh
Copy link
Member

For example for mongodb-container - adding usermod -a -G root mongodb in Dockerfile solves this issue.

Is this something that we want to have/is expected of containers running in Openshift?

@omron93
Copy link
Contributor

omron93 commented Apr 24, 2017

How about making fix-permissions take the GID via an argument (would default to 0 so we do not have to change all existing calls) instead? That would get rid of the warnings while additionally making sure the process has the correct access permissions for the files.

Copies of fix-permissins scripts in mongodb-container [1] and postgresql-container [2] also change owner to default image user. This is needed for running using "pure" docker where default group isn't root.
On the other hand changing owner makes sense only in Dockerfile running under root. So +1 taking arguments to fix-permissions.

[1] https://github.com/sclorg/mongodb-container/blob/master/3.2/root/usr/libexec/fix-permissions
[2] https://github.com/sclorg/postgresql-container/blob/master/9.5/root/usr/libexec/fix-permissions

I don't think it would make all errors disappeared, because symlinks mentioned in #112 that point to root-owned files (correctly read-only) would still produce warnings/errors IMO.. the reason of not having enough permissions is different there.

We should not change file attributes of similar files. Warning makes sense in this case IMPOV.

@omron93
Copy link
Contributor

omron93 commented Apr 24, 2017

Is this something that we want to have/is expected of containers running in Openshift?

In OpenShift all containers are running under root GID and random UID. That is why all files should be accessible by root group. @bparees Is it right?

@bparees
Copy link
Collaborator

bparees commented Apr 24, 2017

In OpenShift all containers are running under root GID and random UID. That is why all files should be accessible by root group. @bparees Is it right?

sort of. The assemble script actually runs as the default user for the image, and if the default user for the image has specifically assigned groups, then those are the groups they will have, not necessarily the root group.

But if the user is not listed in /etc/groups, then yes they get the root group.

@omron93
Copy link
Contributor

omron93 commented Apr 25, 2017

But if the user is not listed in /etc/groups, then yes they get the root group.

@bparees So when running container in OpenShift with "random" UID gets always root GID, or not? Is it possible that "random" UIG will be already listed in /etc/passwd?

Is it problem to add default user to root group from OpenShift POV ?

@bparees
Copy link
Collaborator

bparees commented Apr 25, 2017

@bparees So when running container in OpenShift with "random" UID gets always root GID, or not? Is it possible that "random" UIG will be already listed in /etc/passwd?

it's theoretically possible the user could be listed (and thus not have root group permissions) but pretty unlikely. the assigned/random uid range starts at like 10000 or something. i've never seen an image that defines user 10000 in their /etc/passwd and /etc/groups files.

Is it problem to add default user to root group from OpenShift POV ?

no i don't think that should be a problem (but again you don't need to add the default user explicitly as long as the default user isn't otherwise already listed. for most of our images we use the default user 1001, which is why this works ok for us).

@omron93
Copy link
Contributor

omron93 commented Apr 25, 2017

no i don't think that should be a problem (but again you don't need to add the default user explicitly as long as the default user isn't otherwise already listed. for most of our images we use the default user 1001, which is why this works ok for us).

In database images default user is different. So without random UID it causes problems.

So solution it to also use 1001 user in database images or to add current default users to root group. @hhorak What to choose?

@hhorak
Copy link
Member Author

hhorak commented Apr 26, 2017

I prefer to add the default users to the root group, since this issue does not seem worth changing the default user. So, it should remove the need to hide errors in case of chgrp calls, but there is still the issue with files owned by root (sclorg/s2i-python-container#178 (comment)) where we see error messages when symlinks point to them, which we still should mitigate somehow.

We will make sure that the script calling the fix-permissions scripts are always part of the root group, so we don't need to solve 'not enough permissions' issue in case of chgrp calls.
@hhorak
Copy link
Member Author

hhorak commented Apr 26, 2017

A fixed solution with suggestions from #112 (comment) is available.

@omron93
Copy link
Contributor

omron93 commented Apr 28, 2017

[test]

@pkubatrh
Copy link
Member

Operation not permitted warnings still present in RHEL7 CI as it seems to be testing s2i-* images built upon the wrong version of s2i-base (the PR version is tagged as centos/s2i-base-rhel7 instead of the expected rhscl/s2i-base-rhel7).
Would like to get this fixed and run through the RHEL CI properly before merging.

@omron93
Copy link
Contributor

omron93 commented May 16, 2017

Operation not permitted warnings still present in RHEL7 CI as it seems to be testing s2i-* images built upon the wrong version of s2i-base (the PR version is tagged as centos/s2i-base-rhel7 instead of the expected rhscl/s2i-base-rhel7).
Would like to get this fixed and run through the RHEL CI properly before merging.

You are right! Build scripts for this image does not support centos/ vs rhscl/ tagging... It used openshift/ namespace for both versions, but after #114 namespace is always centos/ instead of openshift/

I suggest to fix this by using https://github.com/sclorg/container-common-scripts (for example by accepting #121)

Marek Skalický and others added 2 commits May 16, 2017 14:58
@pkubatrh
Copy link
Member

@hhorak Please rebase to be able run tests including #122

We will make sure that the script calling the fix-permissions scripts are always part of the root group, so we don't need to solve 'not enough permissions' issue in case of chgrp calls.
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.

None yet

4 participants