Bug 205144 - [patch] make rsh(1) compatible with recent Cisco IOS versions
Summary: [patch] make rsh(1) compatible with recent Cisco IOS versions
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.2-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Eugene Grosbein
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-12-08 18:13 UTC by Eugene Grosbein
Modified: 2017-11-06 12:46 UTC (History)
2 users (show)

See Also:


Attachments
rsh.diff (2.74 KB, patch)
2015-12-08 18:13 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2015-12-08 18:13:50 UTC
Created attachment 163996 [details]
rsh.diff

It's not uncommon to run periodic jobs that use rsh(1) to connect to Cisco IOS devices (routers, switches) to manage them or collect some information not available via SNMP using "show ..." commands.

Our rsh(1) implementation does "shutdown(rem, SHUT_WR)" when it detects "end-of-file" condition for standard input stream to inform remote host of EOF. Jobs created with cron(8) have standard input redirected from /dev/null and rsh(1) calls mentioned shutdown() just after connection is created.

Recent Cisco IOS versions (e.g. 15.x) close remote shell session immediately on receiving such end-of-stream indication that results in empty output of "show ..." commands.

Attached patch introduces new "rsh -N" option that acts like opposite to 
"rsh -n" mode preventing shutdown of socket sending path. This prevents of premature disconnect of rsh session by remote host.
Comment 1 Eugene Grosbein freebsd_committer freebsd_triage 2017-09-19 17:28:52 UTC
My PR.
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-10-02 16:33:30 UTC
A commit references this bug:

Author: eugen
Date: Mon Oct  2 16:33:05 UTC 2017
New revision: 324212
URL: https://svnweb.freebsd.org/changeset/base/324212

Log:
  rsh: introduce new option -N disabling shutdown of socket sending path.

  This prevents premature disconnection of rsh session with protocol
  implementation confused by "end-of-file" condition for standard
  input stream. For example, modern Cisco IOS (15.x) versions
  can be managed with "rsh -N" cron jobs having /dev/null as stdin.

  PR:		205144
  Approved by:	avg (mentor)
  MFC after:	1 week

Changes:
  head/usr.bin/rsh/rsh.1
  head/usr.bin/rsh/rsh.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-11-06 12:44:55 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov  6 12:44:27 UTC 2017
New revision: 325473
URL: https://svnweb.freebsd.org/changeset/base/325473

Log:
  MFC r324212:

    rsh: introduce new option -N disabling shutdown of socket sending path.

  PR:		205144
  Approved by:	mav (mentor)

Changes:
  stable/11/usr.bin/rsh/rsh.1
  stable/11/usr.bin/rsh/rsh.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-11-06 12:45:58 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov  6 12:45:52 UTC 2017
New revision: 325474
URL: https://svnweb.freebsd.org/changeset/base/325474

Log:
  MFC r324212:

    rsh: introduce new option -N disabling shutdown of socket sending path.

  PR:		205144
  Approved by:	mav (mentor)

Changes:
  stable/10/usr.bin/rsh/rsh.1
  stable/10/usr.bin/rsh/rsh.c