From orion@cora.nwra.com  Tue Aug 25 19:28:13 2015
Received: (at submit) by bugs.x2go.org; 25 Aug 2015 17:28:15 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED
	autolearn=ham version=3.3.2
Received: from mail.nwra.com (mail.nwra.com [72.52.192.72])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 334B05DA80
	for <submit@bugs.x2go.org>; Tue, 25 Aug 2015 19:28:12 +0200 (CEST)
Received: from [10.10.20.7] (NORTHWEST-R.edge3.Denver1.Level3.net [4.28.99.98])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mail.nwra.com (Postfix) with ESMTPSA id 24C3134046D
	for <submit@bugs.x2go.org>; Tue, 25 Aug 2015 10:28:10 -0700 (PDT)
To: submit@bugs.x2go.org
From: Orion Poplawski <orion@cora.nwra.com>
Subject: x2goclient 4.0.5.0 overwrites user's shell
Message-ID: <55DCA5A2.2010802@cora.nwra.com>
Date: Tue, 25 Aug 2015 11:28:02 -0600
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.2.0
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="------------060304090003050109000704"

This is a multi-part message in MIME format.
--------------060304090003050109000704
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Package: x2goclient
Version: 4.0.5.0
Tags: patch

See https://bugzilla.redhat.com/show_bug.cgi?id=1256799

Description of problem:
After upgrading x2goclient my system assigned shell of /bin/zsh is ignored and
forcefully set to /bin/bash

The shift to running everything under /bin/bash had the side effect of setting
SHELL to /bin/bash, which is then what terminal emulators and others use for
spawning shells.

If we specify -l to bash it runs as a login shell, sources the proper startup
files and sets SHELL to whatever getpwent() returns for the login shell.

However, this also opens the door for things like ~/.bash_logout to get run
which executes "clear", which emits:

TERM environment variable not set.

when TERM is empty as it is here.  So we also set TERM=dumb to work around that.


It might be nice to add the ability to distinguish between a session startup
command and other utility commands (x2gomountdirs, etc.) and only add -l to
the session startup commands.  This is probably more appropriate.

-- 
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       orion@nwra.com
Boulder, CO 80301                   http://www.nwra.com

--------------060304090003050109000704
Content-Type: text/x-patch;
 name="x2goclient-shell.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="x2goclient-shell.patch"

diff --git a/src/sshprocess.cpp b/src/sshprocess.cpp
index 4866c2b..2e599b5 100644
--- a/src/sshprocess.cpp
+++ b/src/sshprocess.cpp
@@ -200,8 +200,8 @@ void SshProcess::startNormal(const QString& cmd)
 // #endif
     if(!masterCon->useKerberos())
     {
-        QString shcmd = "bash -c 'echo \"X2GODATABEGIN:" + uuidStr + "\"; export PATH=\"/usr/local/bin:/usr/bin:/bin\"; "+cmd+"; echo \"X2GODATAEND:" + uuidStr + "\";'";
-        x2goDebug << "Running masterCon->addChannelConnection(this, '" << uuidStr << "', '" << shcmd.left (200) << "');";
+        QString shcmd = "bash -l -c 'echo \"X2GODATABEGIN:" + uuidStr + "\"; export PATH=\"/usr/local/bin:/usr/bin:/bin\"; export TERM=dumb; "+cmd+"; echo \"X2GODATAEND:" + uuidStr + "\";'";
+        x2goDebug << "this="<<this<<" Running masterCon->addChannelConnection(this, '" << uuidStr << "', '" << shcmd.left (200) << "');";
         masterCon->addChannelConnection(this, uuidStr, shcmd);
         connect(masterCon,SIGNAL(stdOut(SshProcess*,QByteArray)),this,SLOT(slotStdOut(SshProcess*,QByteArray)));
         connect(masterCon,SIGNAL(channelClosed(SshProcess*,QString)), this,SLOT(slotChannelClosed(SshProcess*,QString)));
@@ -222,7 +222,7 @@ void SshProcess::startNormal(const QString& cmd)
          * as there is no preceding "outer double quote" the whole argument
          * is wrapped in.
          */
-        shcmd = "bash -c 'echo \"X2GODATABEGIN:" + uuidStr + "\"; export PATH=\"/usr/local/bin:/usr/bin:/bin\"; "+cmd+"; echo \"X2GODATAEND:" + uuidStr + "\";'";
+        shcmd = "bash -l -c 'echo \"X2GODATABEGIN:" + uuidStr + "\"; export PATH=\"/usr/local/bin:/usr/bin:/bin\"; export TERM=dumb; "+cmd+"; echo \"X2GODATAEND:" + uuidStr + "\";'";
 
         proc=new QProcess(this);
         QString local_cmd = "";

--------------060304090003050109000704--

