Skip to content

Commit f36fe0f

Browse files
author
buildplan
committed
check if its a valid script
1 parent 835afca commit f36fe0f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

restic-backup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ check_for_script_update() {
235235
return 1
236236
fi
237237
echo -e "${C_GREEN}✅ Checksum verified successfully.${C_RESET}"
238+
if ! grep -q -E "^#!/(usr/)?bin/(env )?bash" "$temp_script"; then
239+
echo -e "${C_RED}Downloaded file does not appear to be a valid script. Aborting update.${C_RESET}" >&2
240+
return 1
241+
fi
238242
chmod +x "$temp_script"
239243
mv "$temp_script" "$0"
240244
if [ -n "${SUDO_USER:-}" ] && [[ "$SCRIPT_DIR" != /root* ]]; then

0 commit comments

Comments
 (0)