Bug 430882 - 'service sshd status' is broken
Summary: 'service sshd status' is broken
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: openssh
Version: 4.6
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: Brian Brock
URL:
Whiteboard:
: 479838 (view as bug list)
Depends On: 430877
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-01-30 12:34 UTC by Martin Poole
Modified: 2018-10-27 14:30 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-14 20:28:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Poole 2008-01-30 12:34:18 UTC
+++ This bug was initially created as a clone of Bug #430877 +++

Escalated to Bugzilla from IssueTracker

-- Additional comment from tao 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 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 20:11:20 UTC
Actually status -p $PID_FILE openssh-daemon must be used otherwise it is not
correct either.


Comment 4 RHEL Program Management 2008-10-31 16:39:34 UTC
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 15:22:08 UTC
*** Bug 479838 has been marked as a duplicate of this bug. ***

Comment 6 Albert Hopkins 2009-01-13 16:52:27 UTC
Customer is also asking for this to be fixed in RHEL4.

Comment 7 RHEL Program Management 2009-01-13 16:58:18 UTC
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 19:48:59 UTC
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 Program Management 2010-10-22 18:55:24 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 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.