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

precreate nginx log files, fix permissions #97

Closed
wants to merge 1 commit into from
Closed

precreate nginx log files, fix permissions #97

wants to merge 1 commit into from

Conversation

aptalca
Copy link
Member

@aptalca aptalca commented Nov 6, 2023

We need to precreate the nginx log files and fix their permissions on first run. Otherwise nginx creates them as root owned.

fixes linuxserver/docker-baseimage-alpine-nginx#149

@aptalca aptalca requested a review from a team November 6, 2023 16:23
@LinuxServer-CI
Copy link
Contributor

I am a bot, here are the test results for this PR:
https://ci-tests.linuxserver.io/lspipepr/nginx/1.24.0-r7-pkg-4e37044e-dev-5efb8ec06677b433bacc995bc71ac53015d7a684-pr-97/index.html
https://ci-tests.linuxserver.io/lspipepr/nginx/1.24.0-r7-pkg-4e37044e-dev-5efb8ec06677b433bacc995bc71ac53015d7a684-pr-97/shellcheck-result.xml

Tag Passed
amd64-1.24.0-r7-pkg-4e37044e-dev-5efb8ec06677b433bacc995bc71ac53015d7a684-pr-97
arm64v8-1.24.0-r7-pkg-4e37044e-dev-5efb8ec06677b433bacc995bc71ac53015d7a684-pr-97

@nemchik
Copy link
Member

nemchik commented Nov 17, 2023

I think we want this in the nginx base, not here.

@aptalca
Copy link
Member Author

aptalca commented Nov 17, 2023

Sure, the precreation can move to the base, but we would still need the chown as the base no longer does that

@nemchik
Copy link
Member

nemchik commented Nov 17, 2023

Sure, the precreation can move to the base, but we would still need the chown as the base no longer does that

if we're precreating using s6-setuidgid as abc i thought we didn't need the chown?

@aptalca
Copy link
Member Author

aptalca commented Nov 17, 2023

We need it for other files in general. The base used to do a recursive chown so the nginx image never had to. But the recursive chown was removed from the base a few months ago so now we need it here.

The precreation requirement is separate because without it the log files are created after init completes and chown runs so they remain root owned until the next container start

@aptalca
Copy link
Member Author

aptalca commented Nov 17, 2023

In other words, this PR attempts to fix two separate issues, but one of those fixes (precreation) can be moved to the base. The other will stay here.

Comment on lines +11 to +12
lsiown -R abc:abc \
/config
Copy link
Member

Choose a reason for hiding this comment

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

I am still hesitant on the recursive chown on /config being here. I know we used to do it in the nginx base, but what would be the reason we need it here (outside of restoring the previous behavior)? I could maybe see doing a recursive chown on /config/www but that still makes me think permissions should maybe be up to the user. The other folders created in /config include keys, log (which sparked this), nginx, and php all of which maybe would be better to be handled by doing chowns in the nginx base. The www folder is either user-land or populated by the downstream images, and I can agree if there does need to be a recursive chown it can be added to downstream images, but I'm not positive if it's 100% the right option in this image (or swag) as they are the two most likely to have a user apply different permissions with some intention.

Copy link
Member

Choose a reason for hiding this comment

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

I reviewed the nginx base, and here is what we're doing
https://github.com/linuxserver/docker-baseimage-alpine-nginx/blob/a05dfb3ef3424235465cc5d30e91d471a0c870af/root/etc/s6-overlay/s6-rc.d/init-permissions/run#L9-L16
Could we not just move the logs chown up to the recursive set and add the pre-creation of the files to the nginx base?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's up to you. You're the maintainer. I'm just letting you know that there are currently two issues, one affects all nginx based images where the logs in a fresh container are root owned and logrotate is busted as a result. The other affects the nginx image where if the user changes the PUID/PGID after creation, a bunch of files have incorrect ownership.

Copy link
Member

Choose a reason for hiding this comment

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

It's up to you. You're the maintainer. I'm just letting you know that there are currently two issues, one affects all nginx based images where the logs in a fresh container are root owned and logrotate is busted as a result. The other affects the nginx image where if the user changes the PUID/PGID after creation, a bunch of files have incorrect ownership.

Does the second issue not affect all nginx based images? I think that's the part I'm misunderstanding.

Copy link
Member

Choose a reason for hiding this comment

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

Wait... I get it now.

The second issue technically does affect all nginx based images that don't already set permissions in /config/www but in the case of this image and swag I'm not sure if the best option is to adjust it for the user or to have the user adjust the permissions on their own. If the user changed PUID/PGID that's an intentional change on their part (even if they don't know what it can cause). For those that do know what it does and want more specific control over permissions if we add a recursive chown on /config/www it limits that ability. For all other images (where the idea is more to run a specific app) I do think the recursive chown on /config/www is probably fine.

I'll prep a PR for the nginx base to fix the logrotate issue and chat a bit in discord about the secondary issue. It'll kind of come down to support efforts I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Most if not all Nginx based images do a recursive chown in their init (including SWAG). Nginx image does not because it was relying on the baseimage's recursive chown which got removed a few months back.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't go look to see it in swag, but yeah I see it now. I guess at this point if we merge linuxserver/docker-baseimage-alpine-nginx#151 we can remove the log precreate in this PR and keep the recursive chown and call it a day.

nemchik added a commit to linuxserver/docker-baseimage-alpine-nginx that referenced this pull request Nov 23, 2023
@LinuxServer-CI
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@aptalca
Copy link
Member Author

aptalca commented Nov 15, 2024

looks like this was implemented in the base

@aptalca aptalca closed this Nov 15, 2024
@aptalca aptalca deleted the logs branch November 15, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work-in-progress Stale exempt
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG] Logrotate is unable to rotate logs due to incorrect file permissions
4 participants