SFTP: semantics of writing an entry to an immutable file in a writeable directory #1063
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#1063
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?
If we have a write cap to a Tahoe directory, or write permission to a Unix directory, we can always replace entries in that directory.
In Unix filesystems, there are also write permission bits on individual files. If the applicable write permission bit is not set on a file, then attempts to open the file for writing will fail with an EPERM error, even though the directory entry could be changed to refer to a different file.
(Note that, non-standard extensions aside, files/inodes in a Unix filesystem are mutable. If a file is hardlinked from two directory entries, the hardlinks are aliases to the same mutable file/inode object.)
The previous SFTP code did not support the case of a non-writeable file in a writeable directory. I.e. if the path passed to an open request with FXF_WRITE or FXF_CREAT flags refers to an immutable file at the time of the open, then the request will succeed, and the directory entry will be changed to refer to a new immutable file when the handle is closed.
This is also true for the new implementation as of ticket1037 r4377, but in addition we support opening mutable files. A read-only mutable file (that is, one whose entry in the parent directory is a read cap) cannot be opened for writing, even when the parent directory is writeable.
Zooko expressed concern on IRC that the ability to express non-writeable directory entries referring to mutable files, but not to immutable files, was inconsistent and might cause compatibility problems. (I hope I've expressed his concern correctly.)
I propose to address that by adding an optional "
no-write
" field in the metadata of directory entries. The default would be False. When this field is set to a non-empty string in an entry pointing to an immutable file, the write permission bits reflected to SFTP clients would have the 'write' bits cleared, and attempts to open the entry for writing would fail. (The field would have no effect on entries pointing to directories, unknowns, or mutable files.)Note that the permissions reflected to SFTP clients always have 'owner', 'group' and 'world' bitfields the same. When the permissions are set by a client, the value of 'no-write' would be taken from the owner write bit.
Pros:
Cons:
A closely related issue is what should happen when you clear the owner write bit on an entry pointing to a mutable file or mutable directory. This could diminish the write cap to a read cap. However, unlike the corresponding operation on Unix permissions (for the file owner), that would not be reversible -- it would not be possible to restore the write cap by changing the permissions back.
The advantage of this is that you would be able to use
chmod
to create read-only structures in the Tahoe filesystem. Without it, there is no way to create a read-only link to a mutable directory (or file) just using SFTP.fixed by changeset:de95140b7b58b4b0, changeset:29a06457d25bcea8, changeset:2a791b0d05b8bab4.
Hm, note that the part about diminishing a read-write cap to a read-only cap when the no-write flag is set is an actual security restriction.