Skip to content

Commit e9f3dc2

Browse files
Use escaped cron paths and refine renewal wording
Agent-Logs-Url: https://github.com/8bitDream/AmiiboAPI/sessions/0306bdf9-88cc-41dd-8bde-09039539f355 Co-authored-by: AbandonedCart <1173913+AbandonedCart@users.noreply.github.com>
1 parent 6b4a3bf commit e9f3dc2

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This script:
5353
- Copies `fullchain.pem` and `privkey.pem` from `/etc/letsencrypt/live/amiiboapi.org/` into the project root
5454
- Sets file permissions to read/write for owner+group (`660`) on both certificate files
5555
- Installs `/etc/cron.d/amiiboapi-certbot` to run renewal checks twice daily
56-
- `certbot renew` renews certificates (90-day validity) when they have 30 days or less remaining
56+
- `certbot renew` attempts renewal for certificates with 30 days or less remaining (90-day validity period)
5757

5858
> [!IMPORTANT]
5959
> `certbot --standalone` needs port `80` available. Stop any process using port `80` before running issuance if needed.

scripts/certbot_certificate.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ renew_certificate() {
7171
}
7272

7373
install_renewal_schedule() {
74-
local cron_cmd cron_line
75-
if [[ ! "$SCRIPT_PATH" =~ ^[A-Za-z0-9._/-]+$ || ! "$LOG_FILE" =~ ^[A-Za-z0-9._/-]+$ ]]; then
76-
echo "SCRIPT_PATH and LOG_FILE contain unsupported characters for cron setup." >&2
74+
local quoted_script_path quoted_log_file cron_cmd cron_line
75+
if [[ "$SCRIPT_PATH" != /* || "$LOG_FILE" != /* || "$SCRIPT_PATH" == *$'\n'* || "$LOG_FILE" == *$'\n'* ]]; then
76+
echo "SCRIPT_PATH and LOG_FILE must be absolute single-line paths for cron setup." >&2
7777
exit 1
7878
fi
7979

80-
cron_cmd="/bin/bash \"$SCRIPT_PATH\" renew >> \"$LOG_FILE\" 2>&1"
80+
printf -v quoted_script_path '%q' "$SCRIPT_PATH"
81+
printf -v quoted_log_file '%q' "$LOG_FILE"
82+
cron_cmd="/bin/bash $quoted_script_path renew >> $quoted_log_file 2>&1"
8183
cron_line="0 3,15 * * * root $cron_cmd"
8284

8385
run_as_root touch "$LOG_FILE"

0 commit comments

Comments
 (0)