Kron4ek / Conty

Easy to use unprivileged Linux container packed into a single portable executable
MIT License
760 stars 45 forks source link

/usr/bin/env: bad interpreter: Text file busy #13

Closed satmandu closed 3 years ago

satmandu commented 3 years ago

After a while I'm getting this error:

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ls
bash: ./conty_lite_lz4.sh: /usr/bin/env: bad interpreter: Text file busy

(This is after trying playonlinux, which failed to download anything, thought the gui came up) :

chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh playonlinux
Using system squashfuse and bwrap
Using regular mount command (sudo mount) instead of squashfuse
Running Conty

Looking for python... 3.9.2 - skipped
Looking for python2.7... 2.7.18 - wxversion(s): 3.0-gtk3
/usr/lib64/python2.7/site-packages/wx-3.0-gtk3/wx/_core.py:16629: UserWarning: wxPython/wxWidgets release number mismatch
  warnings.warn("wxPython/wxWidgets release number mismatch")
selected
/usr/lib64/python2.7/site-packages/wx-3.0-gtk3/wx/_core.py:16629: UserWarning: wxPython/wxWidgets release number mismatch
  warnings.warn("wxPython/wxWidgets release number mismatch")
/bin/sh: line 1: xrdb: command not found
1
[main] Message: PlayOnLinux (4.3.4) is starting
[clean_tmp] Message: Cleaning temp directory
[POL_Config_Write] Message: Config write: VDRIVES_LINK_MADE TRUE
[Check_OpenGL] Warning: check_dd_x86 missing, test skipped
[Check_OpenGL] Warning: check_dd_amd64 missing, test skipped
[POL_System_CheckFS] Message: Checking filesystem for /home/chronos/user/.PlayOnLinux/
[FS_Check] Warning: The following file is located on a noexec mounted filesystem.
It might prevent wine from working

/home/chronos/user/.PlayOnLinux/
[main] Message: Filesystem is compatible
[install_plugins] Message: Checking plugin: Capture...
[install_plugins] Message:    -->Installing plugin: 'Capture'.
[update_check] Message: Web version : 1617215730
[update_check] Message: Current local version : 
[update_check] Message: Updating list
[install_plugins] Message: Checking plugin: ScreenCap...
[install_plugins] Message:    -->Installing plugin: 'ScreenCap'.
[install_plugins] Message: Checking plugin: PlayOnLinux Vault...
[install_plugins] Message:    -->Installing plugin: 'PlayOnLinux Vault'.

