system: cron template regression in 26.1.7 — missing newline corrupts all user-defined cron jobs
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
- [x] I have read the contributing guidelines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
- [x] I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue
Describe the bug
Since 26.1.7, the generated /var/cron/tabs/nobody is missing newline characters between cron job entries. The # Origin/Description: comment of each subsequent job is appended directly to the end of the previous job's command line without a preceding newline. This was working correctly in 26.1.6.
To Reproduce
- Go to System → Settings → Cron
- Create two or more user-defined cron jobs using "Custom CURL call" (or any command)
- Save and apply
- Inspect
/var/cron/tabs/nobody
Expected behavior
Each cron entry and its # Origin/Description: comment should be separated by a newline:
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping1'
# Origin/Description: cron/Job 2
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping2'
Actual behavior
The comment is concatenated directly onto the previous command line without a newline:
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping1'# Origin/Description: cron/Job 2
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping2'
This causes the shell to treat 'https://example.com/ping1'# as a single token — the # is not interpreted as a comment start (POSIX requires whitespace before # for comment recognition), so the entire # Origin/Description: ... string is appended literally to the URL/argument passed to the command. The second job's command executes correctly; only the first job (and any subsequent except the last) is affected.
Describe alternatives you considered
Disabling and re-enabling jobs individually does not resolve the issue — the missing newline is present regardless of job count or order as soon as more than one user-defined job exists.
Workaround: Define jobs directly in /usr/local/etc/cron.d/ to bypass the user.cron template entirely.
Relevant log files
Actual /var/cron/tabs/nobody output (sensitive values replaced):
# Origin/Description: cron/Job A
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping1'# Origin/Description: cron/Job B
*/1 * * * * /usr/local/sbin/configctl -d -- cronscripts curl 'https://example.com/ping2'
System log shows the affected job returning an error from the remote endpoint, while the last job in the file executes correctly.
Additional context
This regression is likely related to the cron template changes introduced as part of the fix for #10075 (merged in 26.1.7). The user.cron template appears to no longer emit a trailing newline after each command entry.
Environment
OPNsense 26.1.7 (amd64)
@jusicgn thanks, should be fixed with https://github.com/opnsense/core/commit/55c7bd247e7aa202f945bde13d36c3eb8d750707
thank you, will hotfix this tomorrow morning
well, all hotfixed now
@fichtner & @AdSchellevis wow, that was quick. Thanks a lot 👍