set chan "#ascii"
set botdir "/home/dmg/hosee2"
set rootdir "$botdir/filesys"
set scrver "getdiz"
set author "dmg"
bind pub v !get get_file
proc get_file { nick uhost hand chan args } {
global rootdir
global scrver
global author
regsub -all -nocase {[^[:alnum:][][$\\]._()!'?^-]} [lindex $args 0] {} arg
if { [llength $arg] != 1 } {
putchan $chan "Usage: !get \[\[path\] <filename>\]"
return 0
} else {
set find "$rootdir/$arg"
set send [dccsend $find $nick]
putchan $chan "requesting transfer of $arg to $nick"
if { [passwdok $hand ""] == 1 } {
putchan $chan "you have to set a password (or maybe you must identify yourself?)."
return 0
}
if { $send == 0 } { putchan $chan "\002ok!\002 sending file" }
if { $send == 1 } { putchan $chan "too many connections. try again later)" }
if { $send == 2 } { putchan $chan "can't open a socket for the transfer. try again later" }
if { $send == 3 } { putchan $chan "the file $arg \002does not exist\002 (maybe you entered the wrong path?)" }
if { $send == 4 } { putchan $chan "too many simultanious transfers. putting file in queue" }
putchan $chan "---==(\\/)- $scrver by $author -(\\/)==---"
return 1
}
}
putlog "$scrver by $author"
Everything is fine and dandy except that i found out that it will accept any kind of argument to it so using !get ../../filename or whichever path/file not limited by local rights settings would be possible.
My question is: How could i limit the script/argument to refuse access outside of the $rootdir variable?
..oh, and if you wonder, the regexp is because the files in my archive (ascii art), can sometimes have crazy characters in the filename.
Please be gentle with me since i haven't quite understood how everything works and what everything does yet
Last edited by dmg on Mon Apr 20, 2009 10:08 pm, edited 1 time in total.
maybe i didnt quite understand what you want to do, but what i understood until now is that you want users ONLY have access to $rootdir and below but nowhere else than $rootdir and below?
if thats the case i dont see anything wrong because $rootdir is "hardcoded" and since you are using $arg as an addition to $rootdir your users will get "jailed" into $rootdir anyway.