(mainwindow.py:2669): Gtk-WARNING **: 22:12:58.674: Could not load a pixbuf from /org/gtk/libgtk/theme/Adwaita/assets/check-symbolic.svg.
This may indicate that pixbuf loaders or the mime database could not be found.
[POL_Config_Write] Message: Config write: LAST_TIMESTAMP 1617215730
[POL_SetupWindow_Init] Message: Creating new window for pid 4526
[POL_SetupWindow_Close] Message: Closing window for pid 4526
rm: cannot remove '/home/chronos/user/.PlayOnLinux//install': No such file or directory
[POL_GPG_auth_script] Message: Checking signature of /home/chronos/user/.PlayOnLinux//install
[POL_GPG_install_key] Message: Importing PlayOnLinux public key
[POL_Bash] Message: POL GPG : Good signature - Microsoft Paint
[POL_SetupWindow_Init] Message: Creating new window for pid 4689
[POL_Wine_SelectPrefix] Message: Selecting prefix: mspaint
[POL_Wine_PrefixCreate] Message: Setting POL_WINEVERSION to 3.0.4
[POL_Wine_PrefixCreate] Message: Creating prefix (3.0.4)...
[POL_Wine_PrefixCreate] Message: Using wine 3.0.4
[POL_Wine_InstallVersion] Message: Installing wine version path: 3.0.4, x86
[POL_Wine_InstallVersion] Message: Wine site: https://phoenicis.playonlinux.com/index.php/wine?os=linux
env LD_LIBRARY_PATH="" wget --prefer-family=IPv4 -q https://phoenicis.playonlinux.com/index.php/wine?os=linux -O-
[POL_Wine_InstallVersion] Message: Winebuild data: {
  "version": "3.0.4",
  "url": "http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz",
  "sha1sum": "7dace0daf0eed442bcd7368c3a4dd0f4b547320f",
  "geckoFile": null,
  "geckoUrl": null,
  "geckoMd5": null,
  "monoFile": null,
  "monoUrl": null,
  "monoMd5": null
}
[POL_Wine_InstallVersion] Message: Wine address found: http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz
/usr/local/bin/perl: error while loading shared libraries: libssp.so.0: cannot open shared object file: No such file or directory
Server sha1 : 7dace0daf0eed442bcd7368c3a4dd0f4b547320f
Client sha1 : 
[POL_Config_PrefixWrite] Message: Prefix config write: ARCH x86
[POL_Config_PrefixWrite] Message: Prefix config write: VERSION 3.0.4
[POL_Wine_SetVersionEnv] Message: Wine 3.0.4 not installed. Installing it
[POL_Wine_InstallVersion] Message: Installing wine version path: 3.0.4, x86
[POL_Wine_InstallVersion] Message: Wine site: https://phoenicis.playonlinux.com/index.php/wine?os=linux
env LD_LIBRARY_PATH="" wget --prefer-family=IPv4 -q https://phoenicis.playonlinux.com/index.php/wine?os=linux -O-
[POL_Wine_InstallVersion] Message: Winebuild data: {
  "version": "3.0.4",
  "url": "http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz",
  "sha1sum": "7dace0daf0eed442bcd7368c3a4dd0f4b547320f",
  "geckoFile": null,
  "geckoUrl": null,
  "geckoMd5": null,
  "monoFile": null,
  "monoUrl": null,
  "monoMd5": null
}
[POL_Wine_InstallVersion] Message: Wine address found: http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz
/usr/local/bin/perl: error while loading shared libraries: libssp.so.0: cannot open shared object file: No such file or directory
Server sha1 : 7dace0daf0eed442bcd7368c3a4dd0f4b547320f
Client sha1 : 
[POL_Wine_SetVersionEnv] Message: Wine 3.0.4 not installed. Installing it
[POL_Wine_InstallVersion] Message: Installing wine version path: 3.0.4, x86
[POL_Wine_InstallVersion] Message: Wine site: https://phoenicis.playonlinux.com/index.php/wine?os=linux
[POL_Wine_InstallVersion] Message: Winebuild data: {
  "version": "3.0.4",
  "url": "http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz",
  "sha1sum": "7dace0daf0eed442bcd7368c3a4dd0f4b547320f",
  "geckoFile": null,
  "geckoUrl": null,
  "geckoMd5": null,
  "monoFile": null,
  "monoUrl": null,
  "monoMd5": null
}
[POL_Wine_InstallVersion] Message: Wine address found: http://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-3.0.4-upstream-linux-x86.tar.gz
Traceback (most recent call last):
  File "/usr/share/playonlinux/python/setupwindow/POL_SetupFrame.py", line 392, in DebugClick
    self.parent.BugReport(e)
AttributeError: 'NoneType' object has no attribute 'BugReport'
/usr/local/bin/perl: error while loading shared libraries: libssp.so.0: cannot open shared object file: No such file or directory
/usr/share/playonlinux/lib/playonlinux.lib: line 335:  4689 Killed                  bash "$@"
Unhandled exception in thread started by <bound method gui_server.handler of <gui_server(Thread-2, started 140303092676160)>>
Traceback (most recent call last):
  File "/usr/share/playonlinux/python/setupwindow/gui_server.py", line 53, in handler
    connection.send(self.result)
