mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

Same command behaves differently from a script #52

Closed jcalfee closed 6 years ago

jcalfee commented 6 years ago

This command runs a workable xpra window:

james@librem:~$ x11docker --clipboard atom &
[1] 19014
james@librem:~$ Warning: invalid option: 'shadow-fullscreen'
x11docker note: Using X server option --xpra

x11docker WARNING: Your host X server seems to run without cookie authorisation.

x11docker note: Stay tuned, xpra will start soon.

The same command from a script runs a weston-xwayland (showing me 2 title bars):

james@librem:~$ echo 'x11docker --clipboard atom &' > tmp.sh 
james@librem:~$ sh ./tmp.sh 
james@librem:~$ x11docker note: Using X server option --weston-xwayland

x11docker note: Sharing picture clips with option --clipboard
  is only possible with options --xpra, --xpra-xwayland and --hostdisplay.

x11docker WARNING: Your host X server seems to run without cookie authorisation.

x11docker note: Looking for windowmanager linked with x-window-manager.
  You can set the default one detected in auto mode with
    update-alternatives --config x-window-manager

x11docker note: Using host window manager /usr/bin/xfwm4

Why does the same command behave differently when ran from a script?

bash ./tmp.sh choose weston-xwayland..

mviereck commented 6 years ago

That is strange. I cannot reproduce it, I get xpra in both cases as expected. What happens if you specify --xpra, does it show a failure?

echo 'x11docker --clipboard --xpra atom &' > tmp.sh 
sh ./tmp.sh 

If this does not give a useful hint, please show me the output with option --verbose.

jcalfee commented 6 years ago
$ echo 'x11docker --clipboard --xpra atom &' > tmp.sh 
$ ./tmp.sh 
james@librem:~$ Warning: invalid option: 'shadow-fullscreen'
x11docker WARNING: Your host X server seems to run without cookie authorisation.

x11docker note: Stay tuned, xpra will start soon.
mviereck commented 6 years ago

xpra runs well if you use --xpra?

Another curious thing is the output Warning: invalid option: 'shadow-fullscreen', it is not from x11docker. Maybe you have some outdated configuration in /etc/xpra/xpra.conf. Does the error show up, too, if you run xpra --version? But this should not influence the choice of either --xpra or --weston-xwayland.

Can you please show me the output of:

james@librem:~$ echo 'x11docker --verbose --clipboard atom &' > tmp.sh 
james@librem:~$ sh ./tmp.sh 
jcalfee commented 6 years ago

--xpra runs very well for an editor. I can resize the outer window and see flickering as it repaints, so it is not native speed. It is however fine for an app like this. Only 1 title bar that is part of the native OS. The window has all the hosts OS features including full screen..

--weston-xwayland is one big window that can not be re-sized then an inner window with the app. If I use full screen on the inner app it could be work-able except that the main window is not re-sizable. Resizing the app (inner window) is much more responsive than the --xpra window. It is of course better for desktops.

Interesting, xpra version did show the Warning: invalid option: 'shadow-fullscreen' warning. I have commented out this setting in /etc/xpra/xpra.conf to fix this.

Here is the log for echo 'x11docker --verbose --clipboard atom &' > tmp.sh, startup and shutdown: https://pastebin.com/ZtWqkFkU

mviereck commented 6 years ago

Maybe I found the reason. x11docker checks the output of tty to check if it runs on tty or not. On tty/console, it decides to use --weston-xwayland. Your logfile shows that x11docker believes to run on tty/console.

My output of sh -c tty is /dev/pts/0. Can you show me the output of:

bash -c tty
sh -c tty
jcalfee commented 6 years ago
james@librem:~$ bash -c tty
/dev/pts/2
james@librem:~$ sh -c tty
/dev/pts/2
mviereck commented 6 years ago

It is confusing. Can you check this?

# x11docker checks for tty and ssh with this code:
pstree -ps $$ | grep -q sshd && Ssh="yes" || Ssh="no"  # check if running over SSH
tty | grep -q tty            && Tty="yes" || Tty="no"  # check if running on X or on tty
[ "$Tty" = "no" ] && [ -z "$DISPLAY" ] && [ "$Ssh" = "yes" ] && Tty="yes"

# check result:
echo "tty: $Tty"
echo "ssh: $Ssh"

With $Tty = yes x11docker uses --weston-xwayland. With $Tty = no x11docker runs--xpra.

The logfile shows:

  Running on console:                             yes
  Running over SSH:                               no

That would mean that tty | grep -q tty succeeds. But due to your last post with output /dev/pts/2 it should not.

jcalfee commented 6 years ago

$ echo "tty: $Tty" tty: no $ echo "ssh: $Ssh" ssh: no

mviereck commented 6 years ago

Can you put the code in a file and run it with sh? It does not make a difference here, but maybe on you system for obscure reasons.

x11docker reduced on the deciding part:

$ echo '#! /bin/bash
tty | grep -q tty            && Tty="yes" || Tty="no"  # check if running on X or on tty
echo $Tty
' > tmp.sh

$ sh tmp.sh
jcalfee commented 6 years ago
$ echo '#! /bin/bash
> tty | grep -q tty            && Tty="yes" || Tty="no"  # check if running on X or on tty
> echo $Tty
> ' > tmp.sh
$ sh ./tmp.sh 
no
mviereck commented 6 years ago

I have only one idea left. Your logfile shows Running on console: yes, but your last check says no. I only see one last difference: In your first post you start x11docker as a background job with &. Is there a difference if you run sh ./tmp.sh &?

jcalfee commented 6 years ago

I get a no when I run x11docker in the background and re-run the latest tmp.sh .. Another variable, I log into Debian using "Gnome on Wayland" .. This feature is available after installing from the live installer iso. I just re-tested and I get the same behavior described in the initial issue.

mviereck commented 6 years ago

I tried Gnome-Wayland session with gnome-terminal on debian 9 and on fedora 28 and still cannot reproduce the issue. Regardless what I try, I always get a /dev/pts/N output from command tty. And x11docker always runs --xpra, if started directly, or in a script, or in a script in background.

How exactly do you get an output of command tty containing the keyword tty?

jcalfee commented 6 years ago

Not sure I understand your question .. Looks like I'm running tty and not something else:

$ which tty
/usr/bin/tty
$ /usr/bin/tty
/dev/pts/3

Lets just close the ticket unless someone else reports the issue.. There is an easy work around.

mviereck commented 6 years ago

Not sure I understand your question

Depending on the output of command tty x11docker decides to run --xpra or --weston-xwayland. If the output of command tty contains the keyword tty like in /dev/tty2, x11docker will run --weston-xwayland. Otherwise, with e.g. /dev/pts/3, it will run --xpra.

Lets just close the ticket unless someone else reports the issue..

ok.