-
-
Notifications
You must be signed in to change notification settings - Fork 116
Fix permissions error #298 and improve permissions in general #299
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
Conversation
d46278e to
dccfba2
Compare
|
Thanks for the PR. Wouldn't that remove the executable bit from /app/gokapi? |
|
From: git checkout fix-298-permissions-error
docker build -t foo .
docker run --rm --name foo -d foo
docker exec -it foo /bin/ls -la /appI see So |
dockerentry.sh
Outdated
|
|
||
| echo "Setting permissions" | ||
| # chmod 750 for directories, 640 for files; does not remove existing u+x or g+x file permissions | ||
| find -P /app -type d -exec chmod 750 -- {} + -o \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In combination with UMASK PR, the result looks like this:
- given
UMASK=0077, Gokapi creates files in /app/data with0600permission in runtime - with the container restart, the permission on existing files forcefully changes to 0640. What is the point of UMASK than?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a different PR from the linked PR, UMASK does not exist for this PR. If the others is merged first it may need to be modified but since it's not it does not. The current behavior is chmod -R 700 /app, which has the negative effect of +xing files into executables.
After the linked PR is merged, this can be changed if there is desire. To be honest I'm not sure why there is a chmod here in the first place as chown is more relevant in changing ownership during DOCKER_NONROOT. Ideally we can remove this line entirely and just assume previous permissions are correct. But @Forceu will have to weigh in on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a different PR from the linked PR, UMASK does not exist for this PR.
Sorry, just taking an overall picture. And agree that chmod -R 700 /app is irrelevant.
To be honest I'm not sure why there is a
chmodhere
Agree with that. Excluding some edge cases changing permission and ownership is not a container entrypoint job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Forceu I left the chmod in before to avoid breaking in case there was something I was unaware of, but unless there is a reason, can I remove it?
|
Overall opinion. This MR introduces unnecessary complexity that also brings some issues.
Meanwhile the problem it targets can be solved by most standard docker practice without any changes to entrypoint chown -R <UID>:<GID> config data \
&& docker container run -u <UID>:<GID> \
-v "$(pwd)/config:/app/config" -v "$(pwd)/data:/app/data"
...Permissions are not supposed to be manipulated in this manner, it's either umask setting suggested in #297, or no control at all |
Good catch, I'll fix that.
If it is owned by
No, it would work if the directory was already owned by that UID/GID.
This does the exact same thing the current |
In the current image $ docker container run -ti -u 69 f0rc3/gokapi sh
/app $ id
uid=69 gid=0(root) groups=0(root)
/app $ ls -dl /app/
drwxr-xr-x 1 root root 4096 Aug 29 12:49 /app/
/app $ chown -R $(id -u):$(id -g) /app
chown: /app/.isdocker: Operation not permitted
chown: /app/gokapi: Operation not permitted
chown: /app/run.sh: Operation not permitted
chown: /app: Operation not permitted
chown: /app: Operation not permittedBut again... But what I can say for sure, there are no issues outside of Just no need to fix what is not broken |
|
I see the current behavior as broken. The behavior you are describing is a no-op and log spam in the bad case, and rectifying ownership if it works, i.e. if root or if As for permissions, I agree- it'd be better to remove that line but since I don't know why they were set in the master branch I'm leaving it in unless the author says it is fine to do away with them. If we end up documenting that the correct way to run the binary as non-root is
|
|
If you make a PR, and test it, removing the |
|
Thank you for your feedback, both sides are very valuable! Personally I do not have extensive experience with Docker, especially as I am mostly using non-root Podman instances. I would be more than happy to accept changes to the current way the Docker image is run and to the documentation. Also sorry for closing the PR, that was a misclick. |
|
I think we both agree, uness there is some need to have root for setup when you start the container, the best way would be:
The current setup determines root based on an env variable. If you need root initially or something, this works perfectly as you can do: # do_root_stuff
# su-exec gokapi actual_commandIn that case, the use of A caveat here is that when using |
|
@spaghetti-coder If I missed anything above please let us know |
|
So it would be enough to simply run |
Works for me.
Will shape a ticket shortly and will try to implement.
With major version yes, but for now we need to keep backward compatibility. |
|
@Forceu @spaghetti-coder This is partially tangential, partially not due to the existing PR, but one thing that would be nice to have here is if [ -n "$UMASK" ]; then umask "$UMASK"; fi
exec /app/gokapi "$@" And maybe, optionally:
|
|
@spaghetti-coder If you do make a PR, if you wouldn't mind commenting "Conflicts with " on the other two PRs. I'll leave them open until yours is merged in case it ends up not being so, so the comment would be appreciated. Also ideally link the related issues the PRs address |
|
Conflicts with #327 |
This PR cleans up permission in
dockerentry.shin 3 ways:dockerentry.shchmod +x's all files inconfig. #298 bychmod-ing directories to 750, then effectivelychmod-ing files to 640, but without removing any existing executable (x) permissions. I.e. executables will remain executables (to user and group)DOCKER_NONROOTis set. This is both for consistency but also ensures consistency should a user tryDOCKER_NONROOTthen revertchownwhenDOCKER_NONROOTis not set; this is in case a user switches from usingDOCKER_NONROOTthen back.