Merge pull request #11 from hobbyquaker/master

Session validation
This commit is contained in:
j-a-n 2018-07-22 11:56:45 +02:00 committed by GitHub
commit 219d5801b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 1 deletions

View File

@ -1,5 +1,5 @@
{
CONFIG_URL /addons/rmupdate
CONFIG_URL /addons/rmupdate/index.cgi
CONFIG_DESCRIPTION {
de {<li>System-Update</li>}
en {<li>System-update</li>}

View File

@ -0,0 +1,9 @@
catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
set $varname $val
}
}
}

13
addon/lib/session.tcl Normal file
View File

@ -0,0 +1,13 @@
#!/bin/tclsh
load tclrega.so
proc check_session sid {
if {[regexp {@([0-9a-zA-Z]{10})@} $sid all sidnr]} {
set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
if {$res != ""} {
return 1
}
}
return 0
}

12
addon/www/index.cgi Normal file
View File

@ -0,0 +1,12 @@
#!/bin/tclsh
source /usr/local/addons/rmupdate/lib/querystring.tcl
source /usr/local/addons/rmupdate/lib/session.tcl
if {[info exists sid] && [check_session $sid]} {
set fp [open "/usr/local/addons/rmupdate/www/rmupdate.html" r]
puts -nonewline [read $fp]
close $fp
} else {
puts {error: invalid session}
}