RRZE – Projekte & Prozesse (P&P)

Das Blog der RRZE Stabsstelle "Projekte & Prozesse"

Content

Rekonstruktion von Dateisystemrechten in Linux

English Version

Ein Linux tut immer was man ihm sagt. Und wenn es erstmal fertig ist, gibt’s kein zurück. Das ist in den meisten Fällen keine schlechte Sache, denn man ist sich ja eigentlich immer sicher, dass man dies und das wirklich tun möchte 😉 Hin und wieder kann es jedoch vorkommen, dass einem Fehler unterlaufen und ein ‘Rückgängig’ ist nirgends zu finden. Um so einen Fall geht es nun hier. Ich wollte lediglich einem Verzeichnis und dessen Unterverzeichnissen Rechte auf alles (Lesen, Schreiben und Ausführen) geben.

chmod -R a+rwx DIR

Im ersten Versuch wurde ich noch nett gewarnt, dass das nicht ginge, weil mir das Verzeichnis nicht gehört. Kein Problem, da gibts ja noch den Superuser Account. Angemeldet, Befehl nochmals ausgeführt und zu spät bemerkt, dass sich das Terminal nach der Anmeldung als root im Wurzelverzeichnis / befand. Richtig dumm gelaufen. Jetzt können alle Benutzer Dinge lesen, schreiben und ausführen, auf die sie keinen Zugriff haben sollen. Rückgängig machen kann man das auch nicht. Also was tun? Eine Linux-Konsole ist ja bekanntlich das Schweizer Taschenmesser unter den Terminals, daher gibts bestimmt eine Möglichkeit. Dem ist auch so in Form von getfacl und setfacl. Alles was man noch tun muss, ist einen Rechner zu finden, der einigermaßen die gleiche Distribution und eine möglichst große Menge an gleich installierter Software besitzt. Danach meldet man sich am gesunden System an und sichert die Rechte auf die zu reparierenden Verzeichnisse:

getfacl -R DIR > /tmp/DIR.acl

Die DIR.acl enthält dann die ‘normalen’ Zugriffsrechte des Verzeichnisses ‘DIR’. Diese Datei muss dann aufs zu repariendene System übertragen werden. Dann dort anmelden und per

setfacl --restore=/tmp/DIR.acl

die Rechte in DIR rekonstruieren. Fehlende Dateien und Verzeichnisse werden natürlich ignoriert. Fertig. Alles wieder gut.

Reconstructing Data access rights in Linux

Linux always does as it’s told. And when it’s done, it’s done. Normally, that’s not a bad thing, after all, you know what you’re doing, don’t you? Every now and then, however, it might happen that you make a mistake, and there’s no ?Undo? Button in sight. That is what this article is about. Originally, all I wanted to do is grant access rights (read, write, execute) to one directory and all its subdirectories.

chmod -R a+rwx DIR

When I first tried this, I was warned that I couldn’t do it because the directory wasn’t mine. No problem, there’s still the Superuser Account. Logged in, executed the command and then realized too late that the the terminal was in the root directory after logging on as root. Tough luck. Now every user can read, write and execute whatever he wants. And there’s no way to undo it either. So what now? A linux console is, as is well known, the swiss army knife of terminals, so surely there’s a way to do it. And of course there is: getfacl and setfacl. All that is left to do is find a computer with roughly the same distribution and as much of the same software as possible. Log onto the ?healthy? system, save the rights for the directories in question:

getfacl -R DIR > /tmp/DIR.acl

DIR.acl now contains the ?normal? access rights for the directory ?DIR?. This file can be transferred to the system that needs repairing. Now log in there and use

setfacl --restore=/tmp/DIR.acl

to reconstruct the rights in DIR. Missing files and directories will be ignored, of course. And all is well again.

Leave a comment

Your email address will not be published Required fields are marked *

You can use the following HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>