when RPM can save your ass

There are very rare times I like the RPM package management or a redhat system. But today this save my ass. Someone or something did a “chmod 777 /” on one our machines…

This normaly leads to immediate excution of this person. But anyhow I had to deal with this and recover the machine. Almost none of the system daemons startet and even a console login wasn’t possible due to wrong permissions of vital files.

The solution was a very simple shell script. The RPM database contains information about the permission of all packages. These permission can be re-applied:

#!/bin/sh -x

for package in `/bin/rpm -qa`; do
/bin/rpm -qv --setperms $package

So simply boot in single user mode and create this little script an run it. This should repair all the necessary permissioins.

Autor: falko

a *nix nerd