socket.error: [Errno 104] Connection reset by peer
Registered PID: 2962 (Missing)
Registered PID: 2996 (Missing)
Registered PID: 3099 (Missing)
Registered PID: 3185 (Missing)
Registered PID: 3291 (Missing)
Registered PID: 3372 (Missing)
Registered PID: 3462 (Missing)
Registered PID: 3548 (Missing)
Registered PID: 4526 (Present)
Registered PID: 4689 (Missing)
Registered PID: 4755 (Missing)
Registered PID: 4789 (Missing)
Kron4ek commented 3 years ago

bash: ./conty_lite_lz4.sh: /usr/bin/env: bad interpreter: Text file busy

Probably some process(es) is accessing it for writing (which is weird and shouldn't happen). If you have lsof installed, you can list all processes that are using the script with this command:

sudo lsof /usr/local/conty_lite_lz4.sh

And regarding playonlinux, i see it uses perl binary from /usr/local/bin, even though the builtin /usr/bin has a higher priority. What if you try to run it like this?

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --tmpfs /usr/local playonlinux

or

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --setenv PATH "/bin:/sbin" playonlinux

Also, does the internet connection work in other apps (in Steam or in Lutris, for example, or with simple ping)?

[FS_Check] Warning: The following file is located on a noexec mounted filesystem.

And i see PlayOnLinux complains about $HOME mounted with noexec.

satmandu commented 3 years ago

$HOME is mounted on ChromeOS as noexec.

chronos@localhost /usr/local $ sudo lsof /usr/local/conty_lite_lz4.sh
chronos@localhost /usr/local $ 
chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --tmpfs /usr/local playonlinux
bash: ./conty_lite_lz4.sh: /usr/bin/env: bad interpreter: Text file busy
chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --setenv PATH "/bin:/sbin" playonlinux
bash: ./conty_lite_lz4.sh: /usr/bin/env: bad interpreter: Text file busy

Haven't tried a network connection in steam or lutris, which both error out. in playonlinux, it looks like it is downloading, but then complains about a network error afterwards.

satmandu commented 3 years ago

I do see these errors in dmesg:

[75616.982752] Chromium OS LSM: sb_mount Mounting a filesystem with 'exec' flag requires CAP_SYS_ADMIN in init ns obj="/run/chrome/gvfs" pid=32600 cmdline="/usr/local/libexec/gvfsd-fuse /run/chrome/gvfs -f"
[75616.982759] Chromium OS LSM: sb_mount dev=gvfsd-fuse type=fuse.gvfsd-fuse flags=0x6
[75616.987749] Chromium OS LSM: sb_mount Mounting a filesystem with 'exec' flag requires CAP_SYS_ADMIN in init ns obj="/run/chrome/gvfs" pid=32602 cmdline="fusermount3 -o rw,nosuid,nodev,subtype=gvfsd-fuse -- /run/chrome/gvfs"
[75616.987754] Chromium OS LSM: sb_mount dev=gvfsd-fuse type=fuse.gvfsd-fuse flags=0x6
[75616.989519] Chromium OS LSM: sb_mount Mounting a filesystem with 'exec' flag requires CAP_SYS_ADMIN in init ns obj="/run/chrome/gvfs" pid=32603 cmdline="fusermount3 -o rw,nosuid,nodev -- /run/chrome/gvfs"
[75616.989523] Chromium OS LSM: sb_mount dev=/dev/fuse type=fuse flags=0x6
Kron4ek commented 3 years ago

Ok, i figured out the reason why this happens - this happens when the previously launched Conty wasn't unmounted. Perhaps you missed the moment when it asked to enter sudo password to unmount the image (assuming you don't have NOPASSWD set for umount) or it was roughly terminated.

mount | grep conty

I will fix this by mounting the image as read-only, so even if it's not unmounted you'll stil be able to run Conty as many times as you want.

For now you can either unmount the image manually or try to run Conty directly with bash to avoid this error:

SUDO_MOUNT=1 USE_SYS_UTILS=1 bash conty_lite_lz4.sh ls

