ftp patch
[1/7] from: rotenca::telvia::it at: 17-Nov-2003 20:44
Hi all,
do load-thru http://www.rebol.it/%7Eromano/ftp-patch.r
This is my beta version of the patch.
This is what I try to fix:
- removed a security issue (load no more used)
- multiline in every confirm call
- try-catch for net-error throw before 1.2.10
- NLST removed (must it be activacted with a custom option?)
- parse-dir-list handles connections in a fixed loop and with try-catch
- parse-files permits any char in owner and groups
- right size in dir
- fixed query errors
- fixed get-port errors
- added a new answer value (200) to CWD
- copy now has /part support
- pick fixed to work with first second...
- remove now has /part support and cache is updated
- close added try to confirm-close for ('dir 'query) and no more store the
port if fails
- added missing local words
- removed unused global word (list-clean)
- removed unused /locals word (home-dir)
Many other changes are only cosmetic.
Feedback welcome!
---
Ciao
Romano
[2/7] from: atruter:labyrinth:au at: 18-Nov-2003 9:51
Hi Romano,
> Feedback welcome!
Tried this on my two servers and (like Brett's) it corrects all my issues.
Good job. Are you and Brett going to join / merge efforts on this one now
that we have two working models? ;)
Regards,
Ashley
[3/7] from: brett:codeconscious at: 18-Nov-2003 15:00
Hi Ashley,
> Tried this on my two servers and (like Brett's) it corrects all my issues.
> Good job.
Good news.
> Are you and Brett going to join / merge efforts on this one now
> that we have two working models? ;)
I'm sure we are. From what I've seen so far Romano's work will be the better
base to build on. I like what he has done. However it might take RT more
time to review it for inclusion in their products because of the literal
(not necessary logic) differences. But more comments should alleviate that.
In the end I think it is better to have a much stronger result.
Regards,
Brett.
[4/7] from: brett:codeconscious at: 18-Nov-2003 18:05
Hi Romano,
> This is my beta version of the patch.
>
> This is what I try to fix:
Great work!
I have looked through your code and I have tried it with my server. It would
be good to use it as a base to build on.
Here's my comments and findings.
---NLST and "Blind" directories
Having looked into NLST more I agree with you - let's just leave it out. If
someone has a desperate need then maybe their situation will show a solution
(custom code perhaps).
Also for "blind" directories better to get what we have working and cleaned
up and deal with the blind problem later if it arises.
--- Parse-files
I believe this function should return none! when parsing fails and a block
when it succeeds. By returning none! an error can be raised within
parse-dir-list. The problem at the moment is if parsing fails, inaccurate
results can be returned without the user knowing. I've confirmed this with
my dodgy test ftp server by emitting deliberately badly formated data (to
simulate an unknown directory listing).
---Data-connect
There's two instances of "error? catch".
---Parse-dir-list
temp: 'list
can be removed by putting the 'list as the parameter directly.
Might be nice to make file-list local to the function.
---PWD and CWD
PWD does not seem to appear at all in network tracing - my patch showed it
coming just after SYST.
I think you may have introduced a bug on CWD. I think that the path should
not be modified if it beings with a "/". I suggest reverting to the original
version of this.
---Unchanged words
These appear to be no different to me: list-check list-file-check
rmdir-check
---Globals
I think parse-dir-list and others can be made local
---"Check you login" bug.
This appears in the original scheme and your scheme, but not my scheme. I
tried to identify what was going on but so far I have not found the problem.
I assume it is to do with connection management and when things are closed.
This is the sequence:
site: ftp://XXXX:[YYY--codeconscious--com]/
print mold read site ; -> SUCCESS
make-dir join site %test-a/test-b/ ; ERROR 550
print mold read site ; SUCCESS
probe read join site %test-a/test-b/ ; ERROR 550
print mold read site ; SUCCESS
probe read join site %test-a/ ; ERROR 550
print mold read site ; ERROR = Failed login to codeconscious...check your
login
probe read join site %test-b/ ; ERROR = Failed login to
codeconscious...check your login
print mold read site ; ERROR = Failed login to codeconscious...check your
login
A strange thing I noticed looking at the trace for the MAKE-DIR was PORT. I
guess I wasn't expecting to see it for make-dir. This was the sequence in
the trace for make-dir:
USER PASS SYST PORT CWD PORT MKD
Maybe some more network logging for the connections will help.
Regards,
Brett.
[5/7] from: rotenca:telvia:it at: 20-Nov-2003 1:06
Beta version 2 for download:
do load-thru http://www.rebol.it/%7Eromano/ftp-patch.r
0.0.2 BETA version 19/11/03
New Features
- Experimental query which does not throw an error if file not found
The behaviour now should be the the same of a file-system port.
- chdir-check now uses the View 1.2.10 version (was View 1.2.8 version of
chdir in previous beta) (thanks Brett!)
- Added a new error for dir open in direct mode
- Added a new error for file open in skip mode
Original FTP bugs fixed (i hope):
- Added two try-catch to data-connnect (was catch)
- Added one try-catch to open for open-proto (was try)
- Moved cache-size in the handler object
- Globals word made locals: add-date digits no-newline ftp-nlist reduced
data-connect parse-dir-list
- Removed unuseful 'file field in /locals
Bugs in 0.0.1 beta version of the patch:
- Fixed 0.0.1 bug in close: now port set to none also if an error occurs in
closing port
This should fix the error reported by Brett about cached connections.
- new locals: locals
- sremove used in the remove function
- 'new-dir instead of 'dir in the open function (like in the original RT
code - was a typo)
And many cosmetic changes, as usual. :-)
---
Ciao
Romano
[6/7] from: atruter:labyrinth:au at: 20-Nov-2003 12:41
Hi Romano,
> Beta version 2 for download:
>
> do load-thru http://www.rebol.it/%7Eromano/ftp-patch.r
my test case is fairly simple:
<code>
do %ftp-patch.r
;do %ftp-proposed.r
sumtree: function [dir [file! url!]] [val] [
val: 0
foreach file read dir [
val: val + either #"/" = last file [sumtree dir/:file][1]
]
val
]
sites: [
ftp://userid:[password--www--site1--com--au]/public_html/
ftp://userid:[password--www--site2--com]/public_html/
]
foreach site sites [
print reform ["Testing" site]
print read join site %test/ ; non-empty dir
print read join site %test2/ ; empty dir
print sumtree site
]
</code>
This now fails (more than halfway through?!) in the sumtree function with
the following error:
...
Net-log: {250 OK. Current directory is /public_html/documents}
Net-log: "Type: dir"
Net-log: ["TYPE A" "200"]
Net-log: "200 TYPE is now ASCII"
Net-log: ["LIST" ["150" "125"]]
Net-log: "150 Connecting to port 1412"
Net-log: ["Closing sub-port" tcp 20 20 1412]
Net-log: [none "226"]
Net-log: "226-Options: -l "
Net-log: "226 5 matches total"
URL Parse: userid password www.site.com.au none public_html/images/ none
Net-log: ["PWD" "25"]
Net-log: {257 "/public_html/documents" is your current location}
Net-log: ["Opening" "tcp" "for" "FTP"]
Net-log: [none ["220" "230"]]
Net-log: ["Opening listen tcp port for FTP"]
Net-log: [["PORT" port/locals/active-check] "200"]
Net-log: ["PASV" "227"]
** User Error: Server error: tcp connection failed
** Near: foreach file read dir [
val: val + either #"/" = last file [sumtree dir/:file] [1]
]
>>
If you need the full log and / or the log of Brett's run (which works) I
can email it to you direct.
Regards,
Ashley
[7/7] from: brett:codeconscious at: 21-Nov-2003 10:14
Hi Ashley,
> > Beta version 2 for download:
> >
> > do load-thru http://www.rebol.it/%7Eromano/ftp-patch.r
...
> This now fails (more than halfway through?!) in the sumtree function with
> the following error:
I've reproduced your error with a different sequence - looking into it with
Romano.
Regards,
Brett.