/usr/sbin
NameSizeModeActions
accessdb157920755editdlrm
addgnupghome30790755editdlrm
addpart155200755editdlrm
adduser1411440755editdlrm
agetty580720755editdlrm
alternatives405440755editdlrm
anacron404640755editdlrm
apachectl48080755editdlrm
applygnupgdefaults22210755editdlrm
arp647280755editdlrm
arping279040755editdlrm
arptables2369600755editdlrm
arptables-nft2369600755editdlrm
arptables-nft-restore2369600755editdlrm
arptables-nft-save2369600755editdlrm
arptables-restore2369600755editdlrm
arptables-save2369600755editdlrm
atd320080755editdlrm
atrun700755editdlrm
auditctl528240755editdlrm
auditd1403360755editdlrm
augenrules41460755editdlrm
aureport1231920755editdlrm
ausearch1231600755editdlrm
autrace196320750editdlrm
avcstat157200755editdlrm
badblocks362000755editdlrm
blkdeactivate163550555editdlrm
blkdiscard237600755editdlrm
blkid528480755editdlrm
blkmapd403600755editdlrm
blkzone363040755editdlrm
blockdev321680755editdlrm
bridge1340880755editdlrm
cache_check30462960755editdlrm
cache_dump30462960755editdlrm
cache_metadata_size30462960755editdlrm
cache_repair30462960755editdlrm
cache_restore30462960755editdlrm
cache_writeback30462960755editdlrm
capsh319600755editdlrm
cfdisk986560755editdlrm
chcpu321760755editdlrm
chgpasswd612000755editdlrm
chkconfig448320755editdlrm
chpasswd569680755editdlrm
chronyd3825440755editdlrm
chroot405040755editdlrm
clock612000755editdlrm
consoletype156480755editdlrm
convertquota706640755editdlrm
cracklib-check154720755editdlrm
cracklib-format2550755editdlrm
cracklib-packer154720755editdlrm
cracklib-unpacker154640755editdlrm
create-cracklib-dict9940755editdlrm
crond779920755editdlrm
ctrlaltdel155520755editdlrm
ctstat241600755editdlrm
dcb969600755editdlrm
ddns-confgen279120755editdlrm
debugfs2386240755editdlrm
delpart154800755editdlrm
depmod1695440755editdlrm
devlink1698160755editdlrm
dmeventd530320555editdlrm
dmfilemapd238560555editdlrm
dmsetup1605360555editdlrm
dmstats1605360555editdlrm
dnssec-cds488160755editdlrm
dnssec-checkds9240755editdlrm
dnssec-coverage9260755editdlrm
dnssec-dsfromkey403840755editdlrm
dnssec-importkey362880755editdlrm
dnssec-keyfromlabel403680755editdlrm
dnssec-keygen485840755editdlrm
dnssec-keymgr9220755editdlrm
dnssec-revoke321680755editdlrm
dnssec-settime485760755editdlrm
dnssec-signzone981840755editdlrm
dnssec-verify322000755editdlrm
dosfsck865920755editdlrm
dosfslabel409760755editdlrm
dovecot1474800755editdlrm
dovecot_cpshutdown33440755editdlrm
dpll493120755editdlrm
dumpe2fs320400755editdlrm
e2freefrag155520755editdlrm
e2fsck3646320755editdlrm
e2image444560755editdlrm
e2label1069680755editdlrm
e2mmpstatus320400755editdlrm
e2undo237120755editdlrm
e4crypt320480755editdlrm
e4defrag320080755editdlrm
ebtables2369600755editdlrm
ebtables-nft2369600755editdlrm
ebtables-nft-restore2369600755editdlrm
ebtables-nft-save2369600755editdlrm
ebtables-restore2369600755editdlrm
ebtables-save2369600755editdlrm
ebtables-translate2369600755editdlrm
edquota916480755editdlrm
efibootdump244400755editdlrm
efibootmgr462640755editdlrm
era_check30462960755editdlrm
era_dump30462960755editdlrm
era_invalidate30462960755editdlrm
era_restore30462960755editdlrm
ether-wake514480755editdlrm
ethtool10126960755editdlrm
exicyclog113650755editdlrm
exigrep117100755editdlrm
exim17288484755editdlrm
eximstats1525460755editdlrm
exim_checkaccess49430755editdlrm
exim_dbmbuild230400755editdlrm
exim_dumpdb418720755editdlrm
exim_fixdb463600755editdlrm
exim_lock233280755editdlrm
exim_tidydb334720755editdlrm
exinext82170755editdlrm
exiqgrep67390755editdlrm
exiqsumm64430755editdlrm
exiwhat45240755editdlrm
exportfs701120755editdlrm
faillock237360755editdlrm
fatlabel409760755editdlrm
fcgistarter253040755editdlrm
fdformat237440755editdlrm
fdisk1147600755editdlrm
filefrag196800755editdlrm
findfs155200755editdlrm
firewalld99890755editdlrm
fix-info-dir80370755editdlrm
fixfiles123870755editdlrm
fsadm246020555editdlrm
fsck445920755editdlrm
fsck.cramfs321280755editdlrm
fsck.ext23646320755editdlrm
fsck.ext33646320755editdlrm
fsck.ext43646320755editdlrm
fsck.fat865920755editdlrm
fsck.minix570480755editdlrm
fsck.msdos865920755editdlrm
fsck.vfat865920755editdlrm
fsck.xfs25980755editdlrm
fsfreeze155120755editdlrm
fstrim445440755editdlrm
fuser420720755editdlrm
g13-syshelp907280755editdlrm
genhomedircon328080755editdlrm
genhostid156480755editdlrm
genl1332720755editdlrm
getcap154960755editdlrm
getenforce156400755editdlrm
getpcaps154880755editdlrm
getpidprevcon156560755editdlrm
getpolicyload156480755editdlrm
getsebool156640755editdlrm
groupadd704240755editdlrm
groupdel660800755editdlrm
groupmems571120755editdlrm
groupmod745040755editdlrm
grpck611920755editdlrm
grpconv528000755editdlrm
grpunconv527680755editdlrm
grub2-bios-setup17499040755editdlrm
grub2-get-kernel-settings27460755editdlrm
grub2-install20685200755editdlrm
grub2-macbless17288720755editdlrm
grub2-mkconfig94310755editdlrm
grub2-probe17459840755editdlrm
grub2-reboot48140755editdlrm
grub2-set-bootflag154564755editdlrm
grub2-set-default35380755editdlrm
grub2-set-password28090755editdlrm
grub2-setpassword28090755editdlrm
grub2-switch-to-blscfg90240755editdlrm
grubby2600755editdlrm
gssproxy1278880755editdlrm
halt3055760755editdlrm
htcacheclean540720755editdlrm
httpd11397200755editdlrm
hwclock612000755editdlrm
iconvconfig324320755editdlrm
ifconfig808800755editdlrm
ifdown10970755editdlrm
ifenslave243040755editdlrm
ifstat405520755editdlrm
ifup10660755editdlrm
imunify-notifier103256160755editdlrm
init980400755editdlrm
insmod1695440755editdlrm
install-info1092560755editdlrm
installkernel3230755editdlrm
intel_sdsi229680755editdlrm
ip7929040755editdlrm
ip6tables2369600755editdlrm
ip6tables-nft2369600755editdlrm
ip6tables-nft-restore2369600755editdlrm
ip6tables-nft-save2369600755editdlrm
ip6tables-restore2369600755editdlrm
ip6tables-restore-translate2369600755editdlrm
ip6tables-save2369600755editdlrm
ip6tables-translate2369600755editdlrm
ipmaddr199120755editdlrm
ipset156400755editdlrm
ipset-translate156400755editdlrm
iptables2369600755editdlrm
iptables-nft2369600755editdlrm
iptables-nft-restore2369600755editdlrm
iptables-nft-save2369600755editdlrm
iptables-restore2369600755editdlrm
iptables-restore-translate2369600755editdlrm
iptables-save2369600755editdlrm
iptables-translate2369600755editdlrm
iptunnel199680755editdlrm
irqbalance659920755editdlrm
irqbalance-ui405360755editdlrm
kexec1972160755editdlrm
key.dns_resolver321040755editdlrm
kpartx486640755editdlrm
lchage237200755editdlrm
ldattach278800755editdlrm
ldconfig11764640755editdlrm
lgroupadd154800755editdlrm
lgroupdel154720755editdlrm
lgroupmod236800755editdlrm
lid195920755editdlrm
lnewusers236800755editdlrm
lnstat241600755editdlrm
load_policy154800755editdlrm
logrotate979600755editdlrm
logsave155520755editdlrm
losetup738160755editdlrm
lpasswd236800755editdlrm
lshw8740640755editdlrm
lsmod1695440755editdlrm
lspci999120755editdlrm
luseradd236800755editdlrm
luserdel154800755editdlrm
lusermod236880755editdlrm
lvchange28310720555editdlrm
lvconvert28310720555editdlrm
lvcreate28310720555editdlrm
lvdisplay28310720555editdlrm
lvextend28310720555editdlrm
lvm28310720555editdlrm
lvmconfig28310720555editdlrm
lvmdevices28310720555editdlrm
lvmdiskscan28310720555editdlrm
lvmdump103780555editdlrm
lvmpolld2153440555editdlrm
lvmsadc28310720555editdlrm
lvmsar28310720555editdlrm
lvm_import_vdo237080555editdlrm
lvreduce28310720555editdlrm
lvremove28310720555editdlrm
lvrename28310720555editdlrm
lvresize28310720555editdlrm
lvs28310720555editdlrm
lvscan28310720555editdlrm
makedumpfile4422080755editdlrm
matchpathcon156800755editdlrm
mii-diag247760755editdlrm
mii-tool284480755editdlrm
mkdict2550755editdlrm
mkdosfs537680755editdlrm
mkdumprd124180755editdlrm
mke2fs1357120755editdlrm
mkfs155360755editdlrm
mkfs.cramfs362240755editdlrm
mkfs.ext21357120755editdlrm
mkfs.ext31357120755editdlrm
mkfs.ext41357120755editdlrm
mkfs.fat537680755editdlrm
mkfs.minix446000755editdlrm
mkfs.msdos537680755editdlrm
mkfs.vfat537680755editdlrm
mkfs.xfs4615920755editdlrm
mkhomedir_helper237680755editdlrm
mklost+found154800755editdlrm
mksquashfs2023600755editdlrm
mkswap486400755editdlrm
modinfo1695440755editdlrm
modprobe1695440755editdlrm
modsec-sdbm-util343680750editdlrm
mount.fuse157040755editdlrm
mount.fuse3198320755editdlrm
mount.nfs1029364755editdlrm
mount.nfs41029364755editdlrm
mountstats435190755editdlrm
mysqld566875760755editdlrm
named5581040755editdlrm
named-checkconf403440755editdlrm
named-checkzone402880755editdlrm
named-compilezone402880755editdlrm
named-journalprint154960755editdlrm
named-nzd2nzf154800755editdlrm
nameif159520755editdlrm
NetworkManager38939280755editdlrm
newusers908320755editdlrm
nfsconf408160755editdlrm
nfsdcld572080755editdlrm
nfsdclddb102300755editdlrm
nfsdclnts92710755editdlrm
nfsdcltrack408720755editdlrm
nfsidmap238560755editdlrm
nfsiostat239100755editdlrm
nfsref445600755editdlrm
nfsstat391920755editdlrm
nft278240755editdlrm
nologin155200755editdlrm
nscd1668560755editdlrm
nsec3hash155600755editdlrm
nstat320880755editdlrm
packer154720755editdlrm
pam_console_apply445520755editdlrm
pam_namespace_helper4710755editdlrm
pam_timestamp_check154964755editdlrm
paperconfig41730755editdlrm
parted987040755editdlrm
partprobe157040755editdlrm
partx612000755editdlrm
pdata_tools30462960755editdlrm
pdns_server61628000755editdlrm
pidof238880755editdlrm
ping914720755editdlrm
ping6914720755editdlrm
pivot_root155200755editdlrm
plipconfig157200755editdlrm
poweroff3055760755editdlrm
pure-authd235680755editdlrm
pure-certd234720755editdlrm
pure-config.pl47550755editdlrm
pure-ftpd1813760755editdlrm
pure-ftpwho272160755editdlrm
pure-mrtginfo148960755editdlrm
pure-quotacheck231040755editdlrm
pure-uploadscript233760755editdlrm
pvchange28310720555editdlrm
pvck28310720555editdlrm
pvcreate28310720555editdlrm
pvdisplay28310720555editdlrm
pvmove28310720555editdlrm
pvremove28310720555editdlrm
pvresize28310720555editdlrm
pvs28310720555editdlrm
pvscan28310720555editdlrm
pwck569360755editdlrm
pwconv485840755editdlrm
pwhistory_helper196560755editdlrm
pwunconv485440755editdlrm
quotacheck958640755editdlrm
quotaoff580320755editdlrm
quotaon580320755editdlrm
quotastats157040755editdlrm
rdisc321120755editdlrm
rdma1198720755editdlrm
readprofile238240755editdlrm
reboot3055760755editdlrm
repquota794160755editdlrm
request-key279440755editdlrm
resize2fs692640755editdlrm
resizepart239600755editdlrm
restorecon237440755editdlrm
restorecon_xattr154880755editdlrm
rfkill320960755editdlrm
rmmod1695440755editdlrm
rndc442880755editdlrm
rndc-confgen238160755editdlrm
rotatelogs390480755editdlrm
route673520755editdlrm
rpc.gssd902240755editdlrm
rpc.idmapd488800755editdlrm
rpc.mountd1357360755editdlrm
rpc.nfsd409600755editdlrm
rpc.statd827280755editdlrm
rpcbind613280755editdlrm
rpcctl96450755editdlrm
rpcdebug191040755editdlrm
rpcinfo364320755editdlrm
rsyslogd8262400755editdlrm
rtacct300480755editdlrm
rtcwake361040755editdlrm
rtkitctl156080755editdlrm
rtmon1290800755editdlrm
rtstat241600755editdlrm
runlevel3055760755editdlrm
runq17288484755editdlrm
runuser569440755editdlrm
sasldblistusers2156400755editdlrm
saslpasswd2156080755editdlrm
sefcontext_compile741200755editdlrm
selabel_digest156800755editdlrm
selabel_get_digests_all_partial_matches156960755editdlrm
selabel_lookup156720755editdlrm
selabel_lookup_best_match156800755editdlrm
selabel_partial_match156720755editdlrm
selinuxconlist156720755editdlrm
selinuxdefcon156720755editdlrm
selinuxenabled156400755editdlrm
selinuxexeccon156560755editdlrm
selinux_check_access156800755editdlrm
semanage416140755editdlrm
semodule328080755editdlrm
sendmail185122755editdlrm
service46230755editdlrm
sestatus236800755editdlrm
setcap154880755editdlrm
setenforce156640755editdlrm
setfiles237440755editdlrm
setpci321040755editdlrm
setquota835360755editdlrm
setsebool196080755editdlrm
sfdisk1064800755editdlrm
showmount158480755editdlrm
shutdown3055760755editdlrm
slattach384720755editdlrm
sm-notify530160755editdlrm
smartctl8743280755editdlrm
smartd6302400755editdlrm
ss1344720755editdlrm
sshd4166640755editdlrm
sssd733280755editdlrm
sss_cache360960755editdlrm
start-statd10270755editdlrm
start-stop-daemon498160755editdlrm
suexec385044755editdlrm
sulogin444400755editdlrm
sw-engine-fpm253146800755editdlrm
swaplabel196480755editdlrm
swapoff238240755editdlrm
swapon443520755editdlrm
switch_root237600755editdlrm
sysctl322480755editdlrm
tc6554560755editdlrm
tcpdump13402560755editdlrm
tcpslice280480755editdlrm
telinit3055760755editdlrm
thin_check30462960755editdlrm
thin_delta30462960755editdlrm
thin_dump30462960755editdlrm
thin_ls30462960755editdlrm
thin_metadata_pack30462960755editdlrm
thin_metadata_size30462960755editdlrm
thin_metadata_unpack30462960755editdlrm
thin_migrate30462960755editdlrm
thin_repair30462960755editdlrm
thin_restore30462960755editdlrm
thin_rmap30462960755editdlrm
thin_trim30462960755editdlrm
tipc950240755editdlrm
tmpwatch368960755editdlrm
tracepath196800755editdlrm
tracepath6196800755editdlrm
tsig-keygen279120755editdlrm
tune2fs1069680755editdlrm
udevadm6019600755editdlrm
umount.nfs1029364755editdlrm
umount.nfs41029364755editdlrm
unix_chkpwd238484755editdlrm
unix_update320800700editdlrm
unsquashfs1165360755editdlrm
update-alternatives405440755editdlrm
update-pciids17570755editdlrm
update-smart-drivedb238850755editdlrm
useradd1411440755editdlrm
userdel909680755editdlrm
usermod1327760755editdlrm
validatetrans156560755editdlrm
vdpa367360755editdlrm
vgcfgbackup28310720555editdlrm
vgcfgrestore28310720555editdlrm
vgchange28310720555editdlrm
vgck28310720555editdlrm
vgconvert28310720555editdlrm
vgcreate28310720555editdlrm
vgdisplay28310720555editdlrm
vgexport28310720555editdlrm
vgextend28310720555editdlrm
vgimport28310720555editdlrm
vgimportclone28310720555editdlrm
vgimportdevices28310720555editdlrm
vgmerge28310720555editdlrm
vgmknodes28310720555editdlrm
vgreduce28310720555editdlrm
vgremove28310720555editdlrm
vgrename28310720555editdlrm
vgs28310720555editdlrm
vgscan28310720555editdlrm
vgsplit28310720555editdlrm
vigr595520755editdlrm
vipw595520755editdlrm
visudo2736800755editdlrm
vmcore-dmesg279520755editdlrm
weak-modules343840755editdlrm
whmapi034781120755editdlrm
whmapi134781120755editdlrm
whmlogin23900755editdlrm
wipefs402240755editdlrm
xfs_admin21780755editdlrm
xfs_bmap6990755editdlrm
xfs_copy948400755editdlrm
xfs_db7250720755editdlrm
xfs_estimate155280755editdlrm
xfs_freeze8040755editdlrm
xfs_fsr445520755editdlrm
xfs_growfs446800755editdlrm
xfs_info12980755editdlrm
xfs_io2074560755editdlrm
xfs_logprint903760755editdlrm
xfs_mdrestore279360755editdlrm
xfs_metadump7860755editdlrm
xfs_mkfile10440755editdlrm
xfs_ncheck6890755editdlrm
xfs_quota943120755editdlrm
xfs_repair7027040755editdlrm
xfs_rtcp196000755editdlrm
xfs_spaceman448320755editdlrm
xqmstats156960755editdlrm
xtables-monitor2369600755editdlrm
xtables-nft-multi2369600755editdlrm
zic610560755editdlrm
zramctl572080755editdlrm
Edit: /usr/sbin/fixfiles (12387B)
#!/usr/bin/bash # fixfiles # # Script to restore labels on a SELinux box # # Copyright (C) 2004-2013 Red Hat, Inc. # Authors: Dan Walsh # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA set -o nounset # # seclabel support was added in 2.6.30. This function will return a positive # number if the current kernel version is greater than 2.6.30, a negative # number if the current is less than 2.6.30 and 0 if they are the same. # function useseclabel { VER=`uname -r` SUP=2.6.30 expr '(' "$VER" : '\([^.]*\)' ')' '-' '(' "$SUP" : '\([^.]*\)' ')' '|' \ '(' "$VER.0" : '[^.]*[.]\([^.]*\)' ')' '-' '(' "$SUP.0" : '[^.]*[.]\([^.]*\)' ')' '|' \ '(' "$VER.0.0" : '[^.]*[.][^.]*[.]\([^.]*\)' ')' '-' '(' "$SUP.0.0" : '[^.]*[.][^.]*[.]\([^.]*\)' ')' } # # Get all mount points that support labeling. Use the 'seclabel' field if it # is available. Else fall back to known fs types which likely support xattrs # and we know were not context mounted. # get_all_labeled_mounts() { FS="`cat /proc/self/mounts | sort | uniq | awk '{print $2}'`" for i in $FS; do if [ `useseclabel` -ge 0 ] then grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)seclabel(,|$)' && echo $i else grep " $i " /proc/self/mounts | grep -v "context=" | grep -E --silent '(ext[234]| ext4dev | gfs2 | xfs | jfs | btrfs )' && echo $i fi done } get_rw_labeled_mounts() { FS=`get_all_labeled_mounts | sort | uniq` for i in $FS; do grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)rw(,|$)' && echo $i done } get_ro_labeled_mounts() { FS=`get_all_labeled_mounts | sort | uniq` for i in $FS; do grep " $i " /proc/self/mounts | awk '{print $4}' | grep -E --silent '(^|,)ro(,|$)' && echo $i done } # # Get the default label returned from the kernel for a file with a label the # kernel does not understand # get_undefined_type() { SELINUXMNT=`grep selinuxfs /proc/self/mountinfo | head -1 | awk '{ print $5 }'` cat ${SELINUXMNT}/initial_contexts/unlabeled | secon -t } # # Get the default label for a file without a label # get_unlabeled_type() { SELINUXMNT=`grep selinuxfs /proc/self/mountinfo | head -1 | awk '{ print $5 }'` cat $SELINUXMNT/initial_contexts/file | secon -t } exclude_dirs_from_relabelling() { exclude_from_relabelling= if [ -e /etc/selinux/fixfiles_exclude_dirs ] then while read i do # skip blank line and comment # skip not absolute path # skip not directory [ -z "${i}" ] && continue [[ "${i}" =~ ^[[:blank:]]*# ]] && continue [[ ! "${i}" =~ ^/.* ]] && continue [[ ! -d "${i}" ]] && continue exclude_from_relabelling="$exclude_from_relabelling -e $i" done < /etc/selinux/fixfiles_exclude_dirs fi echo "$exclude_from_relabelling" } # # Set global Variables # fullFlag=0 BOOTTIME="" VERBOSE="-p" [ -t 1 ] || VERBOSE="" FORCEFLAG="" THREADS="" RPMFILES="" PREFC="" RESTORE_MODE="" BIND_MOUNT_FILESYSTEMS="" SETFILES=/sbin/setfiles RESTORECON=/sbin/restorecon FILESYSTEMSRW=`get_rw_labeled_mounts` FILESYSTEMSRO=`get_ro_labeled_mounts` SELINUXTYPE="targeted" if [ -e /etc/selinux/config ]; then . /etc/selinux/config FC=/etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts else FC=/etc/security/selinux/file_contexts fi # # Log all Read Only file systems # LogReadOnly() { if [ ! -z "$FILESYSTEMSRO" ]; then echo "Warning: Skipping the following R/O filesystems:" echo "$FILESYSTEMSRO" fi } # # Log directories excluded from relabelling by configuration file # LogExcluded() { for i in ${EXCLUDEDIRS//-e / }; do echo "skipping the directory $i" done } # # Find files newer then the passed in date and fix the label # newer() { DATE=$1 shift LogReadOnly for m in `echo $FILESYSTEMSRW`; do find $m -mount -newermt $DATE -print0 2>/dev/null | ${RESTORECON} ${FORCEFLAG} ${VERBOSE} ${THREADS} $* -i -0 -f - done; } # # Compare PREVious File Context to currently installed File Context and # run restorecon on all files affected by the differences. # diff_filecontext() { EXCLUDEDIRS="`exclude_dirs_from_relabelling`" for i in /sys /proc /mnt /var/tmp /var/lib/BackupPC /home /root /tmp; do [ -e $i ] && EXCLUDEDIRS="${EXCLUDEDIRS} -e $i"; done LogExcluded if [ -f ${PREFC} -a -x /usr/bin/diff ]; then TEMPFILE=`mktemp ${FC}.XXXXXXXXXX` test -z "$TEMPFILE" && exit PREFCTEMPFILE=`mktemp ${PREFC}.XXXXXXXXXX` sed -r -e 's,:s0, ,g' $PREFC | sort -u > ${PREFCTEMPFILE} sed -r -e 's,:s0, ,g' $FC | sort -u | /usr/bin/diff -b ${PREFCTEMPFILE} - | grep '^[<>]'|cut -c3-| grep ^/ | grep -Ev '(^/home|^/root|^/tmp)' | sed -r -e 's,[[:blank:]].*,,g' \ -e 's|\(([/[:alnum:]]+)\)\?|{\1,}|g' \ -e 's|([/[:alnum:]])\?|{\1,}|g' \ -e 's|\?.*|*|g' \ -e 's|\{.*|*|g' \ -e 's|\(.*|*|g' \ -e 's|\[.*|*|g' \ -e 's|\.\*.*|*|g' \ -e 's|\.\+.*|*|g' | # These two sorts need to be separate commands sort -u | sort -d | while read pattern ; do if ! echo "$pattern" | grep -q -f ${TEMPFILE} 2>/dev/null; then echo "$pattern"; case "$pattern" in *"*") echo "$pattern" | sed -e 's,^,^,' -e 's,\*$,,g' >> ${TEMPFILE};; esac; fi; done | ${RESTORECON} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} ${THREADS} $* -i -R -f -; rm -f ${TEMPFILE} ${PREFCTEMPFILE} fi } rpmlist() { rpm -q --qf '[%{FILESTATES} %{FILENAMES}\n]' "$1" | grep '^0 ' | cut -f2- -d ' ' [ ${PIPESTATUS[0]} != 0 ] && echo "$1 not found" >/dev/stderr } # unmount tmp bind mount before exit umount_TMP_MOUNT() { if [ -n "$TMP_MOUNT" ]; then umount "${TMP_MOUNT}${m}" || exit 130 rm -rf "${TMP_MOUNT}" || echo "Error cleaning up." fi exit 130 } fix_labels_on_mountpoint() { test -z ${TMP_MOUNT+x} && echo "Unable to find temporary directory!" && exit 1 mkdir -p "${TMP_MOUNT}${m}" || exit 1 mount --bind "${m}" "${TMP_MOUNT}${m}" || exit 1 ${SETFILES} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} ${THREADS} $* -q ${FC} -r "${TMP_MOUNT}" "${TMP_MOUNT}${m}" umount "${TMP_MOUNT}${m}" || exit 1 rm -rf "${TMP_MOUNT}" || echo "Error cleaning up." } export -f fix_labels_on_mountpoint # # restore # if called with -n will only check file context # restore () { OPTION=$1 shift # [-B | -N time ] if [ -n "$BOOTTIME" ]; then newer $BOOTTIME $* return fi # -C PREVIOUS_FILECONTEXT if [ "$RESTORE_MODE" == PREFC ]; then diff_filecontext $* return fi [ -x /usr/sbin/genhomedircon ] && /usr/sbin/genhomedircon EXCLUDEDIRS="`exclude_dirs_from_relabelling`" LogExcluded case "$RESTORE_MODE" in RPMFILES) for i in `echo "$RPMFILES" | sed 's/,/ /g'`; do rpmlist $i | ${RESTORECON} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} ${THREADS} $* -i -R -f - done ;; FILEPATH) ${RESTORECON} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} ${THREADS} $* -R -- "$FILEPATH" ;; *) if [ -n "${FILESYSTEMSRW}" ]; then LogReadOnly echo "${OPTION}ing `echo ${FILESYSTEMSRW}`" if [ -z "$BIND_MOUNT_FILESYSTEMS" ]; then ${SETFILES} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} $* -q ${THREADS} ${FC} ${FILESYSTEMSRW} else # we bind mount so we can fix the labels of files that have already been # mounted over for m in `echo $FILESYSTEMSRW`; do TMP_MOUNT="$(mktemp -p /run -d fixfiles.XXXXXXXXXX)" export SETFILES VERBOSE EXCLUDEDIRS FORCEFLAG THREADS FC TMP_MOUNT m if type unshare &> /dev/null; then unshare -m bash -c "fix_labels_on_mountpoint $*" || exit $? else trap umount_TMP_MOUNT EXIT fix_labels_on_mountpoint $* trap EXIT fi done; fi else echo >&2 "fixfiles: No suitable file systems found" fi if [ ${OPTION} != "Relabel" ]; then return fi echo "Cleaning up labels on /tmp" rm -rf /tmp/gconfd-* /tmp/pulse-* /tmp/orbit-* UNDEFINED=`get_undefined_type` || exit $? UNLABELED=`get_unlabeled_type` || exit $? find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) \( -type s -o -type p \) -delete find /tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /tmp {} \; find /var/tmp \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/tmp {} \; find /var/run \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /var/run {} \; [ ! -e /var/lib/debug ] || find /var/lib/debug \( -context "*:${UNLABELED}*" -o -context "*:${UNDEFINED}*" \) -exec chcon --no-dereference --reference /lib {} \; ;; esac } fullrelabel() { echo "Cleaning out /tmp" find /tmp/ -mindepth 1 -delete restore Relabel } relabel() { if [ -n "$RESTORE_MODE" -a "$RESTORE_MODE" != DEFAULT ]; then usage exit 1 fi if [ $fullFlag == 1 ]; then fullrelabel return fi echo -n " Files in the /tmp directory may be labeled incorrectly, this command can remove all files in /tmp. If you choose to remove files from /tmp, a reboot will be required after completion. Do you wish to clean out the /tmp directory [N]? " read answer if [ "$answer" = y -o "$answer" = Y ]; then fullrelabel else restore Relabel fi } process() { # # Make sure they specified one of the three valid commands # case "$1" in restore) restore Relabel;; check) VERBOSE="-v"; restore Check -n;; verify) VERBOSE="-v"; restore Verify -n;; relabel) relabel;; onboot) if [ -n "$RESTORE_MODE" -a "$RESTORE_MODE" != DEFAULT ]; then usage exit 1 fi > /.autorelabel || exit $? [ -z "$FORCEFLAG" ] || echo -n "$FORCEFLAG " >> /.autorelabel [ -z "$BOOTTIME" ] || echo -n "-N $BOOTTIME " >> /.autorelabel [ -z "$BIND_MOUNT_FILESYSTEMS" ] || echo -n "-M " >> /.autorelabel [ -z "$THREADS" ] || echo -n "$THREADS " >> /.autorelabel # Force full relabel if SELinux is not enabled selinuxenabled || echo -F > /.autorelabel echo "System will relabel on next boot" ;; *) usage exit 1 esac } usage() { echo $""" Usage: $0 [-v] [-F] [-M] [-f] [-T nthreads] relabel or Usage: $0 [-v] [-F] [-B | -N time ] [-T nthreads] { check | restore | verify } or Usage: $0 [-v] [-F] [-T nthreads] { check | restore | verify } dir/file ... or Usage: $0 [-v] [-F] [-T nthreads] -R rpmpackage[,rpmpackage...] { check | restore | verify } or Usage: $0 [-v] [-F] [-T nthreads] -C PREVIOUS_FILECONTEXT { check | restore | verify } or Usage: $0 [-F] [-M] [-B] [-T nthreads] onboot """ } if [ $# -eq 0 ]; then usage exit 1 fi set_restore_mode() { if [ -n "$RESTORE_MODE" ]; then # can't specify two different modes usage exit 1 fi RESTORE_MODE="$1" } # See how we were called. while getopts "N:BC:FfR:l:vMT:" i; do case "$i" in B) BOOTTIME=`/bin/who -b | awk '{print $3}'` set_restore_mode DEFAULT ;; N) BOOTTIME=$OPTARG set_restore_mode BOOTTIME ;; R) RPMFILES=$OPTARG set_restore_mode RPMFILES ;; C) PREFC=$OPTARG set_restore_mode PREFC ;; v) VERBOSE="-v" ;; l) # Old scripts use obsolete option `-l logfile` echo "Redirecting output to $OPTARG" exec >>"$OPTARG" 2>&1 ;; M) BIND_MOUNT_FILESYSTEMS="-M" ;; F) FORCEFLAG="-F" ;; f) fullFlag=1 ;; T) THREADS="-T $OPTARG" ;; *) usage exit 1 esac done # Move out processed options from arguments shift $(( OPTIND - 1 )) # Check for the command if [ $# -eq 0 ]; then usage exit 1 fi command="$1" # Move out command from arguments shift if [ $# -gt 0 ]; then set_restore_mode FILEPATH while [ $# -gt 0 ]; do FILEPATH="$1" process "$command" || exit $? shift done else process "$command" fi