Bug 826720

Summary: sshd initscript clobbers other sshd processes.
Product: Red Hat Enterprise Linux 6 Reporter: Rick Houser <rick.houser>
Component: opensshAssignee: Petr Lautrbach <plautrba>
Status: CLOSED ERRATA QA Contact: Jiri Jaburek <jjaburek>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: jbastian, jjaburek, pattonme, pvrabec, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 10:27:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 782183, 836160, 840699    
Attachments:
Description Flags
fixed sshd.init none

Description Rick Houser 2012-05-30 20:31:10 UTC
Description of problem: Initscript clobbers other sshd processes.  Please note that this is NOT the same issue as 698777, as we are already running seperate pid files.  The problem is that the existing initscript doesn't use them.


Version-Release number of selected component (if applicable): openssh-server-5.3p1-70.el6_2.2.x86_64


How reproducible: Completely


Steps to Reproduce:
1. Create a second sshd instance listening on a different port (ex. copy the sshd initscript, call it "sshd_alt" or something, then change the pid name, config files, make sure it uses -f to talk to a secondary config file, etc).
2. Copy sshd_config to" sshd_config_alt" or something (match the earlier step).
3. Start both instances.
4. Stop one of the instances (ex. the original one).
  
Actual results:

The secondary instance is stopped.  The primary might stop too, but I didn't check.


Expected results:

Only the instance that corresponds with the initscript should stop.


Additional info:

The initscript does unsafe things that interfere with other ssh daemons, like this:

            killproc $SSHD

The PID file is already available as a variable, so the killproc should probably look something like this:

            killproc -p $PID_FILE $SSHD
 
It looks like a similar problem may be affecting the configuration validation, etc.

Comment 3 matthew patton 2012-08-30 06:25:12 UTC
The init script needs a complete rethink and rewrite. All variables moved to /etc/sysconfig/`basename $0`, variables derived dynamically from /etc/ssh/sshd_config or other specified file, etc.

Comment 4 Petr Lautrbach 2012-10-09 15:38:57 UTC
Created attachment 624155 [details]
fixed sshd.init

This is fixed sshd.init using "killproc -p $PID_FILE $SSHD". It's also slightly changed to simplify process of creating multiple sshd instances. Following steps should work to setup a second sshd instance on the port 2222:

# cp /etc/init.d/sshd /etc/init.d/sshd-second
# cp /etc/sysconfig/sshd /etc/sysconfig/sshd-second
# echo 'OPTIONS="-f /etc/ssh/sshd_config-second -p 2222 -o PidFile=/var/run/sshd-second.pid"' >> /etc/sysconfig/sshd-second

(plus some SELinux changes)

Comment 5 Petr Lautrbach 2012-10-09 15:43:38 UTC
> # echo 'OPTIONS="-f /etc/ssh/sshd_config-second -p 2222 -o
> PidFile=/var/run/sshd-second.pid"' >> /etc/sysconfig/sshd-second

If you use -f /etc/ssh/sshd_config-second then you also need to change SSHD_CONFIG variable in the new sshd-secong initscript

Comment 6 Petr Lautrbach 2012-10-09 16:16:25 UTC
Comment on attachment 624155 [details]
fixed sshd.init

This initscript is wrong.
Starting S15sshd: [  OK  ]

Comment 7 Petr Lautrbach 2012-10-10 14:53:58 UTC
> The initscript does unsafe things that interfere with other ssh daemons,
> like this:
> 
>             killproc $SSHD
> 
> The PID file is already available as a variable, so the killproc should
> probably look something like this:
> 
>             killproc -p $PID_FILE $SSHD

will be fixed in next release. Thanks.

>  
> It looks like a similar problem may be affecting the configuration
> validation, etc.

(In reply to comment #3)
> The init script needs a complete rethink and rewrite. All variables moved to
> /etc/sysconfig/`basename $0`, variables derived dynamically from
> /etc/ssh/sshd_config or other specified file, etc.


This would need big change with high regression risc, bugs and so, see my comment #c6. This 
scripts hasn't been supposed to be used in multinstance environment. I won't do this. 
Sorry. 

Please fix your sshd.init copies to avoid problems with configuration validation, sysconfig file and so.

Comment 11 errata-xmlrpc 2013-02-21 10:27:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0519.html