0

I'm trying to use proot under Ubuntu 22.04 to create an isolated environment with a separate home directory. I'm running the following:

proot -r /home/user/testroot/ -w /home/user -b /bin:/bin! -b /dev -b /etc -b /lib:/lib! -b /lib32:/lib32! -b /lib64:/lib64! -b /libx32:/libx32! -b /proc -b /sbin:/sbin! -b /usr -b /var   /bin/bash

which runs OK, and pretty much does what I expect, but there's a slight issue with files created in the environment. Specifically, stat cannot find them at all, unless a file exists on the 'host system' with exactly the same name.

user@vbox-ubuntu:~$ ll
ls: cannot access 'testfile_2': No such file or directory
total 16
drwxr-x--- 16 user user 4096 Dec 16 11:55 ./
drwxr-xr-x  3 root root 4096 Jan 26  2023 ../
-rw-------  1 user user 1090 Dec 16 11:26 .bash_history
-rw-r--r--  1 user user 3817 Feb  2  2023 .bashrc
-rw-rw-r--  1 user user    0 Dec 16 11:55 testfile
-?????????  ? ?    ?       ?            ? testfile_2

So, in the above example, testfile exists in /home/user, but testfile_2 does not. To be clear, I can read and write from/to testfile_2, but stat cannot see it at all. Interestingly, I can also use stat to access files that aren't included in the 'guest system':

user@vbox-ubuntu:~$ stat .profile
  File: .profile
  Size: 807             Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d      Inode: 399533      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    user)   Gid: ( 1000/    user)
Access: 2023-12-16 11:03:43.648320948 +0000
Modify: 2023-01-26 17:16:25.123261068 +0000
Change: 2023-01-26 17:16:25.123261068 +0000
 Birth: 2023-01-26 17:16:25.123261068 +0000
user@vbox-ubuntu:~$ cat .profile
cat: .profile: No such file or directory

Is this a known bug with proot, or is it something I'm getting wrong?

1 Answer 1

1

Ubuntu still has version 5.1.0 of proot, which does not yet intercept the new statx(2) system call that replaces the various older stat syscalls. (statx(2) adds several new fields such as file creation or 'birth' time, which 'struct stat' could not report.) This was only implemented in version 5.3.0.

Consider using tools that use kernel-level filesystem isolation (namespaces), such as bwrap or systemd-nspawn.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .