I just ran this a few seconds ago. I managed to do Ctrl - C as soon as I realized what I started doing.
So far the only directory it's started going through is /bin
.
I'm afraid to do anything else. So far I realized I can't use su
as my normal user anymore.
Luckily I still have another root terminal open. What do I do?
Redhat user:
Debian/Ubuntu user:
While screen is running do this at least twice:
Pay very close attention to the output because if it complains about something having the wrong permissions, you should fix it on another screen window.
Crash course in screen:
Solaris user:
You're fucked.
will reset all the permissions, but setuid-ness will still be broken. Use a backup, or another solaris machine to look for setuid/setgid scripts and files and fix them up manually.
THE IMPORTANT THING ABOUT BACKUPS
Is that you can recover them, not that you take them.
Other people have given you advice to take backups, but I want to add that you should be testing them. If you're using a unixish system, there is no reason whatsoever that you can't dump the files onto another machine periodically and make sure everything works.
Most everything in /bin/ should be owned by root:root, so if you run the following you can fix the ownership on those files:
You may also want to make sure the setuid bit is properly set on /bin/su, which you can fix with the following:
Be aware that the set-uid flags on any affected binaries may have been removed, too; this is a security feature of chown. Check with some other system which binaries have the set-uid or set-gid flags and be sure to set them on your binaries as well.
I was going to explain the details of using RPM to reset file permissions, but I've found a site with a lot more information. It does also mention that Ubuntu/Debian (so .debs in general) don't support it.
But in general the option your looking for would be along the lines:
If this was a debian system, I'd aptitude reinstall everything.
do you have a working backup? when yes, restore your bin folder.
otherwise, look at an other box where you installed the same version of ubuntu and
chown
to what you find on the working installation.try this: find all www-data in /bin directory
then change www-data back to the original user
Thanks all for the great responses, everything seems to be fixed now.
/bin/su worked once chmod'd to 4755 (not sure why chown changed the suid bit)
i didnt notice but it also started working through the /home directory but that was an easy enough fix (just set user:group to the user for each dir)