---
name: "libtricks"
section: "1"
platform: "linux"
package: "libtricks"
version: "0.2-5"
release: "Debian 2.1 (Slink)"
platforms: ["linux"]
url: "https://new.carta.tech/libtricks"
---

# libtricks(1)

libc-wrapper library that implements a generalised VPATH, and allows a user to fake a different UID (for dpkg-buildpackage etc).

## NAME

libtricks - libc-wrapper library that implements a generalised VPATH, and allows a user to fake a different UID (for dpkg-buildpackage etc).

## DESCRIPTION

**libtricks** library that wraps libc functions like open(), readdir(), stat(), getuid(), etc. The libtricks versions of these functions check the existance of environment variables like VPATH, FAKEROOTUID, etc. Depending on the values of these variables, the open() function can be instructed to find files in different directories, and getuid() will return different values than the real UID.

For people who want to just fake root (useful for creating debian packages), the  **fakeroot** (1) script is provided that also starts **faked** , the daemon that is records actions like \`chmod sys somefile' (these actions are not allowed for non-root users, so faked remembers them, and the stat() function in libtricks communicate with faked).

For more information about VPATH, please see /usr/doc/libtricks/README.

## ENVIRONENT

- VPATH

  **The \`view-path'. With this variable, you can cause files to be** searched (also) in additional directories, messages to be issued upon opening of certain files in certain modes, and loads more. See /usr/doc/libtricks/README for more details. To debug, use detrick, like in:

  ```
  $ VPATH='needexec&chop("/bin/")=:/usr/lib/libtricks/bin/:/bin' detrick
  ```

- VPATHLIBDELIM

  **The string that delimits the various directories within a vpath. If** `unset, ":" is used.`

- VPATHLIBEXTDELIM

  **The string that is used to seperate two vpath's in the VPATH variable. If** `unset, "::" is used.`

- VPATHSYMLINK

  **If set, all files affected by** `the VPATH will appear to be symlinks to the files they replace. For example:`

  ```
  $ fakeroot
  # VPATHSYMLINK=yes
  # VPATH="chop(\"/usr/bin\")=:/bin"
  # ls -ild /usr/bin /bin
  42337 drwxr-xr-x 2 root root 2048 Sep 13 17:31 /bin
  42337 lrwxr-xr-x 2 root root 2048 Sep 13 17:31 /usr/bin -> /bin
  ```

-

  `Note that the inodes of both direcotories are the same, as libtricks` `didn't really create the symlink, and thus doesn't know what inode` `number will be free to use.`

- VPATHLIBEXTSEPERATOR

  **The string used to seperate the functions in a vpath element** `(functions like chop, iswrite, stdout, etd.) from the directory. If` `unset, "=" is used.`

- FAKEROOTUID

  - FAKEROOTGID

  - FAKEROOTEUID

  - FAKEROOTEGID

  **If set, fakeroot will set the uid, gid, euid and egid to the numeric** `values of these environment variables (note that the variables cannot` `contain names, only numbers).`

- FAKEROOTDONTTRYCHOWN

  **If set (to whatever value, may be set to ""), the wrapper function provided by** `chown will not try to do the chown on disk any more. This may be useful if` `you have nfs volumes mounted from an irix server. `

- FAKEROOTKEY

  **The key used to communicate with the faked 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 filesystem's permissions/ownerships.` `(assuming the daemon and connecting program were started by the same` `user). Note that faked outputs a string of the form` `"$FAKEROOTKEY:$PID" when it is started. The shell script fakeroot` `takes the output of faked, and sets FAKEROOTKEY correctly).`

## BUGS

- symlinks

  **symlinks aren't \`vpath-ed'. that is, if VPATH="chop(\\"/bin\\")=:/tmp/bin",** `then opening a symlink ~/home/ls -> /bin/ls will open /bin/ls` `directly, and not first try to open /tmp/bin/ls.`

- dpkg-shlibdeps

  **dpkg-shlibdeps ran inside fakeroot gets a sig 11 (avoided with neat** `VPATH trick in fakeroot, but nevertheless, there's a bug in libtricks` `there somewhere). `

- readlink

  **readlink on a ordinary file/dir without VPATHSYMLINK set will still** `not return an error, if the file is affected by the VPATH. Should,` `according to readlink(2), return EINVAL.`

- chroot

  **in trick-chroot, the output of \`pwd' initially isn't correct. After the** `first cd this is corrected, but anyway. Should use vpath_findpath() in` `getcwd().`

## COPYING

**libtricks** `is distributed under the GNU General Public License.` `(GPL 2.0 or greater).`

## AUTHOR

`joost witteveen` \<joostje@debian.org\>

## MANUAL PAGE

`mostly by joost witteveen,` `some pieces probably still from J.H.M. Dassen ` \<jdassen@wi.LeidenUniv.nl\> `, who wrote the original version of this manual page`

## SEE ALSO

[**detrick**(1)](/detrick/1.md), [**trick-chktmp**(1)](/trick-chktmp/1.md), [**trick-chroot**(1)](/trick-chroot/1.md), **trick-openlog**(1), [**dpkg-buildpackage**(1)](/dpkg-buildpackage/1.md), **build**(1L) [**fakeroot**(1)](/fakeroot/1.md) **/usr/doc/libtricks/README** **/usr/doc/libtricks/DEBUG**
