fakeroot(1) | Manual de Debian | fakeroot(1) |
fakeroot - ejecuta una orden en un entorno que falsea privilegios de superusuario para la manipulación de ficheros
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 ejecuta una orden en un entorno donde parece que se tiene permisos de superusuario para la manipulación de ficheros. Útil para permitir a usuarios crear archivos (tar, ar, .deb etc.) con ficheros con permisos/propietarios de superusuario. Sin fakeroot uno necesitaría privilegios de superusuario para crear los ficheros constituyentes del archivo con los permisos y propietario correctos, y después empaquetarlos, o uno tendría que construir los archivos directamente, sin usar el archivador.
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 pretende construir paquetes usando fakeroot, es aconsejable construir primero el paquete fakeroot: la etapa "debian/rules build" tiene algunas comprobaciones (la mayoría de ellas buscan fallos de versiones viejas de fakeroot). Si estas pruebas fallan (por ejemplo, porque tiene ciertos programas libc5 en el sistema), también fallará la construcción de otros paquetes mediante fakeroot, pero de formas mucho más sutiles.
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).
Aquí hay un ejemplo de una sesión con fakeroot. Dese cuenta que dentro de un entorno fakeroot la manipulación de ficheros que requiere privilegios de superusuario se realiza con éxito, pero realmente no se lleva a cabo.
$ 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
Sólo las operaciones que el usuario joost puede hacer se llevan a cabo realmente.
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 es un programa normal, sin el bit setuid. No aumenta los privilegios de un usuario ni disminuye la seguridad del sistema.
/usr/lib/*/libfakeroot-*.so The shared library containing the wrapper functions.
touch foo fakeroot ls -al foo
o del otro modo,
fakeroot touch tal ls -al tal
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’.
No envuelve open(). Esto no es malo por si mismo, pero si un programa hace open("fichero", O_WRONLY, 000), escribe en "fichero", lo cierra, y trata de abrirlo de nuevo para leer el fichero, entonces falla al abrirlo, ya que el modo del fichero será 000. El fallo es que si el superusuario hace lo mismo, open() será satisfactorio, ya que los permisos del fichero no se comprueban para el superusuario. Elegí no envolver open(), ya que open() se usa en muchas otras funciones de libc (incluso en aquellas que ya están envueltas), de forma que se crean bucles (o posibles bucles futuros, cuando la implementación de varias funciones de libc cambie ligeramente).
fakeroot se distribuye bajo la Licencia Pública General de GNU. (GPL 2.0 o posterior).
Traducción de Rubén Porras Campo <debian-l10n-spanish@lists.debian.org>
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 | Proyecto Debian |