Trying to compile a small program in c inside nsjail using the following command.
sudo nsjail -B / --cwd /mydir/ -- /usr/bin/gcc main.c
This command, even though defeats the entire purpose of nsjail, has been the result of constant inability of nsjail to find required dependencies for gcc. As an ultimatum, I mounted the entire root directory to check whether the issue lies in nsjail or in my mount configuration.
The above command fails with the following error
collect2: fatal error: cannot find 'ld'
compilation terminated.
Here's the output of $PATH as perceived in nsjail,
sudo nsjail -B / -- /usr/bin/bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Update:
gcc works when I explicitly point all of its internal search paths to /usr/bin like so,
sudo nsjail -B / --cwd /mydir/ -- /usr/bin/bash -c "/usr/bin/gcc -B/usr/bin main.c"