Bug 611669 - xrdp: execute startwm.sh under a login shell
xrdp: execute startwm.sh under a login shell
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: xrdp (Show other bugs)
17
All Linux
low Severity medium
: ---
: ---
Assigned To: Itamar Reis Peixoto
Fedora Extras Quality Assurance
: Patch, Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-06 01:32 EDT by Bojan Smojver
Modified: 2012-06-16 20:00 EDT (History)
4 users (show)

See Also:
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-16 20:00:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Have correct environment, even when using xinitrc (1.08 KB, patch)
2010-12-17 01:01 EST, Bojan Smojver
no flags Details | Diff
Have correct environment, even when using xinitrc (939 bytes, patch)
2012-05-23 21:14 EDT, Bojan Smojver
no flags Details | Diff

  None (edit)
Description Bojan Smojver 2010-07-06 01:32:51 EDT
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 02:58:57 EDT
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-06 23:24:14 EDT
(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-06 23:44:13 EDT
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 13:52:08 EDT
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 13:52:13 EDT
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 19:08:00 EDT
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 03:23:09 EDT
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 03:46:07 EDT
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 05:18:13 EDT
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 02:19:54 EDT
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 02:20:01 EDT
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-11 21:58:18 EDT
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 00:07:54 EDT
(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 06:31:56 EDT
I think you should call call profile and something misc before xinitrc.
Comment 15 Fedora Update System 2010-10-29 16:42:04 EDT
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 19:40:21 EDT
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 18:59:32 EST
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-16 21:05:31 EST
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-16 21:39:32 EST
(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-16 21:43:07 EST
(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 01:01:04 EST
Created attachment 469292 [details]
Have correct environment, even when using xinitrc
Comment 22 Bojan Smojver 2010-12-17 01:01:53 EST
(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-07 21:26:40 EDT
Moving this to F-15. Any chance we see this patched up?
Comment 24 Itamar Reis Peixoto 2011-07-08 06:57:01 EDT
yes, I will do it.
Comment 25 Bojan Smojver 2011-10-31 21:07:18 EDT
Still a problem in F-16. Moving to that.
Comment 26 William Overstreet 2012-02-22 16:07:57 EST
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-23 21:12:46 EDT
Moving to F-17. Will attach a patch that would fix this trivially in the xrdp.spec file.
Comment 28 Bojan Smojver 2012-05-23 21:14:53 EDT
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-27 20:50:00 EDT
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 06:29:34 EDT
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-16 20:00:22 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.