Bug 611669

Summary: xrdp: execute startwm.sh under a login shell
Product: [Fedora] Fedora Reporter: Bojan Smojver <bojan>
Component: xrdpAssignee: Itamar Reis Peixoto <itamar>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 17CC: itamar, kirbyzhou, mads, william.ab.overstreet
Target Milestone: ---Keywords: Patch, Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: xrdp-0.5.0-0.11.03172010.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-17 00:00:22 UTC Type: ---
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
Have correct environment, even when using xinitrc
none
Have correct environment, even when using xinitrc none

Description Bojan Smojver 2010-07-06 05:32:51 UTC
Description of problem:
If this file is not executed, the environment is not quite correct. For instance, gnome-terminal will not pick up language settings.

Version-Release number of selected component (if applicable):
xrdp-0.5.0-0.6.20090811cvs.fc12.i686

How reproducible:
Always.

Steps to Reproduce:
1. Run xrdp.

Actual results:
Environment different from regular Gnome session.

Expected results:
Environment should match the one from a regular Gnome session.

Additional info:
--- /etc/xrdp/startwm.sh.o	2009-09-17 05:39:53.000000000 +1000
+++ /etc/xrdp/startwm.sh	2010-07-06 15:24:49.132095018 +1000
@@ -10,6 +10,13 @@
 #PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
 #export PATH=$PATH
 
+if [ -f /etc/profile ]; then
+	. /etc/profile
+fi
+if [ -f ~/.bash_profile ]; then
+	. ~/.bash_profile
+fi
+
 for WindowManager in $SESSIONS
 do
   which $WindowManager

Comment 1 Bojan Smojver 2010-07-06 06:58:57 UTC
Simpler fix:

diff -u /etc/xrdp/startwm.sh.o /etc/xrdp/startwm.sh
--- /etc/xrdp/startwm.sh.o	2009-09-17 05:39:53.000000000 +1000
+++ /etc/xrdp/startwm.sh	2010-07-06 16:50:45.926245031 +1000
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash -l
 
 # change the order in line below to run to run whatever window manager you
 # want, default to kde

Comment 2 Itamar Reis Peixoto 2010-07-07 03:24:14 UTC
(In reply to comment #1)
> -#!/bin/sh
> +#!/bin/bash -l

ok, I will apply it, thanks for the report.

In fedora sh is a symlink to bash, do you know which others operating systems where sh is not bash ?

Comment 3 Bojan Smojver 2010-07-07 03:44:13 UTC
Any Unix (e.g. Solaris) will generally have a non-bash default shell. At least that's how I remember it :-)

Comment 4 Fedora Update System 2010-07-09 17:52:08 UTC
xrdp-0.5.0-0.10.03172010.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/xrdp-0.5.0-0.10.03172010.fc12

Comment 5 Fedora Update System 2010-07-09 17:52:13 UTC
xrdp-0.5.0-0.10.03172010.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/xrdp-0.5.0-0.10.03172010.fc13

Comment 6 Bojan Smojver 2010-07-11 23:08:00 UTC
Invoking /bin/sh -l instead of /bin/bash -l will produce a slightly different result. Instead of calling ~/.bash_profile, ~/.profile will be called. Most people will likely have ~/.bash_profile in their home directories on Fedora (because that would have gotten copied from /etc/skel on account setup). ~/.bash_profile calls /etc/bashrc, which also does some setup (such as umask).

Comment 7 Fedora Update System 2010-07-13 07:23:09 UTC
xrdp-0.5.0-0.10.03172010.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update xrdp'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/xrdp-0.5.0-0.10.03172010.fc13

Comment 8 Fedora Update System 2010-07-13 07:46:07 UTC
xrdp-0.5.0-0.10.03172010.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update xrdp'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/xrdp-0.5.0-0.10.03172010.fc12

Comment 9 Kirby Zhou 2010-08-21 09:18:13 UTC
Another problem about startwm.sh.
With xrdp, it does start up any Input Method, such as SCIM.
Maybe we should call /etc/X11/xinit/xinitrc instead of start a Window Manager by startwm.sh itself.

Comment 10 Fedora Update System 2010-10-04 06:19:54 UTC
xrdp-0.5.0-0.11.03172010.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/xrdp-0.5.0-0.11.03172010.fc14

Comment 11 Fedora Update System 2010-10-04 06:20:01 UTC
xrdp-0.5.0-0.11.03172010.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/xrdp-0.5.0-0.11.03172010.fc13

Comment 12 Fedora Update System 2010-10-12 01:58:18 UTC
xrdp-0.5.0-0.11.03172010.fc13.1 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/xrdp-0.5.0-0.11.03172010.fc13.1

Comment 13 Itamar Reis Peixoto 2010-10-12 04:07:54 UTC
(In reply to comment #9)
> Another problem about startwm.sh.
> With xrdp, it does start up any Input Method, such as SCIM.
> Maybe we should call /etc/X11/xinit/xinitrc instead of start a Window Manager
> by startwm.sh itself.

what do you think about putting this 

#!/bin/sh
. /etc/X11/xinit/xinitrc

in startwm.sh ?

Comment 14 Kirby Zhou 2010-10-12 10:31:56 UTC
I think you should call call profile and something misc before xinitrc.

Comment 15 Fedora Update System 2010-10-29 20:42:04 UTC
xrdp-0.5.0-0.10.03172010.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2010-11-06 23:40:21 UTC
xrdp-0.5.0-0.11.03172010.fc13.1 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2010-11-18 23:59:32 UTC
xrdp-0.5.0-0.11.03172010.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Bojan Smojver 2010-12-17 02:05:31 UTC
Again a problem in F-14 with the latest update.

Path is incorrect inside xrdp session, because startwm.sh is not run under a login shell. The file /etc/X11/xinit/xinitrc is found when xorg-x11-xinit is installed (which will mostly be the case, because without this gdm cannot be there).

You need to execute that pre_start function before calling xinitrc, otherwise the environment doesn't get set up right.

Comment 19 Bojan Smojver 2010-12-17 02:39:32 UTC
(In reply to comment #18)

> You need to execute that pre_start function before calling xinitrc, otherwise
> the environment doesn't get set up right.

Actually, that doesn't work either. Digging...

Comment 20 Bojan Smojver 2010-12-17 02:43:07 UTC
(In reply to comment #19)
 
> Actually, that doesn't work either. Digging...

Changing the shell to login shell does (i.e. what I did in comment #1). I get correct paths set up once again.

Comment 21 Bojan Smojver 2010-12-17 06:01:04 UTC
Created attachment 469292 [details]
Have correct environment, even when using xinitrc

Comment 22 Bojan Smojver 2010-12-17 06:01:53 UTC
(In reply to comment #19)
 
> Actually, that doesn't work either. Digging...

That would be because I'm an idiot. Functions need to be defined before they are used in shell. See the patch.

Comment 23 Bojan Smojver 2011-07-08 01:26:40 UTC
Moving this to F-15. Any chance we see this patched up?

Comment 24 Itamar Reis Peixoto 2011-07-08 10:57:01 UTC
yes, I will do it.

Comment 25 Bojan Smojver 2011-11-01 01:07:18 UTC
Still a problem in F-16. Moving to that.

Comment 26 William Overstreet 2012-02-22 21:07:57 UTC
It's a pam configuration issue. sesman has it's own pam configuration. It's not set up to read the environment on login, as it's not required per the configuration. At some point in the sesman pam configuration, `pam_env.so` needs to be 'required'. Probably as part of session or auth.

Comment 27 Bojan Smojver 2012-05-24 01:12:46 UTC
Moving to F-17. Will attach a patch that would fix this trivially in the xrdp.spec file.

Comment 28 Bojan Smojver 2012-05-24 01:14:53 UTC
Created attachment 586502 [details]
Have correct environment, even when using xinitrc

Instead of changing startwm.sh, we can simply execute it form another, bash specific script, with environment already set. This would be Fedora specific, so no need to push anything upstream, where bash may not be available etc.

Comment 29 Fedora Update System 2012-05-28 00:50:00 UTC
xrdp-0.6.0-0.5.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/xrdp-0.6.0-0.5.fc17

Comment 30 Fedora Update System 2012-05-29 10:29:34 UTC
Package xrdp-0.6.0-0.5.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing xrdp-0.6.0-0.5.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-8538/xrdp-0.6.0-0.5.fc17
then log in and leave karma (feedback).

Comment 31 Fedora Update System 2012-06-17 00:00:22 UTC
xrdp-0.6.0-0.5.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.