Wednesday 11 November 2015

Fixing deleted /var/run link and restoring SELinux permissions - CentOS 7

So some idiot with sudo permissions deleted the symlink /var/run. To restore it, log on to another system and find out the permissions of this link:
# ls -ld /var/run
lrwxrwxrwx. 1 root root 6 Feb 25  2015 /var/run -> ../run
# ls -Z /var/run
lrwxrwxrwx. root root system_u:object_r:var_run_t:s0   /var/run -> ../run
#
Log on to broken system as root and do the following:
# cd /var
# ln -s ../run run
# chcon -h system_u:object_r:var_run_t:s0 run
# ls -Z run
lrwxrwxrwx. root root system_u:object_r:var_run_t:s0   /var/run -> ../run