Skip to content

move cron to os init, optimize cron init#285

Draft
aptalca wants to merge 1 commit into
3.24from
3.24-cron
Draft

move cron to os init, optimize cron init#285
aptalca wants to merge 1 commit into
3.24from
3.24-cron

Conversation

@aptalca

@aptalca aptalca commented Jun 12, 2026

Copy link
Copy Markdown
Member

PR proposal for all os baseimages:

  • Move cron init to os init to prevent race condition (currently cron init runs concurrently with downstream image init)
  • Optimize cron init to achieve the following:
    • /defaults/crontabs is for user customizable crontabs and they take priority over /etc/crontabs
    • /etc/crontabs is for non-user customizable crontabs
    • /config/crontabs is only created and imported from if /defaults/crontabs is present in image
    • in RO environments, no import is done, only /etc/crontabs is active
      • for images where we include /defaults/crontabs, we should also include /etc/crontabs as a fallback for RO environments
  • Potential downside: import of /config/crontabs/root means an unprivileged user can run scripts as root inside the container

@LinuxServer-CI

Copy link
Copy Markdown
Collaborator

I am a bot, here are the test results for this PR for commit 0ece153 :
https://ci-tests.linuxserver.io/lspipepr/alpine/3.24-fc91df9f-pkg-fc91df9f-dev-0ece153acc9bf0166e879c5e37f689039ff5dd38-pr-285/index.html
https://ci-tests.linuxserver.io/lspipepr/alpine/3.24-fc91df9f-pkg-fc91df9f-dev-0ece153acc9bf0166e879c5e37f689039ff5dd38-pr-285/shellcheck-result.xml

Tag Passed
amd64-3.24-fc91df9f-pkg-fc91df9f-dev-0ece153acc9bf0166e879c5e37f689039ff5dd38-pr-285
arm64v8-3.24-fc91df9f-pkg-fc91df9f-dev-0ece153acc9bf0166e879c5e37f689039ff5dd38-pr-285

fi

# set permissions and import user crontabs
lsiown "${cron_user}":"${cron_user}" "/config/crontabs/${cron_user}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was important. Having the cron user own the crontab in /config meant running as root inside the container required root access on the host. Having abc own the root crontab in /config will allow unprivileged users to modify the container's root cron. If the container has a docker socket that could lead to all kinds of shenanigans.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Most downstream images recursively chown config, no point in fighting it.

Custom init also had the same issue and the solution was to put them in a separate mount outside of config, which is not worth the hassle here.

@LinuxServer-CI

Copy link
Copy Markdown
Collaborator

I am a bot, here are the test results for this PR for commit a377283 :
https://ci-tests.linuxserver.io/lspipepr/alpine/3.24-c0036bf5-pkg-c0036bf5-dev-a377283d8d0e65941d6ce53f72f064fdf1204e58-pr-285/index.html
https://ci-tests.linuxserver.io/lspipepr/alpine/3.24-c0036bf5-pkg-c0036bf5-dev-a377283d8d0e65941d6ce53f72f064fdf1204e58-pr-285/shellcheck-result.xml

Tag Passed
amd64-3.24-c0036bf5-pkg-c0036bf5-dev-a377283d8d0e65941d6ce53f72f064fdf1204e58-pr-285
arm64v8-3.24-c0036bf5-pkg-c0036bf5-dev-a377283d8d0e65941d6ce53f72f064fdf1204e58-pr-285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants