Bug 826720 - sshd initscript clobbers other sshd processes.
sshd initscript clobbers other sshd processes.
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: openssh (Show other bugs)
6.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Petr Lautrbach
Jiri Jaburek
:
Depends On:
Blocks: 782183 836160 840699
  Show dependency treegraph
 
Reported: 2012-05-30 16:31 EDT by Rick Houser
Modified: 2013-02-21 05:27 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-21 05:27:53 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
fixed sshd.init (4.51 KB, text/plain)
2012-10-09 11:38 EDT, Petr Lautrbach
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 63129 None None None 2012-08-14 16:57:03 EDT

  None (edit)
Description Rick Houser 2012-05-30 16:31:10 EDT
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 02:25:12 EDT
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 11:38:57 EDT
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 11:43:38 EDT
> # 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 12:16:25 EDT
Comment on attachment 624155 [details]
fixed sshd.init

This initscript is wrong.
Starting S15sshd: [  OK  ]
Comment 7 Petr Lautrbach 2012-10-10 10:53:58 EDT
> 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 05:27:53 EST
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

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