Skip to contentSkip to conversation

what to do with matchpathcon on S_IFCHR, S_IFBLK, hard links and fifos

DISCUSSION Luke Kenneth Casson Leighton 2 participants 5 messages Sep 1, 2004 – Sep 2, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

when using matchpathcon(), is there anything special that should be done for the above filetypes, or should the mode_t argument just be passed through and let libselinux worry about it?

ta,

l.

Signature · 13 lines
--
Truth, honesty and respect are rare commodities that all spring from
the same well: Love.  If you love yourself and everyone and everything
around you, funnily and coincidentally enough, life gets a lot better.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 3 lines · Luke Kenneth Casson Leighton

when using matchpathcon(), is there anything special that should be done for the above filetypes, or should the mode_t argument just be passed through and let libselinux worry about it?

Pass the mode; matchpathcon will take (mode & S_IFMT) and compare it with the file type specified in file_contexts (-b, -c, -d, -p, -l, -s, --, or nothing to match any file type).

Multiple hard links are a separate issue; setfiles keeps track of inode->specification mappings as it traverses a filesystem and detects conflicts, but matchpathcon can't do that obviously.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 8 lines · Stephen Smalley
Quoted 3 lines · Luke Kenneth Casson Leighton

when using matchpathcon(), is there anything special that should be done for the above filetypes, or should the mode_t argument just be passed through and let libselinux worry about it?

Pass the mode; matchpathcon will take (mode & S_IFMT) and compare it with the file type specified in file_contexts (-b, -c, -d, -p, -l, -s, --, or nothing to match any file type).

ta stephen.

okay, second question, if i may.

if i have set up file contexts on some files in a temporary directory (of course, using matchpathcon to set the context of where the file is _going_ to be not where it _is_), then will the "/bin/mv" command preserve those file contexts even across filesystem boundaries - without any extra arguments?

if so i don't have to patch dpkg's use of mv, which would be good.

ta,

l.

Signature · 13 lines
--
Truth, honesty and respect are rare commodities that all spring from
the same well: Love.  If you love yourself and everyone and everything
around you, funnily and coincidentally enough, life gets a lot better.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 7 lines · Luke Kenneth Casson Leighton

okay, second question, if i may.

if i have set up file contexts on some files in a temporary directory (of course, using matchpathcon to set the context of where the file is _going_ to be not where it _is_), then will the "/bin/mv" command preserve those file contexts even across filesystem boundaries - without any extra arguments?

With a SELinux-patched coreutils, yes; mv attempts to preserve the security context on the file even when moving across filesystem boundaries. But it cannot always succeed, e.g. the filesystem may not support xattrs or the policy may deny access due to file create permission or filesystem associate permission.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 7 lines · Luke Kenneth Casson Leighton

okay, second question, if i may.

if i have set up file contexts on some files in a temporary directory (of course, using matchpathcon to set the context of where the file is _going_ to be not where it _is_), then will the "/bin/mv" command preserve those file contexts even across filesystem boundaries - without any extra arguments?

Quoted 5 lines

With a SELinux-patched coreutils, yes; mv attempts to preserve the security context on the file even when moving across filesystem boundaries. But it cannot always succeed, e.g. the filesystem may not support xattrs or the policy may deny access due to file create permission or filesystem associate permission.

... okay [this is for what i am considering for dpkg].

so in that case, dpkg's policy file may need updating:
unlikely as it already allows files to be mv'd.

ta.

l.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.