Sunday, 21 August 2016

Recovering from a 'chmod -r 777 /'

Running a 'chmod -r 777 /' will have catastrophic results on the functioning of any solaris system.
This will prevent most of the OS services & functions from working correctly including ssh & the server will enter maintenance mode if rebooted.
It happened with me a few days ago & this post is about the tasks performed to get the system back up to a stable state.

The first corrective action was to restore /etc to the default mask i.e 755 for directories & 644 for files.

find /etc -type d -exec chmod 755 {} \;
find /etc -type f -exec chmod 644 {} \;

The next critical task was to restore services & associated binaries to their expected permissions & ownerships. This task was accomplished with pkgchk command.
pkgchk checks the accuracy of installed files or, by using the  -l  option, displays information about package files. pkgchk checks the  integrity of  directory  structures  and files. Discrepancies are written to standard error along with a detailed explanation of the problem.

To fix the permissions I ran
# /usr/sbin/pkgchk -f 
This command correct file attributes if possible. (permission, datestamp, ownership) 

then to check the binaries: 
# /usr/sbin/pkgchk -n 

After that reboot the server
# /usr/sbin/init 6 

Once the server is up, check the status of smf services: 
# /usr/bin/svcs -xv

After the reboot the services were operating optimally & the server was accessible remotely via ssh. There were some other changes needed which I came across via trial & error but pkgchk did most of the heavy lifting. 

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...