# Launching GUI apps from a jail to the desktop



## VucanRidr (Nov 16, 2021)

Hello,

I have been fighting an issue for a couple of weeks now, and I seem to be getting closer. I am trying to get the linux version of Kerbal Space Program running in a jail. To that end, I have managed to set up a Linux jail running Devuan Linux (Debian minus systemd), and I can ssh using X11 forwarding (-X) and trusted X11 forwarding (-Y) from my desktop. I am able to run xeyes on the jail, and have it displayed on my desktop...But when I try Kerbal or glxgears, I get the following error:


```
storm@brahms:/var/log$ glxgears
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  31
  Current serial number in output stream:  32
```


My graphics hardware is an nVidia GLX780Ti, and I am running the proprietary drivers. Can someone give me some guidance on why it is not working and what I can do to get it running?

Thanks,
--vr


----------



## SirDice (Nov 16, 2021)

VucanRidr said:


> and I can ssh using X11 forwarding (-X) and trusted X11 forwarding (-Y) from my desktop. I am able to run xeyes on the jail, and have it displayed on my desktop...But when I try Kerbal or glxgears, I get the following error


X forwarding doesn't support 3D (or 2D for that matter). It's information about widgets and windows only. Even bitmapped graphics are problematic (try playing a video over forwarded X to see what I mean).


----------



## Alain De Vos (Nov 16, 2021)

Even many editors fail to start correctly over x-forwarding.


----------



## VucanRidr (Nov 16, 2021)

Thanks guys. Is there an alternative method that I can use to do this? VNC or something like TightVNC? Can I possibly run the server in the jail and the client on the desktop machine?


----------



## kpedersen (Nov 16, 2021)

This should work. You can start the Xserver on the host and then `ln` (not ln -s) the /tmp/.X11-unix/X0 socket file to the Jail. Finally you can copy over the host user's .Xauthority file (to the user in the jail).

I use something similar to the following in part of a script (I use a chroot rather than a Jail but it should achieve similar).


```
ROOT=/jails/testjail

  cat /etc/hosts > "$ROOT/etc/hosts"
  cat /etc/resolv.conf > "$ROOT/etc/resolv.conf"

  mkdir -p "$ROOT/tmp/.X11-unix"
  SOCKS="$(ls /tmp/.X11-unix)"

  for SOCK in $SOCKS; do
    ln -f "/tmp/.X11-unix/$SOCK" "$ROOT/tmp/.X11-unix/$SOCK"
  done

  cat .Xauthority > "$ROOT/home/jail/.Xauthority"
  chroot "$ROOT" su -l jail
```

One catch is it needs to be on the same filesystem. FreeBSD does this by default (with UFS) these days so is less of a problem.

Whilst you are getting it to work, just expose everything in /dev to the Jail. Then once it is working you can decide the specific parts you need.


----------



## SirDice (Nov 16, 2021)

VucanRidr said:


> VNC or something like TightVNC?


Nice solutions but aren't capable of transmitting 3D or 2D graphics at a reasonable speed either. Works fine for basic desktop usage but nothing more than that.

I'd skip the jail entirely and just try to run the Linux game on /compat/linux directory. Then you'll be able to use the Linux compatibility of the NVidia driver directly on your Xserver.


----------



## VucanRidr (Nov 16, 2021)

That was what I was planning on doing in the first place. So how do I install the game in the /compat/linux directory and run it from there? I found some information on the linuxulator page (including installation of a /compat/ubuntu and adding user accounts), but I didn't find anything on actually using the user account or installing or using applications in that tree. I'm still relatively new to FreeBSD, so I thought going the jail route might work better. Obviously I was wrong.


----------

