RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 826720 - sshd initscript clobbers other sshd processes.
Summary: sshd initscript clobbers other sshd processes.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: openssh
Version: 6.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: Jiri Jaburek
URL:
Whiteboard:
Depends On:
Blocks: 782183 836160 840699
TreeView+ depends on / blocked
 
Reported: 2012-05-30 20:31 UTC by Rick Houser
Modified: 2021-08-30 13:06 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-21 10:27:53 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 63129 0 None None None 2012-08-14 20:57:03 UTC
Red Hat Product Errata RHSA-2013:0519 0 normal SHIPPED_LIVE Moderate: openssh security, bug fix and enhancement update 2013-02-20 21:28:57 UTC

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


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