Bug 1038834

Summary: /etc/x2go/Xsession script broken
Product: [Fedora] Fedora Reporter: Reilly Hall <sly.midnight>
Component: x2goserverAssignee: Orion Poplawski <orion>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: orion
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: x2goserver-4.0.1.13-2.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-07 03:12:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Proposed Xsession file
none
New proposed Xsession file none

Description Reilly Hall 2013-12-05 23:00:41 UTC
Description of problem:
x2go server and client setup and working easily.

However I noticed that some programs no longer run even though they are installed.
Upon further investigation turns out to be a problem with the PATH environment variable.
It is set correct when I login via ssh and with NoMachine but not via x2go.
/etc/profile is properly called from /etc/x2go/Xsession and sources it and the PATH (and other) variable(s) get set but then a command is called that does not exist $(tempfile) that causes the script to exit prematurely and the session starts apparently abandoning the environment.  Commenting line 101 out causes the session to start and exit immediately.  Only after changing the final "exit 0" o an "exit 1" does the session start, but even though echoing the contents of $PATH from that script outputs the correct PATH contents to ~/.xsession-x2go-errors, within the session only a stripped down PATH is set and many other variables are missing.


Version-Release number of selected component (if applicable):
x2goserver-4.0.1.6-5.fc19.x86_64

How reproducible:
Every time.

Steps to Reproduce:
1. Install x2goserver and x2goclient
2. Use client to connect to remote server
3. Check PATH variable and notice it is not the same as a raw SSH shell session.

Actual results:
x2go Xsession script not running correctly and /etc/profile variable not being parsed and kept correctly.

Expected results:
Mostly the same behavior as NoMachine or any normal login environment.

Additional info:
Output of said log:
XSession-x2go: X session started for sly at Thu Dec  5 17:36:39 EST 2013
/etc/x2go/Xsession: line 101: tempfile: command not found

Echoing $PATH and $HOSTNAME from within Xsession shows correct variable contents:
XSession-x2go: X session started for sly at Thu Dec  5 17:21:44 EST 2013
/usr/lib64/qt-3.3/bin:/usr/NX/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
Kentsfield.MidnightNetworks.com

But within session no $HOSTNAME and $PATH is only:
/usr/lib64/qt-3.3/bin:/usr/NX/bin:/usr/local/bin:/usr/bin

Comment 1 Reilly Hall 2013-12-06 21:32:41 UTC
Proposing some changes I found ultimately worked for me but am unsure if they are portable to other users with other desktop environment choices other than KDE and shells different than zsh.

The diff from my modified Xsession file as compared to the original:

diff Xsession Xsession.ori 
51a52,59
> # Load profile
> for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
>     if [ -f "$file" ]; then
>         echo "Loading profile from $file";
>         . "$file"
>     fi
> done
> 
81,90d88
< # Load profile
< set +e
< for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile" "/etc/zprofile"; do
<     if [ -f "$file" ]; then
<         echo "Loading profile from $file";
<         . "$file"
<     fi
< done
< set -e
< 
103,108c101,106
< #WRITE_TEST=$(tempfile)
< #if ! echo "*" >>"$WRITE_TEST"; then
< #  message "warning: unable to write to ${WRITE_TEST%/*}; X session (X2Go) may" \
< #          "exit with an error"
< #fi
< #rm -f "$WRITE_TEST"
---
> WRITE_TEST=$(tempfile)
> if ! echo "*" >>"$WRITE_TEST"; then
>   message "warning: unable to write to ${WRITE_TEST%/*}; X session (X2Go) may" \
>           "exit with an error"
> fi
> rm -f "$WRITE_TEST"
116c114
< #SYSSESSIONDIR=/etc/x2go/Xsession.d
---
> SYSSESSIONDIR=/etc/x2go/Xsession.d
118c116
< #SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
---
> SESSIONFILES=$(run-parts --list $SYSSESSIONDIR)
131,135c129
< # Explicitly call startup command rather than exit with an error.
< exec $STARTUP
< 
< # Unsure why but cannot exit with zero status or session never starts.
< #exit 1
---
> exit 0

Comment 2 Reilly Hall 2013-12-06 21:35:06 UTC
Created attachment 833776 [details]
Proposed Xsession file

Here is my full Xsession file as I have modified it from the original to allow it to work more or less correctly with KDE and zsh.

Comment 3 Orion Poplawski 2013-12-07 06:24:12 UTC
Can you first try https://admin.fedoraproject.org/updates/FEDORA-2013-22479/x2goserver-4.0.1.9-1.fc19 and see if that helps.  That should at least remove the $(tempfile) problem.

Comment 4 Reilly Hall 2013-12-07 17:10:48 UTC
Ok, the Xsession script behaves just as it did when I commented out the original line 101 using the $(tempfile) command.  It completes and the session never opens with the client stating "finished".  If I modify the last exit 0 to an exit 1 (exit by itself also doesn't work) then the KDE session starts.  But again the environment variables sourced by Xsessions sourcing of /etc/profile are somehow lost.

Comment 5 Orion Poplawski 2013-12-08 05:36:44 UTC
Okay, looks like whole Xsession stuff is just way too Debian specific.  I've ripped it out and we'll see how that goes.

Comment 6 Fedora Update System 2013-12-08 05:42:26 UTC
x2goserver-4.0.1.9-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/FEDORA-2013-22479/x2goserver-4.0.1.9-2.fc19

Comment 7 Reilly Hall 2013-12-08 14:59:06 UTC
Would you like me to try x2goserver-4.0.1.9-2?

Comment 8 Reilly Hall 2013-12-08 15:21:24 UTC
I took the liberty to try x2goserver04.0.1.9-2 and while the session does start up now, of course there is no /etc/profile|/etc/zprofile information present in my environment.  So for the time being I've reverted back to the stock version and copied back my proposed version of Xsession that at least does work for me.

I will keep an eye out for the next version to test.  Thanks!

Comment 9 Reilly Hall 2013-12-08 15:27:46 UTC
Created attachment 834084 [details]
New proposed Xsession file

I decided to update my Xsession with the changes you proposed and uncommented out all the logic to deal with no free space using the mktemp command rather than tempfile.  Am uploading my new proposed changes to Xsession.

Comment 10 Fedora Update System 2013-12-09 02:05:18 UTC
Package x2goserver-4.0.1.9-2.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing x2goserver-4.0.1.9-2.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-22479/x2goserver-4.0.1.9-2.fc19
then log in and leave karma (feedback).

Comment 11 Fedora Update System 2014-01-03 20:18:34 UTC
x2goserver-4.0.1.10-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.10-1.fc19

Comment 12 Fedora Update System 2014-01-03 20:18:44 UTC
x2goserver-4.0.1.10-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.10-1.el6

Comment 13 Fedora Update System 2014-01-03 20:18:52 UTC
x2goserver-4.0.1.10-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.10-1.fc20

Comment 14 Fedora Update System 2014-01-13 02:55:51 UTC
x2goserver-4.0.1.10-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2014-01-13 03:01:19 UTC
x2goserver-4.0.1.10-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Reilly Hall 2014-01-13 16:33:33 UTC
I updated to x2goserver-4.0.1.10-1.fc20 and now I am back to not having the correct environment set.  I am reopening the ticket as I believe the purpose of this ticket was to address the lack of a properly setup environment for the logged in user.  I have downgraded back to the prior version and copied over my custom Xsession file that mostly works for me.

Comment 17 Fedora Update System 2014-01-18 20:36:02 UTC
x2goserver-4.0.1.10-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Reilly Hall 2014-01-20 17:09:15 UTC
Re-opened as it appears to have been closed when the EPEL6 repo got the same update as well.

Comment 19 Fedora Update System 2014-01-27 04:15:21 UTC
x2goserver-4.0.1.13-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.13-1.fc20

Comment 20 Fedora Update System 2014-01-27 13:02:03 UTC
Package x2goserver-4.0.1.13-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing x2goserver-4.0.1.13-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-1584/x2goserver-4.0.1.13-1.fc20
then log in and leave karma (feedback).

Comment 21 Orion Poplawski 2014-01-27 14:08:09 UTC
Upstream has made some changes to the xsession handling for Fedora.  I've re-enabled and shipped as a sub-package also like upstream.  Please test.

Comment 22 Reilly Hall 2014-01-27 17:09:04 UTC
Good afternoon,

I am pleased to say I have tested the new version and while it did not work on initial testing, after reviewing the new Xsession script included I was able to make it work with a simple change around line 177 (noted the error in the user's log file).  The change is simple as such:

89a90
> 
177,179c178
< 		if [ -r $file ]; then
< 			. $file
< 		fi
---
> 		. $file

Thanks again for the update!  With that simple change I can confirm it works.  It may be preferable to use some sort of error handling so no errors incurred by other commands (in this case caused by a simple benign no files found in the directory referenced being called) causes the script to bomb and loose the environment that it was trying to pull in.

Comment 23 Orion Poplawski 2014-01-27 17:46:43 UTC
Hmm, the other fix is probably:

@@ -174,8 +174,8 @@ elif [ -f /etc/redhat-release ]; then
        unset XKB_IN_USE

        # run all system xinitrc shell scripts.
-       for file in /etc/x2go/xinit/xinitrc.d/* ; do
-               . $file
+       for file in /etc/x2go/xinitrc.d/* ; do
+               [ -r "$file" ] && . $file
        done

        # Prefix launch of session with ssh-agent if available and not already running.

Looks like the path was wrong.

Comment 24 Reilly Hall 2014-01-27 18:44:08 UTC
Ah sorry, didn't bother to look there and see that the path was wrong,  Just assumed it was a location for custom scripts of which I have none.  Thanks for catching that and I prefer your shorter cleaner syntax.

Comment 25 Reilly Hall 2014-01-27 18:45:22 UTC
Comment on attachment 834084 [details]
New proposed Xsession file

Not needed anymore.

Comment 26 Fedora Update System 2014-01-27 19:21:10 UTC
x2goserver-4.0.1.13-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.13-2.fc19

Comment 27 Fedora Update System 2014-01-27 19:21:18 UTC
x2goserver-4.0.1.13-2.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.13-2.el6

Comment 28 Fedora Update System 2014-01-27 19:21:28 UTC
x2goserver-4.0.1.13-2.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/x2goserver-4.0.1.13-2.fc20

Comment 29 Fedora Update System 2014-02-07 03:12:53 UTC
x2goserver-4.0.1.13-2.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 30 Fedora Update System 2014-02-14 20:56:28 UTC
x2goserver-4.0.1.13-2.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 31 Fedora Update System 2014-02-15 06:59:11 UTC
x2goserver-4.0.1.13-2.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.