How to fix a broken owner for files from world & build from ports?

Polytropon freebsd at edvax.de
Tue Jan 29 20:10:39 UTC 2013


On Tue, 29 Jan 2013 12:23:09 +0100, Ralf Mardorf wrote:
> On Tue, 2013-01-29 at 10:08 +0100, Matthias Apitz wrote:
> > This is a mayor damage and can only be repaired by a new installation.
> 
> Perhaps true, but if such a simple mistake can't be fixed, [...]

Excuse me, it's not a _simple_ mistake. It may have initially
been even a typo, but anything executed with root privileges
is not simple; root has the power to do anything, even to
completely destroy the system, and that can also be as simple
as calling rm or dd with "carefully carelessly crafted options",
and there is no simple fix for this.



> [...] what happens
> when somebody makes a big mistake?

The size of the mistake doesn't even matter. :-)



> Perhaps more people stay with Linux
> than other *NIX, regarding to the policy, that issues should be fixed
> instead of always starting from the beginning. ;)?

The fix to your issue is, in pseudocode:

	for part in ( OS , ports ) do:
		determine owner rocketmouse:* for all files
		compare with list with correct owner
		for each deviating file do:
			if owner != correct owner then:
				chown file to correct user
			fi
		od
	od

Of course OS and ports have to be treated seperately.

As you have mentioned to own a backup where the permissions
(owners) are correct, obtaining the required reference data
from that backup would be the easiest part.

The alternative: reinstall world, reinstall ports. To avoid
this task, you need to activate your admin skills. :-)



> Of course, if I simply would restore from a dump, it will be less time
> consuming and it wouldn't annoy you, but I would have the bad feeling,
> that if ever needed, thinks can't be fixed, I always would have to
> restore from backups. And what happens, if for what reason ever a backup
> shouldn't be available?

In that case, you would need other references to get the correct
file owners. Files are usually installed to the system by the
"install" command, and it is employed in the Makefiles for the
OS and also for ports. As you correctly recognized, not simply
all files belong to root, so everything "non-standard" could
be derived from such "control files".

Of course, the more files you have to treat (see wc -l of your
result list), the harder the task can become, and maybe installing
the port again is faster than finding out where permissions are
set for the install program call. If you only have 10 files or
so, do it manually, but if there are 100 and more files, coming
from several different ports, reinstalling them sounds easier,
and it's not a big deal to do that with portmaster.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list