Skip to contentSkip to conversation

Where's the class defined in file_contexts*

DISCUSSION dE 4 participants 5 messages Jul 1, 2014 SELinux security module

lore
Share & tools
lore

dE

author
#0 lore raw

The default security context of a object also depends on it's class.

I was looking at etc/selinux/<SELINUXTYPE>/contexts/files/file_contexts*, but I couldn't see any definition of a class.

Also semanage fcontext doesn't have an option define a class. Entries are based only on files and directories.

If you get red text in this email please notify.

#1 lore raw

It is defined through the "middle" column. For instance, -- is a regular file, -l a symlink, etc.

These can de defined with "semanage fcontext" as well.

Wkr,
Sven

Quoted 16 lines · dE

The default security context of a object also depends on it's class.

I was looking at etc/selinux/<SELINUXTYPE>/contexts/files/file_contexts*, but I couldn't see any definition of a class.

Also semanage fcontext doesn't have an option define a class. Entries are based only on files and directories.

If you get red text in this email please notify.
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

#2 lore raw
In reply to dE
Quoted 9 lines · dE

The default security context of a object also depends on it's class.

I was looking at etc/selinux/<SELINUXTYPE>/contexts/files/file_contexts*, but I couldn't see any definition of a class.

Also semanage fcontext doesn't have an option define a class. Entries are based only on files and directories.

Quoted 7 lines

If you get red text in this email please notify.
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

I believe the answer to your question is:

man semanage-fcontext
...
-f [{a,f,d,c,b,s,l,p}], --ftype [{a,f,d,c,b,s,l,p}]
File Type. This is used with fcontext. Requires a file
type as shown in the mode field by ls, e.g. use 'd' to match only directories
or 'f' to match only regular files. The following
file type options can be passed: f (regular file),d (directory),c (character
device), b (block device),s (socket),l (symbolic link),p
(named pipe). If you do not specify a file type, the file type will
default to "all files".

#4 lore raw
In reply to dE
Quoted 8 lines · dE

The default security context of a object also depends on it's class.

I was looking at etc/selinux/<SELINUXTYPE>/contexts/files/file_contexts*, but I couldn't see any definition of a class.

Also semanage fcontext doesn't have an option define a class. Entries are based only on files and directories.

semanage support -f

only file object classes apply to file object context specifications obviously.

file: --
dir: -d
symbolic link: -l
named pipe: -p
sock file: -s

semanage fcontext -a ... -f -d "/test/mydir"
semanage fcontext -a ...-f -s "/test/mysocket"
semanage fcontext -a ... -f -- "/test/myfile"
... etc ...

if the file object context spec applies to any file object then you need not specify the class:

semanage fcontext -a ... "/test/anyfileobjects(/.*)?"

So in file_contexts look for -- -d -s -l -p, if none of those are specified then the spec applies to any file object class

Quoted 7 lines

If you get red text in this email please notify.
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

author
#3 lore raw
In reply to Daniel J Walsh
Quoted 19 lines · Daniel J Walsh
Quoted 9 lines · dE

The default security context of a object also depends on it's class.

I was looking at etc/selinux/<SELINUXTYPE>/contexts/files/file_contexts*, but I couldn't see any definition of a class.

Also semanage fcontext doesn't have an option define a class. Entries are based only on files and directories.

Quoted 7 lines

If you get red text in this email please notify.
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

I believe the answer to your question is:

Quoted 11 lines

man semanage-fcontext
...
-f [{a,f,d,c,b,s,l,p}], --ftype [{a,f,d,c,b,s,l,p}]
File Type. This is used with fcontext. Requires a file
type as shown in the mode field by ls, e.g. use 'd' to match only directories
or 'f' to match only regular files. The following
file type options can be passed: f (regular file),d (directory),c (character
device), b (block device),s (socket),l (symbolic link),p
(named pipe). If you do not specify a file type, the file type will
default to "all files".

Thanks everyone for clarifying this.

I didnt know there existed man pages for semanage-*. It's not there in Fedora 19.