Creating SELinux Context Type in RHEL5
Our environment is running RHEL 5 and there are still a handful of servers with SELinux set to permissive mode. I've been going through the audit logs and generating policy entries as needed, but I have run into a situation where the context type I need does not exist.
In order to determine what policies to generate, I've been comparing some of the AVC denial messages on my RHEL 5 boxes with some of the newer policies (CentOS 6.3 and Fedora 17) to find out if there are any entries to address the denials I'm getting. In many cases, the denials I'm getting are set to "dontaudit" in newer OS versions.
What I'm running up against now is the fact that we have VMWare Tools on a few servers and that is getting flagged. When I look at my CentOS system, there are several file contexts for VMWare-related files. In the RHEL 5 policies, however, these contexts do not exist, so I can't create file contexts using 'semanage' because the 'type' is not recognized.
How do I create a 'type' so that I can assign that type to a group of files on my server? I haven't been able to find much about this, so I thought I'd try posting something here.
Thanks in advance for any suggestions!
Responses
file_t indicates you have a file with no labels on it. /var/run/vmware/vmumguestagent.pid does not have a label.
On my Fedora 18 box, matchpathcon /var/run/vmware/vmum-guestagent.pid
/var/run/vmware/vmum-guestagent.pid system_u:object_r:vmware_host_pid_t:s0
Indicates that this pid file should be labeled vmware_host_pid_t.
It is probably best if you just delete the file/directory and let vmware recreate it with a label.
All of these AVC's look like leaked file descriptors.
http://danwalsh.livejournal.com/53603.html
ifconfig seems to be appending content into /usr/share/vmum-ga/getInventoryErrors, which might work if it was labeled var_log_t.
chcon -t var_log_t /usr/share/vmum-ga/getInventoryErrors
If this eliminates the AVC ,you could make this permanent with the following command:
semanage fcontext -a -t var_log_t /usr/share/vmum-ga/getInventoryErrors
Dan, if you read my blog above it has a description of what is a leaked file descriptor...
Bottom line, when programmers write code that opens files or sockets it creates a file descriptor, by default these file descritors are leaked to all programs that are executed by the current program. SELinux looks at each of these leaked file descriptors and determins if the new process is allowed to use them. If not SELinux closes the descriptor and prints an ugly message in the log file. Programmers can fix there code by "closing the file descriptors on exec", and then the problem goes away.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
