fakeroot(1) | Manual de Debian | fakeroot(1) |
NOMBRE¶
fakeroot - ejecuta una orden en un entorno que falsea privilegios de superusuario para la manipulación de ficheros
SINOPSIS¶
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]
DESCRIPCIÓN¶
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).
OPCIONES¶
- -l biblioteca, --lib biblioteca
- Especifica una biblioteca envoltorio.
- --faked binario
- Especifica un binario alternativo a usar en vez de faked.
- [--] orden
- Any command you want to be run as fakeroot. Use ‘--’ if in the command you have other options that may confuse fakeroot's option parsing.
- -s fichero-salvado
- Guarda el entorno fakeroot en fichero-salvado al salir. Este fichero puede usarse para restaurar el entorno más tarde usando -i. Sin embargo, este fichero fallará y fakeroot se comportará de forma extraña a menos que no modifique los ficheros creados (N.T. del inglés touched, haciendo referencia a la orden touch, con la que fakeroot crea algunos ficheros vacíos para simular algunas situaciones) dentro del entorno fakeroot cuando esté fuera del entorno. Aun así, esto puede ser útil. Por ejemplo, puede usarse con rsync(1) para guardar y restaurar el árbol de directorios completo con la información de usuarios, grupos y dispositivos completa sin necesidad de ser superusuario. Consulte /usr/share/doc/fakeroot/README.saving para más detalles.
- -i fichero-a-cargar
- Carga un entorno fakeroot de fichero-a-cargar previamente salvado usando -s. Note que esto no salva implícitamente el fichero, use también -s para conseguir esto. Es seguro usar el mismo fichero para -i y -s en una misma invocación de fakeroot.
- -u, --unknown-is-real
- Usa el propietario real para ficheros desconocidos previamente por fakeroot en vez de suponer que pertenecen a root:root.
- -b fd
- Especifica el descriptor de fichero base (sólo en modo TCP). Fd es el número mínimo de descriptor de fichero a usar para las conexiones TCP, puede ser importante para evitar conflictos con los descriptores de ficheros usados por programas ejecutándose dentro de fakeroot.
- -h
- Muestra la ayuda.
- -v
- Muestra la versión.
EJEMPLOS¶
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).
ASPECTOS DE SEGURIDAD¶
fakeroot es un programa normal, sin el bit setuid. No aumenta los privilegios de un usuario ni disminuye la seguridad del sistema.
FICHEROS¶
/usr/lib/*/libfakeroot-*.so The shared library containing the wrapper functions.
ENTORNO¶
- FAKEROOTKEY
- The key used to communicate with the fakeroot daemon. Any program started with the right LD_PRELOAD and a FAKEROOTKEY of a running daemon will automatically connect to that daemon, and have the same "fake" view of the file system's permissions/ownerships (assuming the daemon and connecting program were started by the same user).
- LD_LIBRARY_PATH
- LD_PRELOAD
- fakeroot is implemented by wrapping system calls. This is accomplished by setting LD_LIBRARY_PATH=/usr/lib/fakeroot and LD_PRELOAD=libfakeroot.so.0. That library is loaded before the system's C library, and so most of the library functions are intercepted by it. If you need to set either LD_LIBRARY_PATH or LD_PRELOAD from within a fakeroot environment, it should be set relative to the given paths, as in LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/foo/bar/
LIMITACIONES¶
- Versiones de la biblioteca
- Toda orden ejecutada con fakeroot necesita enlazarse con la misma versión de la biblioteca de C del mismo fakeroot.
- open()/create()
- fakeroot no envuelve open(), create(), etc. Así, que si el usuario
joost hace
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’.
- GNU configure (and other such programs)
- fakeroot, en efecto, cambia el comportamiento del sistema. Los programas que prueban el sistema, como GNU configure, pueden verse confundidos por esto (o si no lo hacen, llevarán a fakeroot tan al límite que será este el que se confunda). Así que es aconsejable no ejecutar el objetivo "configure" en un entorno fakeroot. Como configure debe ejecutarse en "debian/rules build", "dpkg-buildpackage -rfakeroot" tiene cuidado de esto, haciéndolo correctamente.
FALLOS¶
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).
COPIA¶
fakeroot se distribuye bajo la Licencia Pública General de GNU. (GPL 2.0 o posterior).
AUTORES¶
- joost witteveen
- <joostje@debian.org>
- Clint Adams
- <clint@debian.org>
- Timo Savola
TRADUCTOR¶
Traducción de Rubén Porras Campo <debian-l10n-spanish@lists.debian.org>
PÁGINA DEL MANUAL¶
mostly by J.H.M. Dassen <jdassen@debian.org> with rather a lot of modsifications and additions by joost and Clint.
VÉASE ADEMÁS¶
debuild(1), dpkg-buildpackage(1), faked(1), /usr/share/doc/fakeroot/DEBUG
2024-12-19 | Proyecto Debian |