diff --git a/CONTROL/control b/CONTROL/control index 3fcb9d4..f893b6f 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,10 +1,11 @@ Package: webif Priority: optional Section: web -Version: 1.0.10-6 +Version: 1.0.11 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons(>=1.1.10),mongoose(>=3.0.11),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6) +Conflicts: tvdiary(<0.0.2-6) Suggests: Description: An evolving web interface for the Humax. Tags: http://hummy.tv/forum/threads/4723/ diff --git a/var/mongoose/html/index.shtml b/var/mongoose/html/index.shtml new file mode 120000 index 0000000..64233a9 --- /dev/null +++ b/var/mongoose/html/index.shtml @@ -0,0 +1 @@ +index.html \ No newline at end of file diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/html/settings/settings.jim similarity index 96% rename from var/mongoose/cgi-bin/settings.jim rename to var/mongoose/html/settings/settings.jim index e87a9b1..e57a6c5 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/html/settings/settings.jim @@ -9,10 +9,10 @@ httpheader if {[cgi_get act] eq "https"} { set val [cgi_get val off] if {$val in {0 off}} { - file delete /mod/etc/mongoose.cert + exec /mod/webif/lib/bin/mkcert -delete puts "HTTPS Server will be disabled after next reboot." } else { - exec /mod/sbin/mongoose_mkcert + exec /mod/webif/lib/bin/mkcert puts "HTTPS Server will be enabled after next reboot." } exit @@ -127,10 +127,10 @@ if {$aclact ne "-" && $acluser ne "-"} { } jqplugin form iphone-style-checkboxes +jscss settings.js header puts { -
} @@ -175,8 +175,6 @@ puts " " -setting_toggle "HTTPS web server?" "https" \ - [file exists /mod/etc/mongoose.cert] 0 1 setting_toggle "Slide-down toolbar?" "notoolbar" $(!$notoolbar) 1 setting_toggle "Mobile link on main page?" "nomobile" $(!$nomobile) 1 setting_toggle "Help links on main page?" "nohelplinks" $(!$nohelplinks) 1 @@ -240,7 +238,113 @@ puts " puts "
+" +puts " +

Web Interface Settings

+
+
+ Web Interface Settings + +" +setting_toggle "HTTPS web server?" "https" \ + [file exists /mod/etc/mongoose.cert] 0 1 +puts " +
+
+
+
+ User Access Control + +" + +set aclusers [$settings aclusers] +if {[llength $aclusers]} { + puts "" + foreach user [$settings aclusers] { + lassign $user user + puts "" + puts "" + } + puts "" + puts "" +} else { + puts "" +} + +puts "" +puts " + + + + + + +
Existing Users
+ $userNew password: +
" + puts "Again: + " + puts "
" + puts "" + puts "
 
 
+ Add a user to enable authentication.
Add New User
New User: +
Password: +
Password (confirm): +
+
+
+
+
+" + +puts { + +} + + +puts "

EPG Settings

@@ -389,99 +493,6 @@ puts " #

#" -puts " -

Web Interface User Access Control

-
-
- Web Interface User Access Control - -" - -set aclusers [$settings aclusers] -if {[llength $aclusers]} { - puts "" - foreach user [$settings aclusers] { - lassign $user user - puts "" - puts "" - } - puts "" - puts "" -} else { - puts "" -} - -puts "" -puts " - - - - - - -
Existing Users
- $userNew password: -
" - puts "Again: - " - puts "
" - puts "" - puts "
 
 
- Add a user to enable authentication.
Add New User
New User: -
Password: -
Password (confirm): -
-
-
-
-
-" - -puts { - -} - puts -nonewline "

Advanced Settings

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] }