Bug 430882 - 'service sshd status' is broken
'service sshd status' is broken
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: openssh (Show other bugs)
4.6
All Linux
medium Severity medium
: rc
: ---
Assigned To: Petr Lautrbach
Brian Brock
:
: 479838 (view as bug list)
Depends On: 430877
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-30 07:34 EST by Martin Poole
Modified: 2012-06-14 16:28 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-14 16:28:14 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)

  None (edit)
Description Martin Poole 2008-01-30 07:34:18 EST
+++ This bug was initially created as a clone of Bug #430877 +++

Escalated to Bugzilla from IssueTracker

-- Additional comment from tao@redhat.com on 2008-01-30 07:05 EST --
1. Provide clear and concise problem description as it is understood at the time
of escalation

The command "service sshd status" does not tell whether the sshd service is
running.  Instead it tells whether there are any sshd processes in the process
table. 
 
It happens on both RHEL 5.1 and RHEL 4.6 (and, presumably, everything in between). 
 
For example: 
# /etc/init.d/sshd stop 
Stopping sshd:                                             [  OK  ] 
# service sshd status 
sshd (pid 26595 26593) is running... 
# ps -ef | grep ssh 
root     18430 18065  0 08:53 pts/1    00:00:00 grep --color ssh 
root     26593     1  0 Jan03 ?        00:00:00 sshd: happy [priv] 
happy    26595 26593  0 Jan03 ?        00:00:02 sshd: happy@pts/0

We know that no new connections will be accepted with this status but the status
function should report that service is stopped.
 
2. State specific action requested of SEG

As the status function is generic to all the init scripts and I agree that it
can't be modified for a single script. However the additional functionally can
be added.

3. Additional info

This seems to be a limitation of using a common/generic "status" function via
/etc/init.d/functions. The status function should also check
/var/run/SERVICE.pid file or /var/lock/subsys/SERVICE, in this case
/var/run/sshd.pid or /var/lock/subsys/sshd

This should be more reliable, though can never be 100% accurate in representing
the service status. We also understand that not all services would actually
create these (pid file) upon startup hence the "status" function primarily
checks for running processes.

Also changing the behavior of the generic function could have cascading impact
on all services using it.
This event sent from IssueTracker by mpoole  [Support Engineering Group]
 issue 161096

-- Additional comment from mpoole@redhat.com on 2008-01-30 07:32 EST --
Simple enough to fix,


--- sshd.orig   2008-01-30 12:11:47.000000000 +0000
+++ sshd        2008-01-30 12:31:03.000000000 +0000
@@ -170,7 +170,7 @@
                fi
                ;;
        status)
-               status $SSHD
+               status -p $PID_FILE $SSHD
                RETVAL=$?
                ;;
        *)
Comment 1 Tomas Mraz 2008-04-07 16:11:20 EDT
Actually status -p $PID_FILE openssh-daemon must be used otherwise it is not
correct either.
Comment 4 RHEL Product and Program Management 2008-10-31 12:39:34 EDT
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".
Comment 5 Tomas Mraz 2009-01-13 10:22:08 EST
*** Bug 479838 has been marked as a duplicate of this bug. ***
Comment 6 Albert Hopkins 2009-01-13 11:52:27 EST
Customer is also asking for this to be fixed in RHEL4.
Comment 7 RHEL Product and Program Management 2009-01-13 11:58:18 EST
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".
Comment 10 Eric Bahmer 2010-06-01 15:48:59 EDT
I realize this is for ssh, but I seem to be running into a similar issue with trying to run a second instance of apache with a different init script and configuration file. The problem does appear to be with /etc/init.d/functions as it defaults to pidof for checking status on a program even when you specify a pidfile. It never even makes it to the pidfile check because it returns right away.

status() {
.............

        # First try "pidof"
        pid="$(__pids_pidof "$1")"
        if [ -n "$pid" ]; then
                echo $"${base} (pid $pid) is running..."
                return 0
        fi

        # Next try "/var/run/*.pid" files
        __pids_var_run "$1" "$pid_file"

............
}

This causes "service <scriptname> status" to report the same pids as "service httpd status", I imagine if I was running multiple copies of sshd with different configurations that it would be the same issue.
Comment 11 RHEL Product and Program Management 2010-10-22 14:55:24 EDT
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 unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

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