termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
745 stars 161 forks source link

link2symlink processed some files in gentoo proot-distro not as expected #188

Open zxq432 opened 2 years ago

zxq432 commented 2 years ago

Problem description

some conftest files lost .l2s. prefix and were placed in ~ (/root) instead of /.l2s

localhost ~ # ls -alt *000*
lrwxrwxrwx 1 root root 30 Sep 14 23:41 conftest.no-such0001 -> conftest.no-such0001.0002
lrwxrwxrwx 1 root root 18 Sep 14 23:41 conftest.no-such0001.0002 -> conftest.no-such
lrwxrwxrwx 1 root root 18 Sep 14 23:36 target0001 -> target0001.0002
lrwxrwxrwx 1 root root 18 Sep 14 23:36 target0001.0002 -> target
lrwxrwxrwx 1 root root 26 Sep 14 23:36 conftest.file0001 -> conftest.file0001.0002
lrwxrwxrwx 1 root root 18 Sep 14 23:36 conftest.file0001.0002 -> conftest.file

some .l2s.*conftest.a* files left useless in /.l2s only have links from *conftest.a* files in /.l2s

localhost ~ # ls -alt /.l2s/.l2s.*conftest*
lrwxrwxrwx 1 root root 138 Sep 14 23:36 /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001 -> /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
-rw------- 1 root root   5 Sep 14 23:36 /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
lrwxrwxrwx 1 root root 138 Sep 14 23:36 /.l2s/.l2s..l2s.conftest.a0002.00020001 -> /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
-rw------- 1 root root   5 Sep 14 23:36 /.l2s/.l2s..l2s.conftest.a0002.00020001.0002
lrwxrwxrwx 1 root root 110 Sep 14 23:36 /.l2s/.l2s.conftest.a0001 -> /.l2s/.l2s.conftest.a0001.0002
-rw-r--r-- 1 root root   0 Sep 14 23:36 /.l2s/.l2s.conftest.a0001.0002
localhost ~ # find -L /{bin,etc,lib,lib64,sbin,usr,var} -samefile /.l2s/.l2s.conftest.a0001.0002
localhost ~ # find -L /{bin,etc,lib,lib64,sbin,usr,var} -samefile /.l2s/.l2s..l2s.conftest.a0002.00020001.0002
localhost ~ # find -L /{bin,etc,lib,lib64,sbin,usr,var} -samefile /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
localhost ~ # find -L /.l2s -samefile /.l2s/.l2s.conftest.a0001.0002
/.l2s/.l2s.conftest.a0001
/.l2s/.l2s.conftest.a0001.0002
localhost ~ # find -L /.l2s -samefile /.l2s/.l2s..l2s.conftest.a0002.00020001.0002
/.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
/.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001
/.l2s/.l2s..l2s.conftest.a0002.00020001.0002
/.l2s/.l2s..l2s.conftest.a0002.00020001
localhost ~ # find -L /.l2s -samefile /.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
/.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001.0002
/.l2s/.l2s..l2s..l2s.conftest.a0002.00020001.00020001
/.l2s/.l2s..l2s.conftest.a0002.00020001.0002
/.l2s/.l2s..l2s.conftest.a0002.00020001
localhost ~ #

further investigation of timestamps in the /var/log/emerge.log revealed the conftest files were created during emerge of 2 packages: coreutils and rsync

localhost ~ # c=$(grep -E "emerge [(0-9]* of " /var/log/emerge.log|sed -e "s/\([0-9]\+\)/echo \`date --date=@'\1'\`'/;s/$/';/")
localhost ~ # eval $c|gawk '/23:33/,/23:42/'
Tue Sep 14 23:33:02 -00 2021: ::: completed emerge (18 of 62) sys-apps/sandbox-2.25 to /
Tue Sep 14 23:33:02 -00 2021: >>> emerge (19 of 62) sys-apps/coreutils-8.32-r1 to /
Tue Sep 14 23:40:01 -00 2021: ::: completed emerge (19 of 62) sys-apps/coreutils-8.32-r1 to /
Tue Sep 14 23:40:01 -00 2021: >>> emerge (20 of 62) net-misc/rsync-3.2.3-r4 to /
Tue Sep 14 23:42:14 -00 2021: ::: completed emerge (20 of 62) net-misc/rsync-3.2.3-r4 to /
localhost ~ # 

Steps to reproduce

 mkdir -p /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/gentoo/.l2s
 proot-distro install gentoo
 proot-distro login gentoo
 curl -LO http://distfiles.gentoo.org/experimental/prefix/arm/prefix-stage3-arm64-latest.tar.xz
 tar -C /data -xf prefix-stage3-arm64-latest.tar.xz
 mv /usr/bin/patch /usr/bin/patch.bk
 ln -s /data/gentoo64/usr/bin/patch /usr/bin/patch
 nano /etc/portage/make.conf   ;#   add '-xattr' to USE in the /etc/portage/make.conf.
 emaint sync -a
 emerge -v1 patch
 rm /usr/bin/patch.bk
 emerge -v1 coreutils
 ls *000* /.l2s/.l2s.*conftest*
 emerge -v1 rsync
 ls *000*

Expected behavior

all link2symlink hiden files have .l2s. prefix and put in the expected folder of original file or /.l2s and useless .l2s.* files should be deleted.

Additional information

~ $ termux-info
Application version:
0.117
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.librehat.com/apt/termux-main/ stable main
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
Updatable packages:
openssh/stable 8.6p1-3 aarch64 [upgradable from: 8.6p1-1]
termux-keyring/stable 2.2 all [upgradable from: 2.0]
Android version:
10
Kernel build information:
Linux localhost 4.14.116 #1 SMP PREEMPT Fri Aug 6 19:16:39 CST 2021 aarch64 Android
Device manufacturer:
HUAWEI
Device model:
SPN-AL00
~ $ 
JavisWiki commented 2 years ago

You can create /.l2s folder fix it. For more detail visit #216