new SFTP implementation #1037
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#1037
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This ticket is for review of my new SFTP implementation. It adds or improves the following features:
support for all valid combinations of open flags (READ, WRITE, CREAT, TRUNC, APPEND, EXCL).
Unicode paths, encoded as UTF-8. (This is dependent on SFTP clients' support for UTF-8, which may be a little sketchy.)
getting file attributes, and setting attributes on an open handle.
mutable files are handled correctly, including preserving the identity of the file when writing. (The previous SFTP implementation could only read and write immutable files, and would fail when listing a directory containing mutable files -- ticket #941.)
the problem described in #645 should be fixed.
latency reduction:
directory has been read.
downloaded (unfinished downloads are stopped when the file
is closed or the SFTP session is logged out).
downloaded.
Attachment sftpd.py (52128 bytes) added
Finished recording patch 'New SFTP implementation: mutable files, read/write support, streaming download, Unicode filena mes, and more
Also see #531 for tests.
Attachment sftp-small-file.log (4574 bytes) added
This log file (sftp-small-file.log) was generated by copying a 18 byte file with Nautilus by SFTP. The upload stalled.
Replying to francois:
francois, please undo the change to 'debug =' (to avoid conflicts), then 'darcs pull' on the ticket1037 branch and try this again. I've fixed #1038, and those changes may have affected this bug as well.
Note that the current code uses foolscap logging (although it can still use 'print' if you set 'use_foolscap_logging = False' on sftpd.py line 41). Instructions on how to view foolscap logs are in source:docs/logging.txt .
Replying to [davidsarah]comment:4:
I just gave it a try with Nautilus and the bug is still present. According to Nautilus, the upload operation is stalled and I could see an empty file stored on Tahoe. Please see attached log file and screenshot.
Attachment sftp-small-file-2.log (28672 bytes) added
Attachment nautilus-dialog.jpeg (43798 bytes) added
I'm reviewing, starting with the tests -- http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/test/test_sftp.py?rev=4295 .
Excellent work so far! I'm glad to see such thorough, feature-oriented tests. I noticed that you test that we return EOF error on a 0-length read if the pos is already at EOF, instead of returning an empty string on a 0-length read in that situation. I remember that we discussed this matter on IRC and that we settled on a good argument that this was preferable. However, I don't remember the argument! Please add it to the code -- http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/frontends/sftpd.py?rev=4295#L541 -- preferably in a docstring of
def readChunk()
if you remember it.Add to test_openFile_read() a test of what happens when you read 0 bytes when you were not already at EOF.
This test looks like it is asserting the wrong result -- the permissions on "small" should be 0660, not 0440. (Also it says
FIXME
next to it... :-))Likewise I don't see why this attempt to open
small_uri
with flagsFXF_WRITE
should fail.Replying to zooko:
It should fail because:
David-Sarah think the problem reported by François has been fixed in the branch. Here are their instructions for testing the branch:
http://tahoe-lafs.org/pipermail/tahoe-dev/2010-May/004339.html
Replying to zooko:
Yes, writing files with Nautilus is now working as expected.
Reviewing http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/test/test_sftp.py?rev=4295 and http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/frontends/sftpd.py?rev=4295 .
The following comments were made when I was under the mis-impression that we were following the latest draft spec. These comments are therefore wrong and irrelevant for the actual current code, but there may be some value in them:
readLink
andmakeLink
in the future?''
returnsFX_INVALID_FILENAME
(as defined in http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13 ) instead ofFX_NO_SUCH_FILE
? (Note: twisted.conch.ssh.filetransfer doesn't define that symbol...)I marked #531 as a duplicate of this ticket.
I did a couple quick tests of the SFTP interface from the ticket1037 branch:
I attached via sshfs. I could list and copy files to the mount, as well as read the files. When I tried to modify a file and save it, there was no error, but the resulting file was 0 bytes. I did this with an .odt file that I copied to the share using nautilus and edited using open office.
I tried the same thing using the nautilus "attach to server..." to connect. I was also able to copy the .odt to the directory and open it. When I tried to edit the file and save it, Open Office gave me 3 input/output errors. I closed Open Office and noticed the file size of the .odt (reported by nautilus) was about doubled. I opened the .odt again and it looked exactly the same. I repeated the edit attempt, and the file size (reported by nautilus) again doubled.
If there are any helpful logs I could attach let me know.
I'm doing this all on ubuntu 10.04 (on a laptop) connecting to a tahoe-lafs node on VM running ubuntu server 10.04
To test this feature get the current version of David-Sarah's branch:
And follow the instructions to set up SFTP: http://tahoe-lafs.org/trac/tahoe-lafs/browser/docs/frontends/FTP-and-SFTP.txt , and then use your favorite SFTP client (especially if it is sshfs, gvfs or other FUSE-like integration layers that make the SFTP server look like a real POSIX filesystem) and report how it works.
Here is a report from the buildbot showing all builds which were specifically building the "ticket1037" branch:
http://tahoe-lafs.org/buildbot/waterfall?show_events=true&branch=ticket1037&reload=none
Okay I've finished reviewing http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/test/test_sftp.py?rev=4295 and part of http://tahoe-lafs.org/trac/tahoe-lafs-ticket1037/browser/src/allmydata/frontends/sftpd.py?rev=4295 . Note that these are not the most recent versions of those files on the ticket1037 branch! My plan is to finish reviewing those versions and then review the patches that were added to the branch since that version.
If you have a writable directory foo and a read-only child bar and you open foo/bar for write then you get PERMISSION DENIED, but if you have a writable directory foo and an immutable child bar and you open foo/bar for write then you succeed! This seems inconsistent and surprising. If foo/bar is a read-only file in a mutable directory then open("foo/bar").write('whee') will not change the result of open("foo/bar").read(), but if foo/bar is an immutable file then it will.
current behavior (inconsistent?):
proposed new behavior:
Replying to zooko:
This is now tested in [test_openFile_write]source:src/allmydata/test/test_sftp.py?rev=4466#L611.
Good question. Currently you can truncate in FXF_APPEND mode (since it only affects the position of writes), but perhaps you shouldn't be able to. Being able to truncate would interfere with the optimization of append mode discussed in #1045.
Yes. I'll add a unit test for this.
This is discussed in #1063.
Replying to [davidsarah]comment:19:
ticket:1041#comment:77187, not #1045.
I reviewed changeset:546c3d2ed471daac.
Replying to zooko:
Note that this corresponds to r4375 of trunk.
I suggest reviewing the patches since r4375 in three chunks, rather than individually:
r4375 to r4383: changes before adding the heisenfiles tables -- sftpd.py, test_sftp.py
r4383 to r4452: functional changes to add the heisenfiles tables and support for OpenSSH extensions -- sftpd.py, test_sftp.py
r4452 to r4476: mainly improvements to test coverage and assertions -- sftpd.py, test_sftp.py