Skip to contentSkip to conversation

How does matchpathcon/setfiles work?

DISCUSSION dE 3 participants 5 messages Jun 1, 2014 – Jun 2, 2014 SELinux security module

lore
Share & tools
lore

dE

author
#0 lore raw

As we know, policies don't contain paths. So the working of matchpathcon/setfiles must be based on common sense.

It looks like it knows certain special folders and it's appropriate security context, for e.g. home folder contents should have files with user_home_t and suggests the correct SELinux user for the files/directories based on which user's home folder is it.

Other directories/files should have the same security context as the parent directory, like with /opt.

Is this correct?

#1 lore raw

Policies do contain paths. They contain path expressions to be more precise.

During policy load, the path expressions together with the target contexts are extracted and placed in /etc/selinux/mcs/contexts/files/file_contexts, which is where tools like matchpathcon get their information from.

Wkr,
Sven Vermeulen

Quoted 19 lines · dE

As we know, policies don't contain paths. So the working of matchpathcon/setfiles must be based on common sense.

It looks like it knows certain special folders and it's appropriate security context, for e.g. home folder contents should have files with user_home_t and suggests the correct SELinux user for the files/directories based on which user's home folder is it.

Other directories/files should have the same security context as the parent directory, like with /opt.

Is this correct?
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

author
#2 lore raw
Quoted 18 lines · Sven Vermeulen

Policies do contain paths. They contain path expressions to be more precise.

During policy load, the path expressions together with the target contexts are extracted and placed in /etc/selinux/mcs/contexts/files/file_contexts, which is where tools like matchpathcon get their information from.

Wkr,
Sven Vermeulen

On Jun 1, 2014 5:48 PM, "dE" <[email protected] <mailto:[email protected]>> wrote:

As we know, policies don't contain paths. So the working of matchpathcon/setfiles must be based on common sense.

It looks like it knows certain special folders and it's appropriate security context, for e.g. home folder contents should have files with user_home_t and suggests the correct SELinux user for the files/directories based on which user's home folder is it.

Quoted 5 lines

Other directories/files should have the same security context as the parent directory, like with /opt.

Is this correct?

Do the paths have any other purpose other than defining the default security context?

#3 lore raw
Quoted 24 lines · dE
Quoted 23 lines · Sven Vermeulen

Policies do contain paths. They contain path expressions to be more precise.

During policy load, the path expressions together with the target contexts are extracted and placed in /etc/selinux/mcs/contexts/files/file_contexts, which is where tools like matchpathcon get their information from.

Wkr,
Sven Vermeulen

On Jun 1, 2014 5:48 PM, "dE" <[email protected]
<mailto:[email protected]>> wrote:

As we know, policies don't contain paths. So the working of matchpathcon/setfiles must be based on common sense.

It looks like it knows certain special folders and it's appropriate security context, for e.g. home folder contents should have files with user_home_t and suggests the correct SELinux user for the files/directories based on which user's home folder is it.

Quoted 8 lines
Quoted 5 lines

Other directories/files should have the same security context as the parent directory, like with /opt.

Is this correct?

Do the paths have any other purpose other than defining the default security context?

No, and they are not part of the kernel policy, only used by userspace programs like setfiles, udev, package managers like rpm/dpkg, etc.

author
#4 lore raw
Quoted 27 lines · Stephen Smalley
Quoted 26 lines · dE
Quoted 25 lines · Sven Vermeulen

Policies do contain paths. They contain path expressions to be more precise.

During policy load, the path expressions together with the target contexts are extracted and placed in /etc/selinux/mcs/contexts/files/file_contexts, which is where tools like matchpathcon get their information from.

Wkr,
Sven Vermeulen

On Jun 1, 2014 5:48 PM, "dE" <[email protected]
<mailto:[email protected]>> wrote:

As we know, policies don't contain paths. So the working of matchpathcon/setfiles must be based on common sense.

It looks like it knows certain special folders and it's appropriate security context, for e.g. home folder contents should have files with user_home_t and suggests the correct SELinux user for the files/directories based on which user's home folder is it.

Other directories/files should have the same security context as the parent directory, like with /opt.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Is this correct?

Do the paths have any other purpose other than defining the default security context?

No, and they are not part of the kernel policy, only used by userspace programs like setfiles, udev, package managers like rpm/dpkg, etc.

Yes, the file belongs to selinux-policy-targeted