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.
My PR.
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
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
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