Bug 18722 - sshd restarts fail when user doing restart is logged in by ssh
Summary: sshd restarts fail when user doing restart is logged in by ssh
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts   
(Show other bugs)
Version: 7.0
Hardware: i386
OS: Linux
high
high
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-10-09 15:51 UTC by jonathan
Modified: 2014-03-17 02:16 UTC (History)
4 users (show)

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


Attachments (Terms of Use)

Description jonathan 2000-10-09 15:51:10 UTC
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`
        
        pid=
        for apid in $pidlist ; do
           [ -d /proc/$apid ] && pid="$pid $apid"
        done
        
        [ -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
make
individual scripts check for other running instances if they want.

Comment 1 Daniel Roesen 2000-10-09 17:00:09 UTC
I think this is a serious problem. Changing Priority to "high".

Comment 2 Dan Browning 2000-10-09 22:22:54 UTC
My workaround:  Build a script...

#!/bin/bash
#/root/restart-sshd.sh
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 18:23:08 UTC
This was fixed, among other things, in errata OpenSSH 2.2.0p1-5.


Comment 4 Pekka Savola 2000-10-13 18:25:35 UTC
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.