Live data from Hacker News

Unix file access rwx permissions are simple but tricky

igoro.pro

41–50 of 77 posts

Re: Unix file access rwx permissions are simple but tricky

#41

I attended a Tanenbaum lecture once where he talked about how silly it was that nothing happens if permissions are reduced for a file while some other user/process has an open handle to it, and this is something Linux doesn't care to handle and MINIX does (or perhaps just that a kernel/filesystem should handle it, and few do -- I don't recall exactly). Surely an edge case (logging? what else? I never keep files open…

How would you want memory-mapped files to work, if permission changes affected open files?

You could synchronously invalidate the PTEs corresponding to the mapper pages on chmod and let the soft fault handler re-evaluate pages when next accessed.

That said, Linux gets this right, and Tanenbaum gets it wrong. Preserving access rights requested on open makes the system easier to reason about.

Re: Unix file access rwx permissions are simple but tricky

#42
post #2

I've been wondering about this for awhile. Do we really need multiple users for desktop unix? I get that you want some division between system and user, to protect the user against themselves. And read-only files are similarly useful, if only because some devices are read-only. But do we really need user/group/other permissions for desktop unix? and all the complexity of groups, and euid, etc. Edit: not sure why I'm…

It's a 70's permission system designed for 70's style computer usage - ie one computer shared by many people, with a relatively high level of trust among all the users.

Re: Unix file access rwx permissions are simple but tricky

#43

Earlier quoted context omitted.

It took me a shockingly long amount of time before I realized it was silly to have a username on my machines. I am the only person using this, why am I typing unnecessary cruft? Username switched to “root” on all my machines and I remove the username from PS1. /root is shorter than /home/a (:

That requires faith in software not making hard coded assumptions about filesystem structure. Something which I am not prepared to do. How much software still cannot respect XDG?

Not a problem in practice. I've seen a lot of systems having user homes in places other than /home for various (usually historical) reasons. Never broke anything afaik.

Re: Unix file access rwx permissions are simple but tricky

#44
post #2

I've been wondering about this for awhile. Do we really need multiple users for desktop unix? I get that you want some division between system and user, to protect the user against themselves. And read-only files are similarly useful, if only because some devices are read-only. But do we really need user/group/other permissions for desktop unix? and all the complexity of groups, and euid, etc. Edit: not sure why I'm…

Do we really need multiple users for desktop unix?

I find them valuable. For example, I have a workstation that is used for different projects with different clients, as well as administrative work for my own business. I want 100% separation between assets related to those different contexts.

It’s bad enough that we have package managers allowing package installation scripts to run arbitrary code, or software wanting you to install via:

    curl https://example.com/imnotmalwareipromise.sh | sh
I’ve seen people seriously make the argument that if your entire system gets nuked by malware through these installation methods then this is entirely your fault. That’s obviously an absurd victim-blaming stance, but the fact is that the risk still exists with modern software development systems.

At least if I have separate users for each client or each major project then the worst that is going to be compromised by a vulnerability introduced during the work for that client or project is that same work.

It’s not just about security though. It’s also about convenience and manageability. Those different clients and projects frequently require the use of specific security credentials and configurations, often for remote services that other clients/projects also use. In a perfect world, I’d like all of the software I use to be XDG-friendly, and I’d like each client/project to have its own home directory with its own independent XDG-style directories underneath, so each user has the configurations and credentials required for its own work and has no knowledge of or access to those of any other user. Finished a project? Archive/nuke that entire user and home directory as appropriate, and nothing is left lying around to break anything or leak anywhere later.

I’m currently playing with NixOS, which means I can also have a limited set of system-wide software installed and have specific additional packages installed per-user or even activated on demand when I change into a specific directory. Again, this means my system has only the software I actually need available at any given time, at the exact version I need for that specific work, and if something is no longer needed by anything I’m doing then it will automatically get cleaned up next time I do an update/rebuild.

None of this really works without the concept of separate users running different software in their own isolated little worlds, possibly concurrently on the same workstation and even sharing the same input/output devices (in a safe way where again they can’t unreasonably interfere with each other – something else that is not 100% there yet, but certainly a lot better than on de facto single-human-user operating systems). The only real alternative is to spin up something like a different virtual machine for each client/project where everything from the OS down is isolated, but I don’t really gain anything by doing that and it’s potentially more work to set up and more difficult to share input/output devices.

Re: Unix file access rwx permissions are simple but tricky

#45
post #7
post #3

Earlier quoted context omitted.

Those multiple users could be used to implement sandboxing. And of course if one has a family then one might want accounts for Mom, Dad, Alice and Bob.

The days of multiple family members using the same computer are long gone. Do you ever log into anyone else's desktop/laptop, or does anyone else ever log into yours? That's what I'm getting at.

My children all share an unprivileged account on our family desktop computer to play video games, etc.

In addition to this, my wife has an account on the computer which is separate from mine.

Re: Unix file access rwx permissions are simple but tricky

#46

Earlier quoted context omitted.

How would you want memory-mapped files to work, if permission changes affected open files?

You could synchronously invalidate the PTEs corresponding to the mapper pages on chmod and let the soft fault handler re-evaluate pages when next accessed. That said, Linux gets this right, and Tanenbaum gets it wrong. Preserving access rights requested on open makes the system easier to reason about.

[deleted]

Re: Unix file access rwx permissions are simple but tricky

#47

Earlier quoted context omitted.

How would you want memory-mapped files to work, if permission changes affected open files?

You could synchronously invalidate the PTEs corresponding to the mapper pages on chmod and let the soft fault handler re-evaluate pages when next accessed. That said, Linux gets this right, and Tanenbaum gets it wrong. Preserving access rights requested on open makes the system easier to reason about.

You could but it would induce corruption in programs. Programs expect I/O to fail much more often than they expect memory accesses to fail.

Re: Unix file access rwx permissions are simple but tricky

#48

Earlier quoted context omitted.

That requires faith in software not making hard coded assumptions about filesystem structure. Something which I am not prepared to do. How much software still cannot respect XDG?

Not a problem in practice. I've seen a lot of systems having user homes in places other than /home for various (usually historical) reasons. Never broke anything afaik.

It probably is fine. Still makes my spider sense tingle about some unforeseen failure that will crop up one day.

Re: Unix file access rwx permissions are simple but tricky

#49

Earlier quoted context omitted.

You could synchronously invalidate the PTEs corresponding to the mapper pages on chmod and let the soft fault handler re-evaluate pages when next accessed. That said, Linux gets this right, and Tanenbaum gets it wrong. Preserving access rights requested on open makes the system easier to reason about.

You could but it would induce corruption in programs. Programs expect I/O to fail much more often than they expect memory accesses to fail.

Programs using mmap have to be prepared for SIGBUS on mapped region access anyway --- consider the surprise removal (yanking out USB stick) case.

That few programs, especially native code ones, bother to make themselves robust against this failure mode of mmap doesn't make it any less part of the mmap contract between the kernel and userspace.

Re: Unix file access rwx permissions are simple but tricky

#50
post #9

Earlier quoted context omitted.

Depressingly i think sharing computers at least in the western world has become a thing of the past. At the very least, sharing your main form of computing.

We're sharing a computer as we speak.

Right, in the sense of "the network is the computer".

Tangent: one of the most talented engineers I ever met gave an amazing (tho sadly company-private, unrecorded) talk about how the OS was his IDE. Kind of analogous... anyway, I like this type of re-framing or meta-level-shifting.

Post reply on HN