Red Hat Bugzilla – Bug 430877
'service sshd status' is broken
Last modified: 2010-10-22 18:09:34 EDT
Escalated to Bugzilla from IssueTracker
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).
# /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]
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 @@
- status $SSHD
+ status -p $PID_FILE $SSHD
Martin, this patch doesn't work. The -p option of status just adds another pid
file to be searched but it still does pidof $SSHD first.
Unfortunately I don't see any way how to fix this bug and not make it wrong in
other cases where the current code is fine.
Also it is questionable what the status option of the init script should really
My apologies. I hadn't synchronised events between test windows properly.
The correct behaviour is to report whether there is a daemon performing the
initial accepts on the port.
It is perfectly possible to fix this and not break any other cases.
In fact simply changing the status check to
status -p $PID_FILE
actually produces the correct sort of return code. Although the message is not
quite as clear.
OK, then something like:
status -p $PID_FILE openssh-daemon
works probably best although I still don't think that it is 100% correct.
Clearly I can do this change in Rawhide and see if there will be any bad
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release. Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products. This request is not yet committed for inclusion in an Update
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.