ftp port chmod patch!
[1/1] from: maximo::meteorstudios::com at: 6-Aug-2003 10:13
well, yesterday I told the list I didn't have time to play around with the ftp handler...
the attraction was just too strong, I wanted to know how it worked, The challenge was
just to enticing...
so, after a few hours of looking at a source dump of an active ftp port and reading some
of the info from this list and reading the i-net rfc on ftp, playing around with lots
of ideas I found a way to transparently patch the ftp protocol in order for it to call
a chmod write on the file after its been dumped.
I haven't done a lot of debuging/testing (like with larges files for example, the chmod
might be called more than once) BUT IT WORKS REALLY WELL SO FAR.
The cgi detection mechanism is quite simple (improve it if you wish), I currently don't
need anything more complex, but I might include a better version in steel's redump.
basically, when a file transfer detects a file which contains ".cgi" in it (but not only
at the end, be carefull)... the write command, then sends a chmod 755 command on that
file.
I'll probably improve it someday, in order to check if the target destination directory
also contains a "cgi-bin/" path. a few extra attributes in the handler could also be
added in order to specify any arbitrary extensions one might want to be considered "executable
files". Its just a question of time. Since ftp now does what I need (and it probably
covers 95% of this lists needs too), I left it as is and am sharing the recipe right
away :-)
here goes (watch for line feeds):
;-)----------------------------------------------------------------------
rebol[
title: "ftpatch"
author: "Maxim Olivier-Adlhoch"
description: "ftp protocol patch which supports chmod for .cgi files"
]
make system/schemes/ftp/handler [
write: func [
"Default write operation called from buffer layer."
port "An open port spec"
data "Data to write"
][
net-utils/net-log ["low level write of " port/state/num "bytes"]
write-io port/sub-port data port/state/num
if find to-string port/target ".cgi" [
net-utils/net-log rejoin [port/target { IS A ".CGI" FILE! PERFORMING CHMOD 755}]
insert port/locals/cmd-port rejoin ["SITE CHMOD 755 " port/target]
]
]
net-utils/net-install ftp self 21
]
trace/net on ;-) just so you see it in action
write ftp://user:[passwd--domain--com]/web/cgi-bin/test.cgi read %/path/to/test.cgi
;-)---------------------------------------------------------------------
Hope this is usefull to some of you!
-max
-----------
meteor Studios, T.D.
-----------
Never Argue with an idiot. They will bring you down to their level and beat you with
experience







