RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 949522 - vncserver start-up script fails
Summary: vncserver start-up script fails
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tigervnc
Version: 6.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Tim Waugh
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
: 1030747 (view as bug list)
Depends On: 562669 768405
Blocks: 994246
TreeView+ depends on / blocked
 
Reported: 2013-04-08 11:22 UTC by Bob Tennent
Modified: 2018-12-09 16:59 UTC (History)
6 users (show)

Fixed In Version: tigervnc-1.1.0-9.el6
Doc Type: Bug Fix
Doc Text:
The vncserver initscript made an assumption about the preferred shell for users of TigerVNC, causing configured displays not to be started for users not using bash as their preferred shell. This has been fixed.
Clone Of:
Environment:
Last Closed: 2014-10-14 04:39:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
log file (7.40 KB, text/x-log)
2013-04-08 11:22 UTC, Bob Tennent
no flags Details
just let vncserver fail if no passwd file (606 bytes, text/plain)
2013-11-18 19:14 UTC, John Hein
no flags Details
Here is the change I plan to make (677 bytes, patch)
2014-04-03 15:26 UTC, Tim Waugh
no flags Details | Diff
Here is the change I plan to make (sorry, missed a bit in the last one) (1.87 KB, patch)
2014-04-03 15:34 UTC, Tim Waugh
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1412 0 normal SHIPPED_LIVE tigervnc bug fix update 2014-10-14 01:11:08 UTC

Description Bob Tennent 2013-04-08 11:22:45 UTC
Created attachment 732654 [details]
log file

Description of problem:
vncserver start-up script fails

Version-Release number of selected component (if applicable):1.1.0-5


How reproducible:

Reproduced on 2 systems. 


Steps to Reproduce:

1.add VNCSERVERS="5:rdt" to /etc/sysconfig/vncservers

2./etc/init.d/vncserver start

  
Actual results:

Starting VNC server: 5:rdt :0
Invalid null command.
if: Expression Syntax.
xauth:  timeout in locking authority file /root/.xauthtYmnNB

New 'jimmy:5 (rdt)' desktop is jimmy:5

Starting applications specified in /home/rdt/.vnc/xstartup
Log file is /home/rdt/.vnc/jimmy:5.log

else: endif not found.
                                                           [FAILED]




Expected results:

Starting VNC server: 5:rdt 

New 'jimmy:5 (rdt)' desktop is jimmy:5

Starting applications specified in /home/rdt/.vnc/xstartup
Log file is /home/rdt/.vnc/jimmy:5.log

                                                           [  OK  ]

Additional info:

Despite the FAILED message, the Xvnc process is started.

Hand-starting vncserver :5 works.

The vncserver start-up script in tigervnc-server-1.0.90-0.17.20110314svn4359 
works.

Comment 2 Tim Waugh 2013-05-22 16:05:21 UTC
Those error messages look like they come from the C shell, tcsh.  Have you changed the system shell to tcsh, or else is rdt's shell set to tcsh?  Just trying to understand how to reproduce the problem myself.

Comment 3 Bob Tennent 2013-05-22 19:03:35 UTC
 > is rdt's shell set to tcsh? 

Yes.  The problem is clearly in lines 54-61, which are executed as ${USER}. 
Earlier versions were shell-agnostic.

Comment 4 Tim Waugh 2013-05-24 14:17:26 UTC
OK, I see it. Thanks.

Comment 6 sairamb_143 2013-09-08 08:47:21 UTC
Please  privide me the script we  are having same problem we have installed SAP and users will be creating under c shell by the installation.vnc server has been configured ,it runs perfectly with one user (i.e iam able to start the vncserver script without the error)but when it is configured for other  user that belongs to c shell it is giving me error

Comment 7 RHEL Program Management 2013-10-13 23:43:49 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 8 Tim Waugh 2013-11-18 12:34:41 UTC
*** Bug 1030747 has been marked as a duplicate of this bug. ***

Comment 9 John Hein 2013-11-18 19:14:06 UTC
Created attachment 825796 [details]
just let vncserver fail if no passwd file

I've been using this patch for a while now.  Copied from bug 1030747 that I submitted before seeing this bug.

Comment 10 Tobias Oed 2014-02-05 10:00:35 UTC
I just made up this patch before seeing this bug

[root@raoultella init.d]# diff vncserver.orig vncserver -ubB
--- vncserver.orig	2014-02-05 10:52:53.449368175 +0100
+++ vncserver	2014-02-05 10:50:56.263368429 +0100
@@ -50,7 +50,7 @@
 	DISP="${display%%:*}"
 	USER="${display##*:}"
 	VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
-        runuser -l ${USER} -c \
+        runuser -l ${USER} -s /bin/bash -c \
 		"cd ~${USER} &&
 		 if [ -r .vnc/passwd ]; then
 			 vncserver :${DISP} ${VNCUSERARGS}


Tobias

