diff --git a/var/mongoose/cgi-bin/settings.js b/var/mongoose/html/settings/settings.js
similarity index 94%
rename from var/mongoose/cgi-bin/settings.js
rename to var/mongoose/html/settings/settings.js
index 91cbdd8..e25f6b6 100644
--- a/var/mongoose/cgi-bin/settings.js
+++ b/var/mongoose/html/settings/settings.js
@@ -64,7 +64,8 @@ $(document).ready(function () {
$(output)
.empty()
.show('slow')
- .load('/cgi-bin/settings.jim?' + urlargs,
+ .html('
Please wait...')
+ .load('/settings/settings.jim?' + urlargs,
function() {
$(el).enable();
$(output)
diff --git a/var/mongoose/include/menuicons.jim b/var/mongoose/include/menuicons.jim
index f13f235..5b70b4d 100755
--- a/var/mongoose/include/menuicons.jim
+++ b/var/mongoose/include/menuicons.jim
@@ -64,7 +64,7 @@ menuitem "Service Management" "/img/spanner.png" \
menuitem "Package Management" "/img/packages.png" \
/pkg/index.jim 217 228
menuitem "Settings" "/images/326_1_00_Menu_Settings.png" \
- /cgi-bin/settings.jim 217 228
+ /settings/settings.jim 217 228
menuitem "Diagnostics" "/img/diagnostics.png" \
/diag/diag.jim 217 228
diff --git a/var/mongoose/include/modversion.jim b/var/mongoose/include/modversion.jim
index 78b1723..e9b3812 100755
--- a/var/mongoose/include/modversion.jim
+++ b/var/mongoose/include/modversion.jim
@@ -16,5 +16,8 @@ puts "
if {![catch {set fhtcpversion [system fhtcpversion]}]} {
puts "
Humax Version: $fhtcpversion"
}
+if {![catch {set kernelver [system kernelver]}]} {
+ puts "
Kernel Version: $kernelver"
+}
puts ""
diff --git a/var/mongoose/include/toolbar.jim b/var/mongoose/include/toolbar.jim
index 895720a..d90df07 100755
--- a/var/mongoose/include/toolbar.jim
+++ b/var/mongoose/include/toolbar.jim
@@ -43,7 +43,7 @@ tb "/images/321_1_00_Menu_CHList.png" "Schedule" "/sched/sched.jim"
tb "/images/328_1_26_Menu_TV_Guide.png" "EPG" $epglink
tb "/img/spanner.png" "Services" "/services/index.jim"
tb "/img/packages.png" "Packages" "/pkg/index.jim"
-tb "/images/326_1_00_Menu_Settings.png" "Settings" "/cgi-bin/settings.jim"
+tb "/images/326_1_00_Menu_Settings.png" "Settings" "/settings/settings.jim"
tb "/img/diagnostics.png" "Diag" "/diag/diag.jim"
eval_plugins toolbar
diff --git a/var/mongoose/lib/bin/mkcert b/var/mongoose/lib/bin/mkcert
new file mode 100755
index 0000000..dd9affb
--- /dev/null
+++ b/var/mongoose/lib/bin/mkcert
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+config=/tmp/openssl.cnf.$$
+
+if [ "$1" = "-delete" ]; then
+ cd /mod/etc
+ [ -f webif.pem ] && rm -f webif.pem
+ [ -f mongoose.cert ] && rm -f mongoose.cert
+ exit 0
+fi
+
+cat << EOM > $config
+[req]
+distinguished_name = req_dn
+
+[req_dn]
+
+EOM
+
+/mod/bin/openssl req \
+ -x509 -nodes -days 365 \
+ -newkey rsa:2048 \
+ -subj "/C=GB/ST=Humax/CN=`hostname`" \
+ -sha1 \
+ -nodes \
+ -batch \
+ -keyout /mod/etc/webif.pem -out /mod/etc/webif.pem \
+ -config $config
+
+rm -f $config
+
+# Support legacy mongoose server...
+
+(
+ cd /mod/etc
+ [ -f mongoose.cert ] && rm -f mongoose.cert
+ ln -sf webif.pem mongoose.cert
+)
+
+exit 0
+
diff --git a/var/mongoose/lib/settings.class b/var/mongoose/lib/settings.class
index 56a4414..1488ac4 100644
--- a/var/mongoose/lib/settings.class
+++ b/var/mongoose/lib/settings.class
@@ -241,7 +241,10 @@ settings method aclusers {} {
return $users
}
+# Legacy function for Mongoose.
+
settings method mongooseauth {{mode 1}} {
+ if {![file exists /mod/etc/mongoose.conf]} return
set fd [open "/mod/etc/mongoose.conf" r]
set fdnew [open "/mod/etc/mongoose.conf.new" w]
foreach line [string trim [split [read $fd] "\n"]] {
@@ -263,44 +266,56 @@ settings method mongooseauth {{mode 1}} {
file rename "/mod/etc/mongoose.conf.new" "/mod/etc/mongoose.conf"
}
-settings method addacluser {user pass} {
- set msg ""
- if {![llength [$self aclusers]]} {
- $self mongooseauth 1
- append msg "Enabled web server authentication
"
- }
- set cmd "/mod/sbin/mongoose -A /mod/etc/htpasswd webif $user $pass"
- exec {*}$cmd
- append msg "Successfully updated user $user"
- return $msg
+settings method htdigest {user pass} {
+ set str "$user:webif:$pass"
+ set hash [string range [exec echo -n $str | md5sum] 0 32]
+ return "$user:webif:$hash"
}
-settings method delacluser {user} {
- if {![file exists "/mod/etc/htpasswd"]} { return }
- set fd [open "/mod/etc/htpasswd" r]
+settings method modacluser {user {pass 0}} {
set fdnew [open "/mod/etc/htpasswd.new" w]
- set num 0
- foreach line [string trim [split [read $fd] "\n"]] {
- lassign [split $line ":"] xuser
- if {$xuser eq $user} { continue }
- if {$line ne ""} {
- puts $fdnew $line
- incr num
+
+ # Remove existing user, if present.
+ if {[file exists "/mod/etc/htpasswd"]} {
+ set fd [open "/mod/etc/htpasswd" r]
+ set num 0
+ foreach line [string trim [split [read $fd] "\n"]] {
+ lassign [split $line ":"] xuser
+ if {$xuser eq $user} { continue }
+ if {$line ne ""} {
+ puts $fdnew $line
+ incr num
+ }
}
+ $fd close
}
- $fd close
+
+ # Add user, if required.
+ if {$pass ne "0"} {
+ puts $fdnew [$self htdigest $user $pass]
+ incr num
+ set msg "Added/updated user $user"
+ } else {
+ set msg "Removed user $user"
+ }
+
$fdnew close
file delete "/mod/etc/htpasswd"
file rename "/mod/etc/htpasswd.new" "/mod/etc/htpasswd"
- set msg "Successfully removed user $user"
- if {$num == 0} {
- $self mongooseauth 0
- append msg "
Disabled web server authentication
"
- }
+ $self mongooseauth $num
+
return $msg
}
+settings method addacluser {user pass} {
+ return [$self modacluser $user $pass]
+}
+
+settings method delacluser {user} {
+ return [$self modacluser $user]
+}
+
settings method smartdata {} {
global settingsdb
diff --git a/var/mongoose/lib/system.class b/var/mongoose/lib/system.class
index b50f9e8..2035026 100644
--- a/var/mongoose/lib/system.class
+++ b/var/mongoose/lib/system.class
@@ -66,6 +66,37 @@ proc {system fhtcpversion} {} {
return $ver
}
+proc {system kernelver} {} {
+ #1 SMP Sun Mar 25 18:30:38 KST 2012
+ set ver [string range [exec uname -v] 11 end]
+ return [switch $ver {
+ # HDR
+ "Sep 16 20:17:56 KST 2010" { format "HDR_1.01.05" }
+ "Oct 11 21:11:05 KST 2010" { format "HDR_1.01.09" }
+ "Jan 21 15:44:39 KST 2011" { format "HDR_1.02.07" }
+ "Jun 11 00:54:19 KST 2011" { format "HDR_1.02.20" }
+ "Mar 25 18:30:38 KST 2012" { format "HDR_1.02.27" }
+ "May 27 00:19:34 KST 2012" { format "HDR_1.02.28" }
+ "Jul 5 11:11:28 KST 2012" { format "HDR_1.02.29" }
+ "Jan 12 16:49:05 KST 2013" { format "HDR_1.02.32" }
+ "Mar 6 07:27:02 KST 2013" { format "HDR_1.03.06(a)" }
+ "May 8 14:32:30 KST 2013" { format "HDR_1.03.06(b)" }
+ "Dec 10 14:36:54 KST 2013" { format "HDR_1.03.11" }
+ "Fri Feb 7 14:15:02 KST 2014 " { format "HDR_1.03.12" }
+
+ # HD
+ "Oct 11 21:14:31 KST 2010" { format "HD_1.01.12" }
+ "May 17 14:16:20 KST 2011" { format "HD_1.02.18" }
+ "Jun 11 00:54:19 KST 2011" { format "HD_1.02.20" }
+ "Mar 25 07:09:19 KST 2012" { format "HD_1.02.27" }
+ "May 27 00:19:40 KST 2012" { format "HD_1.02.28" }
+ "Jul 5 19:41:17 KST 2012 " { format "HD_1.02.29" }
+ "Oct 13 12:48:09 KST 2012" { format "HD_1.02.31" }
+
+ - { format "Unknown - $ver" }
+ }]
+}
+
proc {system pkgver} {{pkg webif}} {
return [lrange [split [exec opkg list-installed $pkg] " "] 2 end]
}