From ac93144789d79a8a2f41fb55ed800e83c52f440a Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sat, 12 Nov 2011 23:57:19 +0000 Subject: [PATCH] add access control and diagnostics git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@511 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/diag.jim | 33 ++++++++ var/mongoose/cgi-bin/settings.jim | 122 +++++++++++++++++++++++++++++ var/mongoose/html/css/style.css | 11 +++ var/mongoose/html/diag.shtml | 25 ++++++ var/mongoose/html/img/more_btn.gif | Bin 0 -> 761 bytes var/mongoose/html/index.shtml | 2 + var/mongoose/html/lib/header.jim | 2 +- var/mongoose/html/lib/header.shtml | 2 +- var/mongoose/lib/settings.class | 73 +++++++++++++++++ var/mongoose/lib/system.class | 5 +- 11 files changed, 272 insertions(+), 5 deletions(-) create mode 100755 var/mongoose/cgi-bin/diag.jim create mode 100644 var/mongoose/html/diag.shtml create mode 100644 var/mongoose/html/img/more_btn.gif diff --git a/CONTROL/control b/CONTROL/control index 9122999..e94dc2f 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.8.0-4 +Version: 0.8.1 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.7),hmt(>=1.1.1),ssmtp diff --git a/var/mongoose/cgi-bin/diag.jim b/var/mongoose/cgi-bin/diag.jim new file mode 100755 index 0000000..586e23d --- /dev/null +++ b/var/mongoose/cgi-bin/diag.jim @@ -0,0 +1,33 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/var/mongoose/lib/setup +require system.class chunked + +cgi_input +#cgi_dump + +set diag [cgi_get diag general] + +start_chunked + +if {[system modversion 1] < 113} { + chunk ">>> Diagnostics only available with customised firmware 1.13 or above." + end_chunked + exit +} + +chunk ">>> Beginning diagnostic $diag\r\n" + +set bcmd "|/bin/diag $diag" +set fd [open $bcmd r] +while {[gets $fd line] >= 0} { + chunk "$line\r\n" + #chunk_pad +} +close $fd +chunk "\r\n" +chunk ">>> Ending diagnostic $diag\r\n" + +end_chunked + diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/cgi-bin/settings.jim index 85bd48a..a5171b7 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/cgi-bin/settings.jim @@ -58,6 +58,34 @@ if {[dict exists $_cgi pkgdevoff] && ![dict exists $_cgi pkgdev]} { } handle_int_update pkgdev $pkgdev "Development Package Display" +set acluser [cgi_get acluser "-"] +set aclpass [cgi_get aclpass "-"] +set aclpassc [cgi_get aclpassc "-"] +if {$acluser ne "-" && $aclpass ne "-"} { + if {![string length $acluser]} { + puts "No username provided." + exit + } + if {$aclpass ne $aclpassc} { + puts "Passwords do not match." + exit + } + if {[string length $aclpass] < 4} { + puts "Password is too short (< 4 characters)" + exit + } + puts [$settings addacluser $acluser $aclpass] + exit +} + +set aclact [cgi_get aclact "-"] +if {$aclact ne "-" && $acluser ne "-"} { + switch $aclact { + "del" { puts [$settings delacluser $acluser] } + } + exit +} + header puts { @@ -194,6 +222,100 @@ puts " puts " +" + +puts " +

+
+ 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 "

Advanced Settings diff --git a/var/mongoose/html/css/style.css b/var/mongoose/html/css/style.css index ae6d7b1..be6a708 100644 --- a/var/mongoose/html/css/style.css +++ b/var/mongoose/html/css/style.css @@ -285,3 +285,14 @@ div.cut color: black; } +.ui-button-text +{ + font-size: inherit !important; +} + +.ui-button, .ui-button-text +{ + padding: 0; + font-size: 12px; +} + diff --git a/var/mongoose/html/diag.shtml b/var/mongoose/html/diag.shtml new file mode 100644 index 0000000..47f774a --- /dev/null +++ b/var/mongoose/html/diag.shtml @@ -0,0 +1,25 @@ + + +
+Diagnostics +Diagnostic: + + +
+ + + + + + + diff --git a/var/mongoose/html/img/more_btn.gif b/var/mongoose/html/img/more_btn.gif new file mode 100644 index 0000000000000000000000000000000000000000..9055fb01078d7ca7a9529b3c841a9d2b2fd748fb GIT binary patch literal 761 zcmdUsTTfB}0Dw<&5D-O6%gbC|Sj#DHhCPUyp~lmB9V-ajv5Sx!NEbLQVGLwG#VWn8{=>|PN$R0 z<;LUjlamt$gR#20Iy^iai^W_nm*4N_^Z7?dM;?zSkx1BVwq!CXl}g28v0AN`%jH8u zLkfjLtJT`=b{>x>5{ax%2n0Hvj?HGLQYqm7p)3LZizS`;>7aA&f;5Z(e;hkw+(P}9fwOVqyE_5L3Z~L{4NSX zqpwy2r%3?%^Bek=z)$RzQ2S2P_k;PRC^HJv30stfVcI{py_o5rB(~5+ zmqLygqtj4Vn|_XJ(0_#T{S7ej99xwN7_5G!0$tB^=` L$Jd$*SfJrAX1_ia literal 0 HcmV?d00001 diff --git a/var/mongoose/html/index.shtml b/var/mongoose/html/index.shtml index 15b3b0b..3a215c9 100644 --- a/var/mongoose/html/index.shtml +++ b/var/mongoose/html/index.shtml @@ -111,6 +111,8 @@ $(document).ready(function() {