fakeroot(1) | Manuel de Debian | fakeroot(1) |
fakeroot - lance une commande dans un environnement simulant les privilèges du superutilisateur pour la manipulation des fichiers.
fakeroot [-l|--lib library] [--faked faked-binary] [-i load-file] [-s save-file] [-u|--unknown-is-real] [-b|--fd-base] [-h|--help] [-v|--version] [--] [command]
fakeroot lance une commande dans un environnement dans lequel cette commande obtient les droits de l'administrateur pour manipuler des fichiers. C'est pratique pour permettre aux utilisateurs de créer des archives (tar, ar, .deb, etc.) qui contiennent des fichiers avec les privilèges et appartenances du superutilisateur. Sans fakeroot, il faudrait posséder les droits du superutilisateur pour donner les droits et appartenances convenables aux fichiers constituant l'archive, puis de les assembler ; ou bien, il faudrait construire directement l'archive, sans utiliser le programme d'archivage.
fakeroot works by replacing the file manipulation library functions (chmod(2), stat(2) etc.) by ones that simulate the effect the real library functions would have had, had the user really been root. These wrapper functions are in a shared library /usr/lib/*/libfakeroot-*.so or similar location on your platform. The shared object is loaded through the LD_PRELOAD mechanism of the dynamic loader. (See ld.so(8))
Si vous désirez construire des paquets avec fakeroot, veuillez essayer de construire d'abord le paquet fakeroot : l'étape « debian/rules build » réalise quelques tests (principalement pour les bogues des vieilles versions de fakeroot). Si ces tests échouent (si vous avez par exemple certains programmes en libc5 sur votre système), la construction d'autres paquets avec fakeroot échouera certainement aussi, mais de façon parfois plus subtile.
Also, note that it's best not to do the building of the binaries themselves under fakeroot. Especially configure and friends don't like it when the system suddenly behaves differently from what they expect (or, they randomly unset some environment variables, some of which fakeroot needs).
Voici un exemple d'utilisation de fakeroot. Notez bien qu'à l'intérieur de l'environnement fakeroot, les manipulations de fichiers qui requièrent les privilèges du superutilisateur ont lieu, mais uniquement virtuellement.
$ whoami joost $ fakeroot /bin/bash # whoami root # mknod hda3 b 3 1 # ls -ld hda3 brw-r--r-- 1 root root 3, 1 Jul 2 22:58 hda3 # chown joost:root hda3 # ls -ld hda3 brw-r--r-- 1 joost root 3, 1 Jul 2 22:58 hda3 # ls -ld / drwxr-xr-x 20 root root 1024 Jun 17 21:50 / # chown joost:users / # chmod a+w / # ls -ld / drwxrwxrwx 20 joost users 1024 Jun 17 21:50 / # exit $ ls -ld / drwxr-xr-x 20 root root 1024 Jun 17 21:50 // $ ls -ld hda3 -rw-r--r-- 1 joost users 0 Jul 2 22:58 hda3
Seule l'opération que l'utilisateur joost pouvait réaliser a réellement aboutie.
fakeroot was specifically written to enable users to create Debian GNU/Linux packages (in the deb(5) format) without giving them root privileges. This can be done by commands like dpkg-buildpackage -rfakeroot or debuild -rfakeroot (actually, -rfakeroot is default in debuild nowadays, so you don't need that argument).
fakeroot est un programme normal, sans privilèges spéciaux. Il n'augmente pas les privilèges de l'utilisateur et n'altère pas la sécurité du système.
/usr/lib/*/libfakeroot-*.so The shared library containing the wrapper functions.
touch foo fakeroot ls -al foo
soit
fakeroot touch foo ls -al foo
fakeroot has no way of knowing that in the first case, the owner of foo really should be joost while the second case it should have been root. For the Debian packaging, defaulting to giving all "unknown" files uid=gid=0, is always OK. The real way around this is to wrap open() and create(), but that creates other problems, as demonstrated by the libtricks package. This package wrapped many more functions, and tried to do a lot more than fakeroot . It turned out that a minor upgrade of libc (from one where the stat() function didn't use open() to one with a stat() function that did (in some cases) use open() ), would cause unexplainable segfaults (that is, the libc6 stat() called the wrapped open() , which would then call the libc6 stat() , etc). Fixing them wasn't all that easy, but once fixed, it was just a matter of time before another function started to use open(), never mind trying to port it to a different operating system. Thus I decided to keep the number of functions wrapped by fakeroot as small as possible, to limit the likelihood of ‘collisions’.
open() n'est pas simulé. Ce n'est pas si grave que cela, mais si un programme invoque open("file", O_WRONLY, 000), écrit dans ce fichier « file », le ferme, puis réessaye ensuite de l'ouvrir en lecture, alors cette tentative échouera, car les droits du fichier seront 000. Le bogue, c'est que si root fait cette opération, alors open() fonctionne, puisque les droits des fichiers ne sont pas du tout vérifiés pour root. Il a été choisi de ne pas simuler open(), car open() est utilisé par nombre d'autres fonctions de la libc (dont certaines qui sont déjà simulées par fakeroot), ce qui créerait des boucles (ou pourrait en créer quand l'implémentation des diverses fonctions de la libc change).
fakeroot est distribué sous la licence GNU General Public License. (GPL 2.0 ou supérieure).
Sylvain Cherrier <sylvain.cherrier@free.fr>.
mostly by J.H.M. Dassen <jdassen@debian.org> with rather a lot of modsifications and additions by joost and Clint.
debuild(1), dpkg-buildpackage(1), faked(1), /usr/share/doc/fakeroot/DEBUG
2024-12-19 | Projet Debian |