7 ms·
Isn't this just a roundabout way of saying that you can remove files from a directory you have write access to? What's the relevance here?
by JimDabell 9y ago
Isn't this just a roundabout way of saying that you can remove files from a directory you have write access to? What's the relevance here?
- etskinner 9y agoThe point seems to be that this isn't expected behavior in most people's minds, and that if someone truly wants to allow users to write to a directory, but not allow them to delete a file, that file must be flagged immutable. Just a quirky edge cases that people might not know about.
- jstanley 9y agoIt is expected behaviour if your mental model is accurate enough. My mental model is that a directory is just a special file that links to other files. Adding or deleting a file to a directory is just a case of writing to the "special file" to add or remove links to other files.
- yberreby 9y agoBut if the file you are removing is the only reference (i.e. hard link) to that inode, you're not just modifying the directory's contents; you're also removing data from the filesystem as a whole.
- glandium 9y agoNote that something else also happens to the inode when it's not the only reference: removing a file changes the "nlink" counter on the inode.
- paulddraper 9y agoRight. You are only affecting that directory listing. Any other hardlinks in any other directories are completely unaffected.
- cortesoft 9y agoThe statement 'it is the expected behavior if your mental model is accurate enough' is a tautology.
- ouid 9y agosaying that tautologies are tautologies is tautological.
- zaptheimpaler 9y agoit only tautological to say "X is a tautology" to those who had recognized X as being a tautology.
- PhasmaFelis 9y agoThe correct answer to "many people find this confusing" is never "I don't, so it's fine."
- Spivak 9y agoBut there's a difference between confusion that arises because something is complex or inconsistent and confusion that arises because people have the wrong mental model. "I assume that SQL tables are basically just fancy CSV files. Therefore strong invariants are obviously confusing."
- PhasmaFelis 9y agoIf most serious users have the wrong mental model about something, then either there's a serious documentation/training failure, or the correct model is non-obvious and counterintuitive (or both). Blaming the users for their ignorance is not productive in either case.
- joelthelion 9y agoHow do you fit immutable files into that mental model?
- libeclipse 9y agoThat comment comes across as very arrogant. Of course if you're familiar enough with the system then you'll have no need to read this, and you can go off and seek gratification installing Gentoo and telling everyone about it. But some people don't know, and benefit from learning it. So chill.
- reacweb 9y agoI did not know about immutable, but I have noticed that c9.io uses another way to avoid modification of a file present in a directory that I own. It makes it a read only mount point: /dev/mapper/volg1-lvdata on /home/ubuntu/.ssh/authorized_keys type ext4 (ro,relatime,data=ordered)
- gpvos 9y agoWell, although that is obvious, I did learn something new: that on Linux, you can prevent linking, unlinking and renaming using chattr.
- code_duck 9y agoI thought the reason the file could be written or deleted by the user was that it had no permissions set... wouldn't this not work if root chmodded little-rock to 600?
- LukeShu 9y agoNo. This would have worked the same if it were chmod 600. The point of chmod 000 was to say that clearly nobody has any any permissions to do anything directly on the file; that the permissions on the file must have nothing to do with it.
- code_duck 9y agoOkay, so deleting or renaming a file is considered a change of the directory information. Therefore, a user's ability to do that to a file is dependent upon the directory's permissions. And one can avoid that by setting the immutable bit. Got it... I think i was distracted by the parable.
- xir78 9y agoYes and every OS these days likes to squire away perms in random utils which you have to google for, I don’t see why the normal interface can’t just be updated if needed. Really annoying.