Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 18722 - sshd restarts fail when user doing restart is logged in by ssh
sshd restarts fail when user doing restart is logged in by ssh
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
i386 Linux
high Severity high
: ---
: ---
Assigned To: Bill Nottingham
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2000-10-09 11:51 EDT by jonathan
Modified: 2014-03-16 22:16 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-10-09 18:22:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jonathan 2000-10-09 11:51:10 EDT
When restarting sshd using the /etc/rc.d/init.d/sshd script 
the restart fails when the person doing the restart is logged
in through ssh. 

In /etc/rc.d/init.d/functions the daemon() function does a check
for whether any proceses with the same executable name is 
currently running by doing:

 # See if it's already running.
        pidlist=`pidofproc $1`
        for apid in $pidlist ; do
           [ -d /proc/$apid ] && pid="$pid $apid"
        [ -n "$pid" ] && return

However, when you are logged in by ssh to the machine and you
try to restart sshd, there IS a process called /usr/sbin/sshd running
so the daemon function"returns" without actually doing anything.

I can see how this might be a good idea sometimes, however, in this
case it makes the script useless for anyone running headless boxes, 
and makes it easy to get stuck with a machine with no way to login to.
(the restart fails, but you don't notice and then logout of the one ssh
shell you currently have---then you can never login until a reboot)

I'm not sure of the best way to fix this except to remove the check and
individual scripts check for other running instances if they want.
Comment 1 Daniel Roesen 2000-10-09 13:00:09 EDT
I think this is a serious problem. Changing Priority to "high".
Comment 2 Dan Browning 2000-10-09 18:22:54 EDT
My workaround:  Build a script...

sleep 1m              #Sleep for 1 minute to allow time for user to log off.
service sshd restart  #now restart, no sshd processes should be running

Comment 3 Pekka Savola 2000-10-13 14:23:08 EDT
This was fixed, among other things, in errata OpenSSH 2.2.0p1-5.
Comment 4 Pekka Savola 2000-10-13 14:25:35 EDT
Also, from the initscripts point of view, I don't think there's much better way of checking
whether a daemon is running.  _Some_ sort of method should be in initscripts -- 
if some daemon needs special attention, it should probably be done there then.

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