A translator for faking privileged access to an underlying filesystem.
This translator appears to give transparent access to the underlying directory node. However, all accesses are made using the credentials of the translator regardless of the client and the translator fakes success for chown and chmod operations that only root could actually do, reporting the faked IDs and modes in later stat calls, and allows any user to open nodes regardless of permissions as is done for root.
A trivial example
Let's demonstrate that chown and chgrp requires root permission.
$ mkdir ~/etc
$ touch ~/etc/this
$ settrans ~/etc/this /hurd/hello
$ ls -lha ~/etc/
total 12K
drwxr-xr-x 2 joshua joshua 4.0K Oct 15 20:12 .
drwxr-xr-x 33 joshua joshua 4.0K Oct 15 20:11 ..
-r--r--r-- 1 joshua joshua 14 Oct 15 20:12 this
$
$ chown root ~/etc/this
chown: changing ownership of '/home/joshua/etc/this': Operation not permitted
Now, let's run through fakeroot-hurd
:
$ fakeroot
# ls -lha ~/etc/
total 12K
drwxr-xr-x 2 root root 4.0K Oct 15 20:12 .
drwxr-xr-x 33 root root 4.0K Oct 15 20:11 ..
-r--r--r-- 1 root root 14 Oct 15 20:12 this
The shell now believes we are root, and all the owner and group are turned into root. Now we can chmod, chown, chgrp, ...
# chown daemon ~/etc/this
# ls -lha ~/etc/
total 12K
drwxr-xr-x 2 root root 4.0K Oct 15 20:12 .
drwxr-xr-x 33 root root 4.0K Oct 15 20:11 ..
-r--r--r-- 1 daemon root 14 Oct 15 20:12 this
A manual example
We can also attach /hurd/fakeroot
manually to ~/etc
, and we'll be able to
use chown
, chgrp
, chmod
, etc. as a normal user.
$ settrans ~/etc /hurd/fakeroot
$ cd ~/etc
$ cd
$ showtrans ~/etc
/hurd/fakeroot
$ ls -lha ~/etc/
total 16K
drwxr-xr-x 2 joshua joshua 4.0K Oct 15 20:12 .
drwxr-xr-x 33 root root 4.0K Oct 15 20:11 ..
-r--r--r-- 1 root root 14 Oct 15 20:12 this
fakeroot
turns all the owner and group to root when it starts. Now
we can chmod, chown, and chgrp as a normal user.
$ chown joshua ~/etc/this
$ chgrp joshua ~/etc/this
$ chmod +xr ~/etc/this
$ ls -lha ~/etc/
total 16K
drwxr-xr-x 2 joshua joshua 4.0K Oct 15 20:12 .
drwxr-xr-x 33 root root 4.0K Oct 15 20:11 ..
-rwxr-xr-x 1 joshua joshua 14 Oct 15 20:12 this