Regarding internet connection, I guess the easiest way to check if it works is with ping or with wget (if ping doesn't work):

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ping 8.8.8.8
SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ping google.com
SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh wget "https://www.google.com/"

/etc/resolv.conf and /etc/hosts get automatically binded to the container, so the connection should work, but maybe there are some other files need to be binded, i'm not familiar with ChromeOS file structure. You can try to bind whole /etc to the container (with BIND="/etc" env variable) and see if this helps.

And i still suggest to try to launch PoL in one of these ways and see if it changes anything (not regarding the "Text file busy" error but regarding the PoL itself and internet connection).

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --tmpfs /usr/local playonlinux
SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --setenv PATH "/bin:/sbin" playonlinux
satmandu commented 3 years ago

Yup. Definitely looks like it never unmounted properly.

chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 bash conty_lite_lz4.sh ls
Using system squashfuse and bwrap
Using regular mount command (sudo mount) instead of squashfuse
mount: /tmp/conty_lite_lz4.sh_chronos_26947/mnt: /dev/loop8 already mounted or mount point busy.
Mounting the squashfs image failed!
chronos@localhost /usr/local $ 
chronos@localhost /usr/local $ sudo losetup --list
NAME        SIZELIMIT  OFFSET AUTOCLEAR RO BACK-FILE                                                    DIO LOG-SEC
/dev/loop0          0       0         0  0 /mnt/stateful_partition/encrypted.block                        1     512
/dev/loop1          0       0         0  1 /usr/share/chromeos-config/configfs.img                        0     512
/dev/loop2          0       0         1  1 /opt/google/containers/android/system.raw.img                  0     512
/dev/loop3          0       0         1  1 /opt/google/containers/arc-sdcard/rootfs.squashfs              0     512
/dev/loop4          0       0         1  1 /opt/google/containers/arc-obb-mounter/rootfs.squashfs         0     512
/dev/loop5          0       0         1  1 /usr/share/chromeos-assets/speech_synthesis/patts.squash       0     512
/dev/loop6          0       0         1  1 /usr/share/chromeos-assets/quickoffice/quickoffice.squash      0     512
/dev/loop7          0       0         0  1 /cros-components/cros-termina/13807.0.0/image.ext4             0     512
/dev/loop8          0 1272792         1  0 /usr/local/conty_lite_lz4.sh                                   0     512
/dev/loop10         0       0         0  1 /cros-components/lacros-dogfood-dev/91.0.4450.0/image.squash   0     512

Either sudo dmsetup remove /dev/loop8 or sudo losetup -d /dev/loop8 got rid of that for me.

Re: network issues I see this:

chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ping 8.8.8.8
Using system squashfuse and bwrap
Using regular mount command (sudo mount) instead of squashfuse
Running Conty

ping: socket: Operation not permitted
chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ping 8.8.8.8
Using system squashfuse and bwrap
Using regular mount command (sudo mount) instead of squashfuse
Running Conty

ping: socket: Operation not permitted

We had to put a wrapper on ping to make that work for us:

#!/bin/bash
sudo -E /usr/local/sbin/capsh --caps="cap_net_raw+eip cap_setpcap,cap_setuid,cap_setgid+ep" \
    --keep=1 --user=nobody --addamb=cap_net_raw -- \
    -c "/usr/local/bin/ping.elf $@"

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh ssh host works fine though.

Re: Playonlinux I see this: image Then... image

Looks like an install starts right: image image Here are some errors with installing the msttfcorefonts: image Let's still try installing: image

Looks like it gets stuck there.

satmandu commented 3 years ago

(Maybe a force unmount might be an option if there's an error with mounting? Or just using the existing loopback device if it exists?

satmandu commented 3 years ago

Maybe remapping home dir away from a noexec mount if it is detected as such might also be useful.

Kron4ek commented 3 years ago

You can try to set custom HOME directory like this:

SANDBOX=1 HOME_DIR="/usr/local/some_custom_dir" SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh playonlinux

Or

SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --bind /usr/local/some_custom_dir $HOME playonlinux

(Maybe a force unmount might be an option if there's an error with mounting? Or just using the existing loopback device if it exists?

As for unmounting when SUDO_MOUNT is enabled, i will try to find a solution.

Kron4ek commented 3 years ago

I added a fix for the unmount issue, the script will use the same mountpoint now if possible. Could you please try the new squashfs-start.sh script? You can easily create new Conty from the existing conty_lite_lz4.sh like this:

First copy the squashfs image from the conty_lite_lz4.sh file (no need to rebuild it, just copy with dd):

dd if=/usr/local/conty_lite_lz4.sh of=/usr/local/image.squashfs bs=1272792 skip=1

Where bs=1272792 is the offset (can be viewed with ./conty_lite_lz4.sh -o)

After that download utils.tar and new squashfs-start.sh directly from this repo:

cd /usr/local
wget https://raw.githubusercontent.com/Kron4ek/Conty/master/squashfs-start.sh
wget https://github.com/Kron4ek/Conty/raw/master/utils.tar 

Then just combine all these with cat:

cat squashfs-start.sh utils.tar image.squashfs > conty_lite_lz4_new.sh
chmod +x conty_lite_lz4_new.sh
satmandu commented 3 years ago

The squashfs-start.sh script appears to work.

changing $HOME does not though...

chronos@localhost /usr/local $ mkdir home
chronos@localhost /usr/local $ SUDO_MOUNT=1 USE_SYS_UTILS=1 ./conty_lite_lz4.sh --bind /usr/local/home $HOME playonlinux
Using system squashfuse and bwrap
Using regular mount command (sudo mount) instead of squashfuse
Running Conty

Looking for python... 3.9.2 - skipped
Looking for python2.7... 2.7.18 - wxversion(s): 3.0-gtk3
/usr/lib64/python2.7/site-packages/wx-3.0-gtk3/wx/_core.py:16629: UserWarning: wxPython/wxWidgets release number mismatch
  warnings.warn("wxPython/wxWidgets release number mismatch")
selected
/usr/lib64/python2.7/site-packages/wx-3.0-gtk3/wx/_core.py:16629: UserWarning: wxPython/wxWidgets release number mismatch
  warnings.warn("wxPython/wxWidgets release number mismatch")
/bin/sh: line 1: xrdb: command not found
1
[main] Message: PlayOnLinux (4.3.4) is starting
[clean_tmp] Message: Cleaning temp directory
[POL_Config_Write] Message: Config write: VDRIVES_LINK_MADE TRUE
[Check_OpenGL] Warning: check_dd_x86 missing, test skipped
[Check_OpenGL] Warning: check_dd_amd64 missing, test skipped
[POL_System_CheckFS] Message: Checking filesystem for /home/chronos/user/.PlayOnLinux/
[FS_Check] Warning: The following file is located on a noexec mounted filesystem.
It might prevent wine from working

/home/chronos/user/.PlayOnLinux/

(/home/chronos/user is $HOME by default for ChromeOS.)

Kron4ek commented 3 years ago

From within the container it will still look like /home/chronos/user, but it is actually linked to /usr/local/home. Check if files/dirs appeared inside it:

ls -a /usr/local/home

If yes, then it works as intended. PlayOnLinux will still complain about noexec on /home, but this shouldn't be an issue since the real HOME is on /usr/local now.

satmandu commented 3 years ago
$ ls -a /usr/local/home
 .   ..   .fontconfig   .PlayOnLinux  "PlayOnLinux's virtual drives"
Kron4ek commented 3 years ago
$ ls -a /usr/local/home
 .   ..   .fontconfig   .PlayOnLinux  "PlayOnLinux's virtual drives"

Yep, it works as intended then.

But does PlayOnLinux work fine with HOME on /usr/local/home or still gets stuck at some point?

satmandu commented 3 years ago

(Currently working on just trying to get the larger squashfs image to work in https://github.com/Kron4ek/Conty/issues/14 )