Web lists-archives.com

Re: HOWTO: Setup persistent RDP sessions




I found out that, in my system, `xrdp` runs the sesman protocol, and /etc/xrdp/sesman.ini specifies to run a file /etc/xrdp/startwm.sh:

$ cat /etc/xrdp/startwm.sh 

#!/bin/sh

. /etc/X11/Xsession

startxfce4


I found that /etc/X11/Xsession does not set $DISPLAY anyhow, although it loads some quite a few files, both systemwide and user specific, which could potentially define $DISPLAY. From what I checked, none of those files define $DISPLAY as of now. So /usr/bin/startxfce4 is the one defining $DISPLAY. Indeed, I found lines such as these:

if test "x$DISPLAY" = "x"

then

  echo "$0: Starting X server"

  prog=xinit

else

  echo "$0: X server already running on display $DISPLAY"

  prog=/bin/sh

fi


The webadmins to the servers told me that they'd rather not make complex/big changes to the servers as they are production servers, and are not quite open to testing out different setups. I proposed to edit the /etc/xrdp/startwm.sh such that `startxfce4` is called with an option for the $DISPLAY, which is calculated based on $UID. They disagree, as the server has quite a lot of users and the users are all temporary (about a year). Since $UID is simply an integer, that didn't seem a proper reason to disagree to my proposal. Alas, it seems I should still be able to set $DISPLAY in the files that /etc/X11/Xsession loads:

# initialize variables for use by all session scripts

OPTIONFILE=/etc/X11/Xsession.options

SYSRESOURCES=/etc/X11/Xresources

USRRESOURCES=$HOME/.Xresources

SYSSESSIONDIR=/etc/X11/Xsession.d

USERXSESSION=$HOME/.xsession

USERXSESSIONRC=$HOME/.xsessionrc

ALTUSERXSESSION=$HOME/.Xsession

ERRFILE=$HOME/.xsession-errors


Specifically, ~/.xsession or ~/.xsessionrc seems to be reasonable places. However, none of these seems to have been loaded in /usr/bin/startxfce4. Rather, it is running xfce4 specific xinitrc:

if [ -f $BASEDIR/xinitrc ]; then

  exec $prog $BASEDIR/xinitrc $CLIENTRC $SERVERRC

elif [ -f $HOME/.xfce4/xinitrc ]; then

  mkdir -p $BASEDIR

  cp $HOME/.xfce4/xinitrc $BASEDIR/

  exec $prog $BASEDIR/xinitrc $CLIENTRC $SERVERRC

else

  exec $prog /etc/xdg/xfce4/xinitrc $CLIENTRC $SERVERRC

fi


Neither $BASEDIR/xinitrc nor $HOME/.xfce4/xinitrc exists as of now, thus /etc/xdg/xfce4/xinitrc is ran by default. This file is quite long (abou 200 lines) but defiens DISPLAY nowhere. The most notable thing is it runs `xfce4-session` by itself, without any options. 


I think I laid out my system configurations to the best of my abilities, without adding too many useless information. I think I have three options here, though am not quite sure which would be simplest and works:

A) I could try setting creating ~/.xsession or ~/.xsessionrc where I set a DISPLAY number (setting it in ~/.xinitrc seems to have stopped X11 to open connection next time I connect from another computer);

B) I could create my own ~/.config/xfce4/xinitrc, which will be executed by startxfce4 as  $BASEDIR/xinitrc. There, I can copy the currently default /etc/xdg/xfce4/xinitrc to there, and specify a DISPLAY option for xfce4-sesion line;

C) Somehow, I could tell xfce4-session to always use the previous sessions saved in ~/.cache/sessions/ for a user, regardless of whether some optional parameters match, notably GEOMETRY etc. See contents of that file here:

cat ~/.cache/sessions/xfwm4-2e1965c2f-8b9b-4860-9173-6ba8cfa8cff1.state 

[CLIENT] 0x3c00008

  [CLIENT_LEADER] 0x3c00001

  [WINDOW_ROLE] gnome-terminal-window-dc448239-c1b8-472f-9760-764c4b353700

  [RES_NAME] gnome-terminal-server

  [RES_CLASS] Gnome-terminal

  [WM_NAME] someuser@somewhere: ~

  [WM_COMMAND] (1) "gnome-terminal-server"

  [GEOMETRY] (3,60,926,482)

  [GEOMETRY-MAXIMIZED] (3,60,737,431)

  [SCREEN] 0

  [DESK] 0

  [FLAGS] 0x10000



Not sure which would work, though I can test the first two myself, and not sure how to tell xfce4-session to always use previous session.


Best,
Hörmet
========================
He who is worthy to receive his days and nights is worthy to receive all
else from you (and me).
                                                 -- The Prophet, Gibran Kahlil



On Wed, Nov 1, 2017 at 4:29 AM, deloptes <deloptes@xxxxxxxxx> wrote:
Hörmetjan Yiltiz wrote:

> Seems like a very simple solution! Do you know if this works for RDP? And
> what runs that vnc-run.sh? Is it executed upon SSH login, VNC login, or by
> the admin?

The vnc-run.sh is my own script

To automate it, you need to modify the script starting the session on the
server. Unfortunately I don't know what how exactly works in your setup.
The RDP/VNC client needs a running vnc server, so I login to the server and
execute this vnc-run.sh.

The vncserver reads .vnc/xstartup which spawns the session and desktop.

example:
#!/bin/sh
xsetroot -solid grey
icewm &

When you find a way to automate it, please post back here.

regards