imbajin commented on code in PR #3253: URL: https://github.com/apache/hugegraph/pull/3253#discussion_r4184814831
########## hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-monitor.sh: ########## @@ -37,6 +37,21 @@ fi # Monitor HugeGraphServer every minute, if the server crashes then restart it. # Modify the frequency according to actual needs carefully. -CRONTAB_JOB="*/1 * * * * export JAVA_HOME=$JAVA_HOME && $TOP/bin/monitor-hugegraph.sh" + +# Persist any path overrides (-c/-l/-i/-o) that the caller (start-hugegraph.sh) exported +CRONTAB_JOB="*/1 * * * * export JAVA_HOME=$JAVA_HOME &&" +if [ -n "$CONF_OVERRIDE" ]; then + CRONTAB_JOB="$CRONTAB_JOB export CONF_OVERRIDE='$CONF_OVERRIDE' &&" Review Comment: I'd keep support for legitimate paths containing spaces or apostrophes. Please use one POSIX shell-word quoting helper for the saved cron command, rather than inserting a backslash into the existing single-quoted value. For example, `/data/team's-logs` should become `'/data/team'\''s-logs'` as one complete shell word; callers should not add another pair of quotes. A few boundaries to cover: - Apply the helper consistently to all four overrides, `JAVA_HOME` and the monitor script path. Avoid relying directly on Bash `printf '%q'`: cron normally parses the command with `/bin/sh` before the monitor's Bash shebang takes effect. - For this patch, reject CR/LF and `%` with a clear error before updating crontab. Check CR/LF before canonicalization, since command substitution can strip trailing newlines. `%` has cron-specific meaning even inside shell quotes; supporting it would need a separate, tested cron-encoding layer. - Use `printf '%s\n' "$job"` when writing the entry. Quote the paths inside `monitor-hugegraph.sh` too, and keep add/remove matching consistent with the serialized command so an apostrophe path does not create a job that `stop-monitor.sh` cannot remove. Please add regression cases for spaces, apostrophes, backslashes and shell metacharacters, verify values survive execution through `/bin/sh` (including dash), and check duplicate-add/removal plus rejected-input handling without changing the existing crontab. No need to change the user's global cron `SHELL` setting. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
