I kind of know the answer, but what I want to know is the implementation details: Suppose root is logged in, and we have a file which has permissions 000. Then root can write and read that file. But my question is, how is this implemented. Does it somehow follow from the usual rules (owner, group, other; rwx) or does the system look at the user and say, ok, this is root, so he has privileged rights to read,write,execute any file?

I am asking this because I am writing a rest-api application which mimicks files and users from unix ( urls for example /galois/home/gauss are considered as unix directories, while for example urls as /galois/home/gauss/iris.pfa are considered as (executable) files in unix. For a little bit more details, see here the readme: https://github.com/orgesleka/unix-acl-sql ). And now my question is, if I can somehow deduce from the usual acl of unix that root is privileged, or if I have to "hard-code" this?

  • 3
    FWIW, "root" is just a common name for the root user. It's the fact that that user has a user ID (UID) of zero that matters. – Kusalananda Nov 1 '18 at 11:49
  • so this is considered separately when implemented? – orgesleka Nov 1 '18 at 11:50

You cannot deduce this using the ACL mechanisms. You have to encode bypasses.

In some operating system kernel codebases you will find

if (suser())
or similar tests here and there. (Example from OpenBSD) This is a function to test that the effective user ID of the relevant process is zero.

In other operating system kernel codebases you will find this replaced with checks against a set of bitflag privileges that a set of credentials possesses. (Example from FreeBSD) But the same consideration applies: the privileges, if possessed, bypass the access checks and there are explicit bypass checks that have to be coded.

Both models are poor ones to be copying just for the sake of it, especially with WWW-facing code. Better to leave both ideas, that of a single distinguished magic user ID and that of magic flags that user accounts can possess, out of your design and out of your code.

Similarly, the 3-bit permissions model is not a good one to be copying. Look at NFS-style ACLs, where flags do not do the double duties that they do in the old 3-bit model. They have been around for a couple of decades, now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.