Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When running ls -dZ /, I get the following output:

system_u:object_r:root_t:s0

Can the user and role fields have any effect access permissions involving a file? Do they mean anything?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

TL;DR: Yes, they can have an effect, but on your system, they probably don't.


First some background:

Most Linux distributions shipping SELinux are using a policy based on the so-called reference policy, which contains a functional policy that can be used as a base for site-specific customization, or used as-is.

The attributes you're looking at are: the SELinux user, the role, and the type (or domain) for the file or process. In SELinux, login users are mapped to SELinux users, and then the SELinux users are assigned to roles which they are allowed to perform. Each role has a set of domains that it can transition to. In this way, one can switch a user's role (users can switch their own role with the newrole command, if they are allowed to change roles) to provide or deny access to a completely different set of domains.

In the case of files, access to the file is mediated based on the user and role of the process matching the user and role with which the file is labeled. However, in the case of unconfined users, (and whenever you want, in your own custom policies) these may be ignored and only the type used, or the type ignored as well.

If you're using the default targeted policy, user and role are almost entirely unused, as this policy really does very little with user- or role-based access control, focusing on confining outward-facing services instead. This policy does have some support for confining users, but it is off by default, and all interactive user logins are unconfined.

Under the strict or mls policies, though, user- and role-based access control are much more heavily used. Users are always confined under these policies, and even what the root user can do is limited by placing the root user in the sysadm_r role. Note that the mls policy causes X to break, so you won't generally see it on workstations.

Most SELinux systems you're likely to run across will only be using the targeted policy; it's unusual to find strict or mls in use, though you will see it in places that require the user- and role-based security (e.g. defense contractors). In those cases you'll also likely see that they've customized the users and roles in use.

It's possible to write a complete SELinux policy from scratch, but since this is a lot of work, and carries its own set of nightmares (e.g. documentation or the lack thereof) you won't see it very often. Though if you want to see a demo of role-based access control, this example from IBM of a policy written from scratch serves well.

(A complete answer would be even more theory, so I'll just leave you with this. Day-to-day, the SELinux User Guide is your friend, and for the really tough SELinux questions, the mailing list is also your friend.)

share|improve this answer
    
That gives a really good general breakdown of SELinux attributes. However, where it discusses user and role, it's only reference to a Linux user account. I still see no reference to the user and role attributes as labeled on a file having any bearing over affecting the handling of the file. –  Jeff Ferland Nov 30 '12 at 18:12
    
That's because, by default, they don't. Only if you've customized your installation with user- or role-based access controls would they have any meaning. And if you do that, then you're deep into "too localized" territory and should probably ask the mailing list. –  Michael Hampton Nov 30 '12 at 18:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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