SELinux

Gehasst oder Geliebt... hmm... das Erstere trifft wohl bei den meisten Leuten eher zu. Schade eigentlich, denn Linux ohne SELinux ist wie Autofahren ohne Sicherheitsgurte. Wie dem auch sei, hier ein paar Tricks im Umgang mit SELlinux.

 

# selinux
The goal of this document is to write your own module, which seems to simple as you can see accoring this
example :
grep centrifydc /var/log/audit/audit.log | audit2allow -M centrifymod
which will collect the messages related to centrifydc and create a module named centrifymod.
After this you can load the module using
semodule -i centrifymod.pp
Run the command "semodule -l" and confirm if the module loaded properly and then check if the AVC denial
messages still exists or not.
semodule -l

##########
#
# schaune ob ein Port offen/zugaenglich ist :
#
#########
semanage port -l | grep syslog


#
# check_mem.pl geht nicht ... hier die module dazu
#
module checkmem1 1.0;

require {
        type nrpe_t;
        type usr_t;
        class file getattr;
}

#============= nrpe_t ==============
allow nrpe_t usr_t:file getattr;
#
#
module checkmem2 1.0;

require {
        type nrpe_t;
        type usr_t;
        class file read;
}

#============= nrpe_t ==============
allow nrpe_t usr_t:file read;
#

module checkmem3 1.0;

require {
        type nrpe_t;
        type usr_t;
        class file { read open };
}

#============= nrpe_t ==============
allow nrpe_t usr_t:file open;
##!!!! This avc is allowed in the current policy
#
allow nrpe_t usr_t:file read;
#


####################################
#
# Context aendern
#
###################################
chcon --reference=negate check_mem.pl

# permanent aendern, auch bei restorecon:
# icinga / nagios / nrpe
semanage fcontext -a -t nagios_system_plugin_exec_t '/usr/lib64/nagios/plugins/check_mem.pl'
semanage fcontext -a -t nagios_unconfined_plugin_exec_t '/usr/lib64/nagios/plugins/check_ftp'

#########################
#
# habe die Erfrahrung gemacht, dass man auch mit egrep im audit.log suchen kann.
# somit werden mehrere Events erfasst und es kann sein, dass man so schneller zum Ziel kommt ;-)
#
##########################