Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1236559

Summary: tigervnc's lock file is not removed after stopping vncserver service
Product: Red Hat Enterprise Linux 6 Reporter: Frantisek Sumsal <fsumsal>
Component: tigervncAssignee: Jan Grulich <jgrulich>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.8CC: fsumsal, psklenar, tpelka
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 20:09:32 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:
Bug Depends On:    
Bug Blocks: 1271696    
Attachments:
Description Flags
fix for vncserver.init none

Description Frantisek Sumsal 2015-06-29 12:39:24 UTC
Description of problem:

tigervnc doesn't remove its lock file (/var/lock/subsys/Xvnc) after first execution of 'service tigervnc stop'

This problem is caused by wrong values/conditions in stop() function of /etc/init.d/vncserver file, which has been already fixed in the upstream version of initscript file.

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

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.7 (Santiago)
# rpm -q tigervnc tigervnc-server
tigervnc-1.1.0-16.el6.x86_64
tigervnc-server-1.1.0-16.el6.x86_64

Steps to Reproduce:

1. Create random user
# useradd bd87a3f0

2. Create necessary folders and files
# runuser -l bd87a3f0 -c "mkdir .vnc; cd .vnc; umask 066; touch xstartup passwd"

3. Rewrite configuration file
# > /etc/sysconfig/vncservers
# echo "VNCSERVERS=7:bd87a3f0" > /etc/sysconfig/vncservers

4. Start tigervnc server
# service vncserver start

5. Stop tigervnc server
# service vncserver stop

6. Lock file /var/lock/subsys/Xvnc still exists
# ls -l /var/lock/subsys/Xvnc
-rw-r--r--. 1 root root 0 Jun 29 08:14 /var/lock/subsys/Xvnc
# service vncserver status
Xvnc dead but subsys locked

7. After second execution of 'service vncserver stop' the lock file gets removed
# service vncserver stop
# ls -l /var/lock/subsys/Xvnc
ls: cannot access /var/lock/subsys/Xvnc: No such file or directory
# service vncserver status
Xvnc is stopped

Expected results:

Lock file should be removed after first execution of 'service vncserver stop'

Comment 2 Tim Waugh 2015-07-01 15:02:39 UTC
(In reply to Frantisek Sumsal from comment #0)
> This problem is caused by wrong values/conditions in stop() function of
> /etc/init.d/vncserver file, which has been already fixed in the upstream
> version of initscript file.

Could you please clarify what you think the fix is?

Comment 3 Frantisek Sumsal 2015-07-02 07:36:37 UTC
As you can see, the old stop() function [1] removes lock file only when value of STOPPED is 0. But when you try to stop vncserver service for the first time, for loop will increment value of STOPPED for each successfully stopped vnc server, thus the STOPPED value after for loop won't be 0 and the lock file won't get deleted [3].

Nevertheless, new stop() function [2] relies only on return value of 'status Xvnc', which works as it should [4].

-----

[1] stop() function present in current RHEL 6 TigerVNC build:
stop() {
    [ "$EUID" != "0" ] && exit 4

    echo -n $"Shutting down $prog: "

    status Xvnc > /dev/null 2>&1
    RETVAL=$?

    STOPPED=0
    # 3 means service is already stopped
    if ! [ "$RETVAL" -eq 3 ]; then
        for display in ${VNCSERVERS}; do
            echo -n "${display} "
            export USER="${display##*:}"
            runuser ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
            RETVAL=$?
            [ "$RETVAL" -eq 0 ] && STOPPED=`expr $STOPPED + 1`
        done
        RETVAL=$?
    else
        let STOPPED=1
        let RETVAL=0
    fi

    [ "$STOPPED" -gt 0 ] && success $"vncserver shutdown" || \
        failure $"vncserver shutdown"
    echo
    [ "$STOPPED" -eq 0 ] && rm -f /var/lock/subsys/Xvnc
    return "$RETVAL"
}

[2] stop() function present in upstream:
stop() {
    [ "$EUID" != "0" ] && exit 4

    echo -n $"Shutting down $prog: "

    status Xvnc > /dev/null 2>&1
    RETVAL=$?

    # 3 means service is already stopped
    if ! [ "$RETVAL" -eq 3 ]; then
	for display in ${VNCSERVERS}; do
	    echo -n "${display} "
	    export USER="${display##*:}"
	    runuser ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
	done
	RETVAL=$?
    else
	let RETVAL=0
    fi

    [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \
	failure $"vncserver shutdown"
    echo
    [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/Xvnc
    return "$RETVAL"
}

[3] Stopping service with old stop() function (with some debug info):
# First call of 'service vncserver stop'
# service vncserver stop
Shutting down VNC server: Before loop: $RETVAL = 0
Stopping vncserver 7:bd87a3f0
7:bd87a3f0 7:bd87a3f0 stopped: $RETVAL = 0, $STOPPED = 1
After loop: $STOPPED = 1
                            
# Second call
# service vncserver stop
Shutting down VNC server: Before loop: $RETVAL = 2
Stopping vncserver 7:bd87a3f0
7:bd87a3f0 7:bd87a3f0 stopped: $RETVAL = 2, $STOPPED = 0
After loop: $STOPPED = 0
                                                           [FAILED]
Removing lock file...

[4] Stopping service with new stop() function:
# service vncserver stop
Shutting down VNC server: 7:bd87a3f0                       [  OK  ]
Removing lock file...

Comment 4 Tim Waugh 2015-07-02 08:08:22 UTC
Oh I see. That's the wrong way around: the STARTED stuff is newer than the upstream code, but a bug crept in at some point ('-eq' should be '-gt' in that test). See bug #768405.

Comment 5 Tim Waugh 2015-07-02 08:13:07 UTC
Created attachment 1045404 [details]
fix for vncserver.init

This is the fix.

Comment 9 Jan Grulich 2015-11-18 11:11:50 UTC
Fixed in tigervnc-1.1.0-17.el6.

Comment 13 errata-xmlrpc 2016-05-10 20:09:32 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.

https://rhn.redhat.com/errata/RHBA-2016-0775.html