fakeroot(1) Debian manual fakeroot(1) NAMN fakeroot - utfor ett kommando i en miljo som fejkar root-privilegier for filmanipulation SYNOPSIS 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] BESKRIVNING fakeroot utfor ett kommando i en miljo dar kommandot tror sig ha root-privilegier for filmanipulering. Detta ar anvandbart for att ge anvandare mojlighet att skapa arkiv (tar, ar, .deb osv) som innehaller filer med root-rattigheter/agarskap. Utan fakeroot tvingas man att ha root-privilegier for att skapa de filer arkivet bestar av med korrekt agarskaps- och rattighetsinformation, alternativt konstruera arkiven manuellt utan att anvanda arkiveringsprogrammet. 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)) Om du planerar att bygga paket med hjalp av fakeroot, forsok forst att bygga fakeroot-paketet: "debian/rules build"-stadiet har ett par tester (som mestadels testar efter buggar i gamla versioner av fakeroot). Om dessa tester misslyckas (till exempel pa grund av att du har vissa libc5-program pa ditt system) sa ar det troligt att du ocksa kommer att misslyckas bygga andra paket, och det ar mojligt att dessa fel blir betydligt svarare att hitta. 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). FLAGGOR -l bibliotek, --lib bibliotek Ange ett alternativt bibliotek med ersattningsfunktioner. --faked binar Ange en alternativ binar att anvanda istallet for faked(1). [--] kommando 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 sparfil Spara fakeroot-miljon till sparfil vid avslut. Denna fil kan anvandas for att senare aterstalla miljon med -i. Men om denna filen skulle lacka kommer fakeroot borja bete sig pa konstiga satt om du inte later bli filerna som anvants inuti fakeroot nar du ar utanfor miljon. Detta kan dock fortfarande vara anvandbart. Det kan till exempel anvandas med rsync(1) for att sakerhetskopiera och aterstalla hela katalogtrad kompletta med anvandare, grupp och enhetsinformation utan att behova vara root. Se /usr/share/doc/fakeroot/README.saving for vidare information. -i lasfil Las in en fakeroot-miljo som tidigare sparats via -s fran lasfil. Notera att detta inte implicit sparar filen, anvand -s ocksa for det beteendet. Anvandning av samma fil for bade -i och -s vid samma fakeroot-korning ar sakert. -u, --unknown-is-real Anvand det riktiga agarskapet for filer som inte tidigare ar kanda av fakeroot istallet for att latsas att de ags av root:root. -b fd Ange fd-bas (endast TCP-lage). fd ar det minsta fildeskriptornummer som anvands for TCP-anslutningar; detta kan vara viktigt for att undvika konflikter med fildeskriptorerna som anvands av program som kors under fakeroot. -h Visa hjalp. -v Visa version. EXEMPEL Har ar ett exempel pa hur fakeroot kan anvandas. Notera att i den fejkade root-miljon sa lyckas filmanipulering som kraver root-privilegier, trots att den egentligen inte utfors. $ 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 Enbart de operationer som anvandaren joost skulle kunna ha genomfort som sig sjalv utfors pa riktigt. 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). SAKERHETSASPEKTER fakeroot ar ett vanligt program utan setuid. Det ger inte anvandaren nagra extra privilegier, och minskar inte systemets sakerhet. FILER /usr/lib/*/libfakeroot-*.so The shared library containing the wrapper functions. MILJO 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/ BEGRANSNINGAR Biblioteksversioner Varje kommando som utfors inom fakeroot maste vara lankat mot samma version av libc som fakeroot sjalvt. open()/create() fakeroot innehaller inga ersattningsfunktioner for open(), create(), osv. Sa om anvandaren joost antingen utfor touch foo fakeroot ls -al foo eller omvant, 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'. GNU configure (and other such programs) fakeroot andrar i praktiken hur systemet beter sig. Program som forsoker kanna av systemets beteende (exempelvis GNU configure) kan bli forvirrade av detta (och aven om de inte blir det sa kan fakeroot bli forvirrat). Darfor ar det inte rekommenderat att utfora "configure" inifran fakeroot. Da configure bor anropas av "debian/rules build", sa borde "dpkg-buildpackage -rfakeroot" ta hand om detta pa ett korrekt satt. BUGGAR fakeroot har ingen ersattningsfunktion for open(). Detta i sig sjalvt ar inget fel, men om ett program utfor open("fil", O_WRONLY, 000), forsoker skriva till filen "fil", stanger den, och sedan forsoker att lasa filen, sa misslyckas detta da filen kommer att ha rattigheterna 000. Felet bestar i att om en process med root-privilegier forsoker sig pa det samma, sa kommer anropet till open() att lyckas, eftersom filrattigheter inte kontrolleras alls for root. Jag valde att inte skriva ersattningsfunktioner for open(), eftersom open() anvands av manga andra funktioner i libc (aven de som har ersattningsfunktioner), vilket ger upphov till cirkelreferenser eller potential for cirkelreferenser ifall implementationen av vissa funktioner i libc forandras). LICENS fakeroot distribueras under GNU General Public License. (GPL 2.0 eller senare). FORFATTARE joost witteveen Clint Adams Timo Savola OVERSATTNING David Weinehall MANUALSIDA mostly by J.H.M. Dassen with rather a lot of modsifications and additions by joost and Clint. SE AVEN debuild(1), dpkg-buildpackage(1), faked(1), /usr/share/doc/fakeroot/DEBUG Debian Project 2024-12-19 fakeroot(1)