Noid has not been updated for a couple of years, and does not work on newer kernels. Consider development to be on hold, with a quite small chance of being restarted.

Noid chtrunk

trunk
Pronunciation: 'tr&[ng]k
Function: noun
Etymology: Middle English tronke box, trunk, from Middle French tronc, from Latin truncus trunk, torso
Date: 15th century
1 a : the main stem of a tree apart from limbs and roots

Chtrunk is a small command line utility for changing the namespace of a process. It works almost like chroot, but is a couple of magnitudes more flexible. With chroot, you can only change the root directory. Chtrunk lets you build a trunk on which you attach files and directories.

Chroot example

root:~# echo This is a file >/path/to/complete/root/dir/file
root:~# chroot /path/to/complete/root/dir/
root:/# cat /file
This is a file

Chtrunk example

user:~$ mkdir /tmp/foo
user:~$ echo This is file one >/tmp/foo/file1
user:~$ echo This is file two >/tmp/file2
user:~$ chtrunk -d /firstfile=/tmp/foo/file1 /secondfile=/tmp/file2 /foodir=/tmp/foo /foo/dir/again=/tmp/foo 47</tmp
Closing unused file descriptors: 47.
sh-2.05$ ls /
bin fd firstfile foo foodir lib secondfile std tmp
sh-2.05$ ls /foodir/
file1
sh-2.05$ ls /foo/
dir
sh-2.05$ ls /foo/dir/
again
sh-2.05$ ls /foo/dir/again/
file1
sh-2.05$ cat /firstfile
This is file one
sh-2.05$ cat /secondfile
This is file two
sh-2.05$ cat /foodir/file1
This is file one
sh-2.05$ cat /foo/dir/again/file1
This is file one

Notice the absence of usual directories like /etc/, /proc/ and /home/. They were not specified on the command line, so they are not mapped into the trunk. Chtrunk also scans for file descriptors that does not belong to a file mapped to the trunk and closes them.

Most of the time, you want /bin/, /lib/ and /tmp/ on the trunk to be able to run any command at all. The -d option to chtrunk adds these automatically. It also maps stdin, stdout and stderr under /std/, to prevent them from being closed.

Chtrunk removes all environment variables not specified on the command line, to prevent any unwanted information being available to the new process.

Chtrunk needs trunkfs to be installed and mounted. To be able to use it as a non-root user you also need the user chroot patch.

Send questions, money, bug reports, success reports, patches and suggestions to the author, Jörgen Cederlöf, at jc+noid@lysator.liu.se.

Hosted at SourceForge Logo lysator