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

Fix crontab backslash #4353

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

Anuril
Copy link
Contributor

@Anuril Anuril commented Apr 4, 2024

This was a fun one 😄

This fixes #4329 and some other issues with crontabs that were not yet found.

  1. The bash function read removed the backslash when reading the $USER_DATA/cron.conf file because -r wasn't used - so json_decode never received the string with \.
  2. If json_decode in web/list/cron/index.php would have received it, it would've been buggy, as json_decode can't deal with single backslashes, so we have to manually escape the backslashes.
  3. The same issue plagued the edit functionality so we do the same thing in /web/edit/cron/index.php

I also noticed that the same thing happened when I wanted to use this crontab line:
/usr/bin/find /home/testuser/test/ -type f -exec echo "Files: "ls {} >> /home/testuser/test/log.log \;

And that issue was with double quotes.

EDIT: This also caused to not create the cron tab entries in the correct way, as func/main.sh also didn't use the -r flag with read.

I also just noticed that there might be an issue when upgrading when suddenly the cronjobs in $USER_DATA/cron.conf are in a wrong format, which breaks the display of the list. I'll create a script to fix that.

EDIT2: Fixed all the parsing issues with quotes and backslashes and all other characters by converting the command string to base64 and storing it that way.

@Anuril Anuril marked this pull request as draft April 4, 2024 20:48
@Anuril Anuril marked this pull request as ready for review April 5, 2024 14:01
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.

[Bug] Crontab editor opening existing cron that has a ; in the command
1 participant