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
A journal on information technology: things I studied, worked, thought, but can't stay in my memory.
Showing posts with label security. Show all posts
Showing posts with label security. Show all posts
Saturday, September 21, 2013
Thursday, July 4, 2013
A quick and simple way to wipe a hard drive
For various reasons, it is necessary to wipe hard drives before disposing them. Writing disk with all zeros should suffice most occasions. This can be done as:
dd if=/dev/zero of=/dev/sdXY
where /dev/sdXY is the device name of the hard drive to work on. To get a better performance, we may need to set bs option, e.g.,
dd if=/dev/zero of=/dev/sdb1 bs=10M
to make dd read and write in 10M bytes at a time.
dd if=/dev/zero of=/dev/sdXY
where /dev/sdXY is the device name of the hard drive to work on. To get a better performance, we may need to set bs option, e.g.,
dd if=/dev/zero of=/dev/sdb1 bs=10M
to make dd read and write in 10M bytes at a time.
Monday, April 22, 2013
poor men's PGP
I just finished the pmPGP, a CLI for sending/receiving openPGP mime messages.
The pmPGP is based on python and gnupg; it supports sending emails in the following formats:
The pmPGP is based on python and gnupg; it supports sending emails in the following formats:
- plain -- regular email
- sign -- RFC3156
- encrypt -- RFC3156
- sign-encrypt -- RFC3156
- Sencrypt -- Symmetric encryption (for fun and personal usage)
- sign-Sencrypt -- (for fun and personal usage)
Poor man may use pmPGP to store/backup files on email servers.Sounds interesting? Get it from:
Subscribe to:
Posts (Atom)