Here are some bits and pieces on SELINUX:
How to view the current SELinux status?
$sestatus
Where is main configuration file?
/etc/selinux/config
How to set booleans?
$setsebool -P httpd_read_user_content 1
or,
$semanage boolean -m --on httpd_read_user_content
How to list booleans?
$getsebool httpd_read_user_content
or,
$semanage boolean -l |grep httpd_read_user_content
How to allow the Apache HTTP server to provide service on port 9876?
$semanage port -a -t http_port_t -p tcp 9876
How to allow the Apache HTTP server to connect to your database server?
$semanage boolean -m --on httpd_can_network_connect_db
How to allow the Apache HTTP server to send mail?
$semanage boolean -m --on httpd_can_sendmail
How to execute multiple commands within a single transaction?
$semanage -i command-file
How to change the security context (temporarily) on a file/directory?
$chcon -t my_type_t /path/to/file # on single file
$chcon -R -t my_type_t /path/to/directory # recursively on directory
How to change the security context (persistently) on a file/directory?
$semanage fcontext -a -t my_type_t /path/to/file
# this will add the specified rule to the local context file, then label it
$restorecon -v /path/to/myfile
How to check/correct the security context on filesystems?
$fixfiles -v check /path/to/file_or_directory # check only
$fixfiles -v restore /path/to/file_or_directory # restore/correct
How to restore default security contexts of a directory tree?
$restorecon -Rv /path/to/the/directory
How to relabel complete filesystem?
$touch /.autorelabel # using init
$reboot
or,
$fixfiles restore # using fixfiles
How to preserve file security contextx when copying?
$cp --preserve=context /path/to/src /path/to/dst
How to change file security contextx when copying?
$install --context=new_context /path/to/src /path/to/dst
How to create archives that retain security contexts?
$tar --selinux -cvzf archive.tgz /path/to/directory # create archive
$tar --selinux -xvzf archive.tgz # extract files from archive
# star should be used, if option selinux is not supported in tar
How to mount a device with a specific security context?
$mount -o context=SELinux_user:role:type:level device dir
How to start SELINUX troubleshooting tool?
$sealert -b
Where is log file?
/var/log/audit/audit.log #audit on
or,
/var/log/messages #audit off
How to add new rules regarding xxxx to policy?
$grep xxxx /var/log/audit/audit.log | audit2allow -M xxxxlocal
$semodule -i xxxxlocal.pp
Hot to start the SELinux management GUI tool?
$system-config-selinux
# we need to install package policycoreutils-gui first
No comments:
Post a Comment