Comment 11 John Hein 2014-02-05 20:11:08 UTC
(In reply to Tobias Oed from comment #10)
> I just made up this patch before seeing this bug
> 
> [root@raoultella init.d]# diff vncserver.orig vncserver -ubB
> --- vncserver.orig	2014-02-05 10:52:53.449368175 +0100
> +++ vncserver	2014-02-05 10:50:56.263368429 +0100
> @@ -50,7 +50,7 @@
>  	DISP="${display%%:*}"
>  	USER="${display##*:}"
>  	VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
> -        runuser -l ${USER} -c \
> +        runuser -l ${USER} -s /bin/bash -c \
>  		"cd ~${USER} &&
>  		 if [ -r .vnc/passwd ]; then
>  			 vncserver :${DISP} ${VNCUSERARGS}
> 
> 
> Tobias

That forces your vnc environment to have SHELL set to /bin/bash which may not be desirable (usually isn't if your default shell is /bin/csh, for instance).

Comment 13 Filip Krska 2014-04-03 10:38:06 UTC
(In reply to John Hein from comment #11)
> (In reply to Tobias Oed from comment #10)
> > I just made up this patch before seeing this bug
> > 
> > [root@raoultella init.d]# diff vncserver.orig vncserver -ubB
> > --- vncserver.orig	2014-02-05 10:52:53.449368175 +0100
> > +++ vncserver	2014-02-05 10:50:56.263368429 +0100
> > @@ -50,7 +50,7 @@
> >  	DISP="${display%%:*}"
> >  	USER="${display##*:}"
> >  	VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
> > -        runuser -l ${USER} -c \
> > +        runuser -l ${USER} -s /bin/bash -c \
> >  		"cd ~${USER} &&
> >  		 if [ -r .vnc/passwd ]; then
> >  			 vncserver :${DISP} ${VNCUSERARGS}
> > 
> > 
> > Tobias
> 
> That forces your vnc environment to have SHELL set to /bin/bash which may
> not be desirable (usually isn't if your default shell is /bin/csh, for
> instance).

We need to assure, that the command supplied after -c is properly executed. It has nothing to do with user's or root's shell preferences (-s ${SHELL}), IMHO it must be the shell which the command is written in. So if #!/bin/bash is the hashbang of /etc/init.d/vncserver, I see nothing wrong with enforcing /bin/bash as a shell for runuser command as well.

Another approach would be to use command without any shell specific constructions.

Comment 14 Bob Tennent 2014-04-03 13:30:55 UTC
It's the if ... then ... else that's the problem.  Just test for non-existence of the passwd file separately:

 runuser -l ${USER} -c \
    "cd ~${USER} && [ ! -r .vnc/passwd ] && (echo ; echo VNC password for user ${USER} is not configured; exit 1)"
 runuser -l ${USER} -c \
                "cd ~${USER} && [ -r .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"

Comment 15 Tim Waugh 2014-04-03 15:26:52 UTC
Created attachment 882348 [details]
Here is the change I plan to make

Comment 16 Tim Waugh 2014-04-03 15:34:42 UTC
Created attachment 882362 [details]
Here is the change I plan to make (sorry, missed a bit in the last one)

Comment 17 John Hein 2014-04-03 16:19:04 UTC
Warning and apologies - The comment herein is slightly off the main topic for this bug.  The following is just in response to a comment in this thread that will hopefully clarify some apparent misconceptions:

@Filip in comment 13.  I think you misunderstand the ramifications of the -s and what runuser does.  You can use runuser to execute any shell script from any shell you specify with -s.

example:

cat > somecsh << eof
#!/bin/csh -f
setenv FOO bar
printenv SHELL
printenv FOO
eof
chmod a+x somecsh

If you try to run this with bourne shell, it will fail of course:

sh somecsh
somecsh: line 2: setenv: command not found


But you can use runuser to execute that script with either -s /bin/csh or -s /bin/sh, and it will work fine.  Try it yourself:

sudo runuser -s /bin/csh -c ./somecsh joe_regular_user
/bin/csh
bar

sudo runuser -s /bin/sh -c ./somecsh joe_regular_user
/bin/sh
bar

The problem in this case is that you are starting a vnc session and all children inherit the SHELL environment variable.  So even if /etc/passwd specifies /bin/csh, any terminal window started under a vnc session that has inherited SHELL=/bin/sh will start /bin/sh as the shell.

That's why just using -s /bin/sh fails to be an optimum solution.  It allows the bourne shell specific code in the init.d script to run, but causes undesirable side effects in the spawned vnc session (i.e., the inherited SHELL environment variable).

Comment 19 John Hein 2014-05-06 16:10:55 UTC
I've been running with the patch in comment 16 for a while now on a few systems.  It fixes the reported problem and I haven't noticed any regressions.

Comment 21 errata-xmlrpc 2014-10-14 04:39:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1412.html


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