security: harden installer config, download, and
0004-security-harden-installer-config-download-and-extrac.patch
--- diff --git a/install_asl3_saytime_weather_timeformat.sh b/install_asl3_saytime_weather_timeformat.sh --- a/install_asl3_saytime_weather_timeformat.sh +++ b/install_asl3_saytime_weather_timeformat.sh @@ -10,7 +10,7 @@ SBIN_DIR="/usr/local/sbin" -ORIGINAL_SOUND_ZIP_URL="http://198.58.124.150/tw/sound_files.zip" +ORIGINAL_SOUND_ZIP_URL="https://198.58.124.150/tw/sound_files.zip" @@ -51,6 +51,7 @@ download_repo_files(){ + bin/asl3-ini.sh \ @@ -64,8 +65,12 @@ download_repo_files(){ + # shellcheck source=bin/asl3-ini.sh + source "$WORKDIR/bin/asl3-ini.sh" + + install -m 0755 "$WORKDIR/bin/asl3-ini.sh" "$SBIN_DIR/asl3-ini.sh" @@ -80,20 +85,36 @@ install_files(){ - sed -i "s/^LOCATION=.*/LOCATION=\"$LOCATION_ARG\"/" "$CONFIG_FILE" + asl3_ini_set "$CONFIG_FILE" LOCATION "$LOCATION_ARG" - sed -i "s/^NODE=.*/NODE=\"$NODE_ARG\"/" "$CONFIG_FILE" + asl3_ini_set "$CONFIG_FILE" NODE "$NODE_ARG" - sed -i "s/^TIME_FORMAT=.*/TIME_FORMAT=\"$TIME_FORMAT_ARG\"/" "$CONFIG_FILE" + asl3_ini_set "$CONFIG_FILE" TIME_FORMAT "$TIME_FORMAT_ARG" +safe_unzip_sound_files(){ + local zip="$1" + local dest="$2" + local relative_file + + while IFS= read -r relative_file; do + [ -n "$relative_file" ] || continue + case "$relative_file" in + */) continue ;; + esac + asl3_zip_entry_is_safe "$relative_file" || die "Unsafe ZIP entry: $relative_file" + done < <(unzip -Z1 "$zip") + + unzip -o "$zip" -d "$dest" >/dev/null || die "Could not extract recorded voice files to $dest" +} + @@ -109,12 +130,12 @@ install_recorded_sound_files(){ - unzip -o "$zip" -d "$SOUNDS_DIR" >/dev/null || die "Could not extract recorded voice files to $SOUNDS_DIR" + safe_unzip_sound_files "$zip" "$SOUNDS_DIR" - sox -n -r 8000 -c 1 "$SOUNDS_DIR/pause-350ms.gsm" trim 0.0 1.0 + sox -n -r 8000 -c 1 "$SOUNDS_DIR/pause-350ms.gsm" trim 0.0 0.35 @@ -132,6 +153,9 @@ cron_has_block(){ + # shellcheck source=bin/asl3-ini.sh + source "$WORKDIR/bin/asl3-ini.sh" + @@ -140,7 +164,7 @@ install_cron_template(){ - active_line="0 * * * * /usr/bin/nice -19 /usr/bin/perl /usr/local/sbin/saytime.pl $LOCATION_ARG $NODE_ARG >/dev/null 2>&1" + active_line="0 * * * * /usr/bin/nice -19 /usr/bin/perl /usr/local/sbin/saytime.pl $(asl3_quote_cron_arg "$LOCATION_ARG") $(asl3_quote_cron_arg "$NODE_ARG") >/dev/null 2>&1" --