bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] Problems Using ⎕GTK


From: Bruce Frost
Subject: [Bug-apl] Problems Using ⎕GTK
Date: Thu, 22 Aug 2019 16:15:12 -0700
User-agent: Mutt/1.10.1 (2018-07-13)

I had trouble using the example of using ⎕GTK as in 
apl-1.8/HOWTOs/Quad-GTK.html and eventually discovered that the reason it 
wasn't working is that the environment variables passed to APL were not passed 
to Gtk_server.  My X (and Wayland) sessions are setup to run programs on 
multiple servers using the X11 XAUTHORITY environment setting.  I forward the 
credentials to remote systems via ssh, allowing me to run X applications on 
remote servers and have them appear on my local display.

The simplest solution is to use "xhost +" even when running programs on the 
local machine.  This is very dangerous on X11 as it allows X11 programs to 
connect from any account and from anywhere so I never do this.  The 
xauth/XAUTHORITY approach is safe because it requires access to files that are 
only readable by the X11/Wayland user.  However, there are other problems even 
in that case.

Problems:

1. The code in src/Gtk/Gtk_server.cc creates an environment with DISPLAY set to 
":0" which is only the default X server.  It is not the X server that you get 
if you are using ssh to forward the X server credentials or if you are running 
multiple X11 and/or Wayland sessions locally.

Solution: I removed that line from Gtk_server.cc.

2. The code in Quad_FIO.cc passes an empty environment to the processes that it 
creates.  This means that the XAUTHORITY, XAUTHLOCALHOSTNAME, DISPLAY and other 
session settings are not passed to child processes.  I am not aware of why you 
don't want to pass the session settings to children and recommend that if there 
are good reasons for not doing this to put some comments into the code about 
why it isn't being done (because foolish people like me will pick the simplest 
solution).

The simplest solution is to pass the APL environment to the child process by 
using the global variable environ (I suspect that the name of this global 
variable is system dependent).

My replacement to the do_FIO_57 function in Quad_FIO.cc looks something like:

#if 0  // no environment variables ...OR ..
   char * envp[] = { 0 };
#else  // APLs environment variables
   char **envp = environ;
#endif
   execve(filename, argv, envp);   // no return on success

If APL must not pass the full complement of environment variables to child 
processes, then at a minimum Gtk_server needs to receive the DISPLAY, 
XAUTHORITY and XAUTHLOCALHOST environment variables (which I also verified was 
sufficient to have X11 and Wayland sessions work on OpenSuSE Linux).

Finally, if you really don't want to make the change to do_FIO_57, then the 
connection to Gdk_server needs to pass DISPLAY, XAUTHORITY and XAUTHLOCALHOST 
from APL after the process has been created.

The HOWTOs/Quad-GTK.html examples then worked flawlessly.

Bruce Frost.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]