Skip to content

Commit 167b5ae

Browse files
committed
limit the update-check.cgi to parse for cmd=download and not parse arbitrary query string options.
1 parent 5766ab1 commit 167b5ae

5 files changed

Lines changed: 38 additions & 33 deletions

File tree

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.5.8+4

addon_files/mosquitto/rc.d/mosquitto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ case "$1" in
5050
info)
5151
echo "Info: <center><a href=\"https://mosquitto.org/\" target=\"_blank\"><img width=\"240\" src="/addons/mosquitto/mosquitto-text-side-28.png"></a></center>"
5252
echo "Name: Mosquitto"
53-
echo "Version: 1.5.8+3"
54-
echo "Update: /addons/mosquitto/update_check.cgi"
53+
echo "Version: $(cat ${ADDON_DIR}/VERSION)"
54+
echo "Update: /addons/mosquitto/update-check.cgi"
5555
echo "Operations: uninstall restart"
5656
;;
5757

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/tclsh
2+
3+
set checkURL "https://raw.githubusercontent.com/homematic-community/ccu-addon-mosquitto/master/VERSION"
4+
set downloadURL "https://github.com/homematic-community/ccu-addon-mosquitto/releases/latest"
5+
6+
catch {
7+
set input $env(QUERY_STRING)
8+
set pairs [split $input &]
9+
foreach pair $pairs {
10+
if {$pair == "cmd=download"} {
11+
set cmd "download"
12+
break
13+
}
14+
}
15+
}
16+
17+
if { [info exists cmd ] && $cmd == "download"} {
18+
puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
19+
puts -nonewline "<html><head><meta http-equiv='refresh' content='0; url=$downloadURL' /></head><body></body></html>"
20+
} else {
21+
puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
22+
catch {
23+
set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
24+
}
25+
if { [info exists newversion] } {
26+
puts $newversion
27+
} else {
28+
puts "n/a"
29+
}
30+
}

addon_files/mosquitto/www/update_check.cgi

Lines changed: 0 additions & 27 deletions
This file was deleted.

build.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ BUILD_DIR=`cd ${0%/*} && pwd -P`
55
ADDON_FILES=$BUILD_DIR/addon_files
66
ADDON_TMP=$BUILD_DIR/addon_tmp
77

8-
mkdir $ADDON_TMP 2> /dev/null || rm -r $ADDON_TMP/*
8+
rm -rf $ADDON_TMP
9+
mkdir $ADDON_TMP
910

1011
echo "copying files to tmp dir..."
1112
cp -r $ADDON_FILES/* $ADDON_TMP/
13+
cp VERSION $ADDON_TMP/mosquitto/
1214

1315
cd $BUILD_DIR
1416

15-
16-
ADDON_FILE=mosquitto-1.5.8+3.tar.gz
17+
ADDON_FILE=mosquitto-$(cat VERSION).tar.gz
1718
echo "compressing addon package $ADDON_FILE ..."
1819

1920
mkdir $BUILD_DIR/dist 2> /dev/null
2021
cd $ADDON_TMP
21-
cd $ADDON_TMP
2222
if [[ "$OSTYPE" == "darwin"* ]]; then
2323
if [[ -f /usr/local/bin/gtar ]]; then
2424
gtar --exclude=.DS_Store --owner=root --group=root -czf $BUILD_DIR/dist/$ADDON_FILE *
@@ -29,5 +29,6 @@ else
2929
tar --owner=root --group=root -czf $BUILD_DIR/dist/$ADDON_FILE *
3030
fi
3131
cd $BUILD_DIR
32+
rm -r $ADDON_TMP
3233

3334
echo "done."

0 commit comments

Comments
 (0)