Skip to content

Commit

Permalink
--backend=chroot: some fixes, but disabled nonetheless. #224
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Feb 3, 2022
1 parent 2b2efd3 commit 42dfead
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Project website: https://github.com/mviereck/x11docker

## [Unreleased]
### Added
- `--backend=proot`: Experimental support.
- `--backend=proot`: Use a rootfs on host with `proot` instead of a container.
[(#224)](https://github.com/mviereck/x11docker/issues/224)
- `--backend=host`: Run application from host. Replaces `-e, --exe`.
### Changed
Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
x11docker ToDo notes

## Work in progress
- --backend=systemd-nspawn
- check empty XDG_RUNTIME_DIR e.g. with --user, --hostuser
- --xc=backend for proot and host backends
- --backend=proot
- --name
- --init except systemd possible?
- share: ro not possible
- clean /tmp
- do old binds disappear?

- kata: add new runtime for nerdctl io.containerd.kata.v2

Expand Down
71 changes: 43 additions & 28 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Run 'x11docker --help' or scroll down to read usage information.
# More documentation at: https://github.com/mviereck/x11docker

Version="7.1.0-beta-3"
Version="7.1.0-beta-4"

# --enforce-i: Enforce running in interactive mode to allow commands tty and weston-launch in special setups.
grep -q -- "--enforce-i" <<< "$*" && case $- in
Expand Down Expand Up @@ -630,6 +630,19 @@ finish() { # trap EXIT routine to clean up background proce
$($Backendbin rm -f "$Containername" 2>&1)"
}
;;
chroot)
while read -r Line; do
debugnote "--backend=$Backend: umount $Line"
Source="$(cut -d'|' -f1 <<< "$Line")"
Target="$(cut -d'|' -f2 <<< "$Line")"
[ -d "$Source" ] && {
umount -f "$Target" || warning "umount failed on '$Target'"
}
[ -S "$Source" ] && rm "$Target"
[ -f "$Source" ] && rm "$Target"
done <<< "$Chrootmountlist"
#umount -t devpts "$Rootfs/dev/pts" || error "--backend=$Backend: umount of devpts failed."
;;
esac

# Stop watching for messages, check others again
Expand Down Expand Up @@ -2301,17 +2314,29 @@ check_newxenv() { # find free display
echo "$Newdisplaynumber" >> "$Numbersinusefile"

# X over IP/TCP
[ "$Xoverip" ] || case $Xserver in
--xwin|--runx)
Xoverip="yes"
[ "$Network" = "none" ] && {
note "Option $Xserver needs network access.
[ "$Xoverip" ] || {
case $Mobyvm in
yes)
Xoverip="yes"
;;
esac
case $Xserver in
--xwin|--runx)
Xoverip="yes"
[ "$Network" = "none" ] && {
note "Option $Xserver needs network access.
Enabling option -I, --network."
check_fallback
Network=""
}
;;
esac
check_fallback
Network=""
}
;;
esac
case $Backend in
chroot)
Xoverip="yes"
;;
esac
}

# set $Newdisplay (DISPLAY of container) and $Newxsocket
case $Xserver in
Expand Down Expand Up @@ -3000,16 +3025,6 @@ check_xserver() { # check chosen X server, auto-choose X server
esac
;;
esac
case $Backend in
chroot)
Xoverip="yes"
;;
esac
case $Mobyvm in
yes)
Xoverip="yes"
;;
esac
[ "$Xoverip" = "yes" ] && [ "$Autochooseserver" = "no" ] && debugnote "Enabled X over TCP instead of sharing unix socket."
}

Expand Down Expand Up @@ -4746,6 +4761,7 @@ create_backendcommand() { ### create command to run docker
/proc|$Rootfs/proc
/dev|$Rootfs/dev
/run/shm|$Rootfs/run/shm"
Chrootmountlist=""
;;
esac

Expand Down Expand Up @@ -7799,9 +7815,12 @@ Fallback: using command '$Containercommand' and enabling option --interactive."
Sudouser="no"
Sharewebcam=""
;;
chrootXXX) ### FIXME
*)
error "Option --backend=$Backend: Backend $Backend is not supported."
;;
chroot) ### FIXME
warning "--backend=$Backend is highly experimental.
Rather use another backend. Even 'proot' is more stable.
Prefer to use another backend. Even 'proot' is more reliable.
Isolation is close to not existant."
[ -z "$Rootfs" ] && [ -d "$Hosthomebasefolder/ROOTFS/$Imagebasename" ] && Rootfs="$Hosthomebasefolder/ROOTFS/$Imagebasename"
[ -z "$Rootfs" ] && error "--backend=$Backend: Did not find a rootfs for $Imagename
Expand All @@ -7817,9 +7836,6 @@ Fallback: using command '$Containercommand' and enabling option --interactive."
}
Switchcontaineruser="yes"
;;
*)
error "Option --backend=$Backend: Backend $Backend is not supported."
;;
esac

# --no-setup
Expand Down Expand Up @@ -9780,15 +9796,14 @@ $(nl -ba <$Cmdrc)"
Target="$(cut -d'|' -f2 <<< "$Line")"
[ -d "$Source" ] && {
mkdir -v -p "$Target"
umount -f "$Target" || debugnote "umount failed on '$Target'"
mount --bind "$Source" "$Target" 2>> "$Containerlogfile" || error "--backend=$Backend: mount failed.
Last lines of log:
$(tail "$Containerlogfile")"
}
[ -S "$Source" ] && ln "$Source" "$Target"
[ -f "$Source" ] && ln "$Source" "$Target"
done <<< "$Chrootmountlist"
mount -t devpts devpts "$Rootfs/dev/pts" || error "--backend=$Backend: mount of devpts failed."
# mount -t devpts devpts "$Rootfs/dev/pts" || error "--backend=$Backend: mount of devpts failed."
;;
esac

Expand Down

0 comments on commit 42dfead

Please sign in to comment.