Home / Alt manpages / faked-tcp(1)

  • faked-tcp(1)
  • User command
  • linux

Use faked-tcp Safely Through fakeroot

A stray faked-tcp process is not a rogue job, it is fakeroot's TCP-mode daemon remembering fake ownership for packaging tests. This guide draws the line between what it fakes and what it actually writes to disk. On this machine the installed package is fakeroot 1.33-1, and the daemon binary lives at /usr/bin/faked-tcp.

Allow about fifteen minutes. You need a normal shell and the installed fakeroot package. The workflow below does not need elevated privileges and does not change system ownership, permissions or services. It creates one temporary file under /tmp; remove that test directory when you have finished.

1. Check which backend is installed

faked-tcp is the daemon that remembers fake metadata for processes using fakeroot. It is normally started for you. Start with read-only checks rather than launching the daemon by hand:

$ command -v faked-tcp
/usr/bin/faked-tcp
$ fakeroot --version
fakeroot version 1.33
$ dpkg-query -W -f='${Package} ${Version}\n' fakeroot
fakeroot 1.33-1

Checkpoint: the first command should resolve to /usr/bin/faked-tcp. If it does not, stop and check the package installation before troubleshooting daemon options.

2. Let fakeroot start the TCP daemon

Run the command you actually want to test through fakeroot-tcp. This wrapper arranges the communication key, preload library and daemon lifecycle:

$ fakeroot-tcp -- sh -c 'id -u; id -g; touch test-file; chown 123:456 test-file; chmod 640 test-file; stat -c "%u:%g %a %n" test-file'
1000
1000
123:456 640 test-file

The exact real user and group IDs vary by host. The useful result is the final line: inside this fakeroot process, stat reports the fake owner, group and mode. The command is ordinary user-level work. Do not add sudo; real root is neither required nor supplied by fakeroot.

The -- separates fakeroot options from the command being run. Keep it when the child command has options of its own, especially options beginning with a hyphen.

3. Prove that the change was simulated

Use a temporary directory so the test cannot alter a working tree. Replace the placeholder directory with a path you own:

$ test_dir=/tmp/faked-tcp-check
$ mkdir "$test_dir"
$ fakeroot-tcp -- sh -c 'touch "$1/file"; chown 123:456 "$1/file"; chmod 640 "$1/file"; stat -c "%u:%g %a %n" "$1/file"' sh "$test_dir"
123:456 640 /tmp/faked-tcp-check/file
$ stat -c '%u:%g %a %n' "$test_dir/file"
1000:1000 640 /tmp/faked-tcp-check/file

The second result is the real filesystem view. In this example the current user is UID 1000 and the file remains really owned by that user. The mode change to 640 is real because the user created the file and can change its mode; the fake owner and group are only remembered by the daemon for the fakeroot process.

Checkpoint: if the outside stat reports 123:456, you are no longer observing the expected fakeroot boundary. Stop before using the result for packaging.

4. Inspect the daemon's supported controls

For ordinary use, you should not run faked-tcp directly. If you are diagnosing a wrapper or a test harness, its installed help is the authoritative option list:

$ faked-tcp --help
faked, daemon for fake root environment
Best used from the shell script `fakeroot'
options for fakeroot: --port, --foreground, --debug, --save-file, --load, --unknown-is-real

--foreground keeps the daemon attached to the terminal. --debug writes diagnostics to standard error. --port selects the TCP port. --save-file saves the remembered environment on exit, while --load reads a saved environment from standard input. --unknown-is-real makes previously unknown files report their real ownership instead of the default root:root fiction.

These are diagnostic or state-management controls, not fixes for a failed packaging build. Saving fake metadata can make later commands appear inconsistent if files are changed outside the matching fakeroot environment.

5. Avoid the TCP and SysV option trap

The generic faked manual page lists --cleanup and --key, but the installed TCP binary explicitly rejects both because they belong to the SysV IPC build:

$ faked-tcp --cleanup 1
This fakeroot has been compiled for TCP and does not support --cleanup
$ faked-tcp --key 123
This fakeroot has been compiled for TCP and does not support --key

Do not keep adding options from a different backend's manual page. Confirm the binary's help and invoke fakeroot-tcp for the normal path. A daemon that is accidentally left in the foreground can also make a shell appear hung; press Ctrl-C only when you deliberately started it for diagnosis.

6. Clean up and recover

Exit status belongs to the command immediately before it, so capture failures directly:

$ fakeroot-tcp -- sh -c 'exit 7'
$ printf 'child status: %s\n' "$?"
child status: 7

fakeroot passes the child command's failure status back to the shell. If a packaging command fails, rerun it without fake metadata only as a separate diagnostic, because that changes what the command is testing. First inspect the command, package version and generated files.

When the test is over, remove only the directory you created under /tmp. This is a destructive action, so verify the path before removing it:

$ printf 'test directory: %s\n' "$test_dir"
test directory: /tmp/faked-tcp-check
$ rm -r -- "$test_dir"

Do not substitute a broad path or an unresolved variable. The fakeroot daemon's in-memory state ends with its wrapper session unless you deliberately save it.

Done means

  • faked-tcp resolves to the installed TCP daemon and its version is known.
  • fakeroot-tcp reports fake ownership inside the session without granting real privileges.
  • An outside stat confirms that fake ownership was not written to disk.
  • You used the TCP binary's help rather than assuming SysV-only options apply.
  • The temporary test directory has been removed, if it was created.