From owner-svn-src-head@freebsd.org Mon Oct 2 16:33:05 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E911EE0E092; Mon, 2 Oct 2017 16:33:05 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BAA176E3FD; Mon, 2 Oct 2017 16:33:05 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v92GX4Ph029523; Mon, 2 Oct 2017 16:33:04 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v92GX4h3029521; Mon, 2 Oct 2017 16:33:04 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201710021633.v92GX4h3029521@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Mon, 2 Oct 2017 16:33:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324212 - head/usr.bin/rsh X-SVN-Group: head X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: head/usr.bin/rsh X-SVN-Commit-Revision: 324212 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Oct 2017 16:33:06 -0000 Author: eugen (ports committer) Date: Mon Oct 2 16:33:04 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 Modified: head/usr.bin/rsh/rsh.1 head/usr.bin/rsh/rsh.c Modified: head/usr.bin/rsh/rsh.1 ============================================================================== --- head/usr.bin/rsh/rsh.1 Mon Oct 2 16:21:20 2017 (r324211) +++ head/usr.bin/rsh/rsh.1 Mon Oct 2 16:33:04 2017 (r324212) @@ -36,7 +36,7 @@ .Nd remote shell .Sh SYNOPSIS .Nm -.Op Fl 46dn +.Op Fl 46dnN .Op Fl l Ar username .Op Fl t Ar timeout .Ar host @@ -87,12 +87,22 @@ By default, the remote username is the same as the loc Authorization is determined as in .Xr rlogin 1 . +.It Fl N +Opposite to +.Fl n +option: do not send the "end of file" (EOF) indication for input stream +to the remote host. This option makes the +.Nm +utility compatible with protocol implementations confused by receiving +EOF, like some Cisco IOS versions. Disables +.Fl n . .It Fl n Redirect input from the special device .Pa /dev/null (see the .Sx BUGS -section of this manual page). +section of this manual page). Disables +.Fl N . .It Fl t Ar timeout Allow a .Ar timeout Modified: head/usr.bin/rsh/rsh.c ============================================================================== --- head/usr.bin/rsh/rsh.c Mon Oct 2 16:21:20 2017 (r324211) +++ head/usr.bin/rsh/rsh.c Mon Oct 2 16:33:04 2017 (r324212) @@ -85,7 +85,7 @@ static char rlogin[] = "rlogin"; void connect_timeout(int); char *copyargs(char * const *); void sendsig(int); -void talk(int, long, pid_t, int, int); +void talk(int, int, long, pid_t, int, int); void usage(void); int @@ -94,13 +94,13 @@ main(int argc, char *argv[]) struct passwd const *pw; struct servent const *sp; long omask; - int argoff, asrsh, ch, dflag, nflag, one, rem; + int argoff, asrsh, ch, dflag, nflag, Nflag, one, rem; pid_t pid = 0; uid_t uid; char *args, *host, *p, *user; int timeout = 0; - argoff = asrsh = dflag = nflag = 0; + argoff = asrsh = dflag = nflag = Nflag = 0; one = 1; host = user = NULL; @@ -120,7 +120,7 @@ main(int argc, char *argv[]) argoff = 1; } -#define OPTIONS "468Lde:l:nt:w" +#define OPTIONS "468LNde:l:nt:w" while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1) switch(ch) { case '4': @@ -131,6 +131,10 @@ main(int argc, char *argv[]) family = PF_INET6; break; + case 'N': + Nflag = 1; + nflag = 0; + break; case 'L': /* -8Lew are ignored to allow rlogin aliases */ case 'e': case 'w': @@ -144,6 +148,7 @@ main(int argc, char *argv[]) break; case 'n': nflag = 1; + Nflag = 0; break; case 't': timeout = atoi(optarg); @@ -227,7 +232,7 @@ main(int argc, char *argv[]) (void)ioctl(rfd2, FIONBIO, &one); (void)ioctl(rem, FIONBIO, &one); - talk(nflag, omask, pid, rem, timeout); + talk(nflag, Nflag, omask, pid, rem, timeout); if (!nflag) (void)kill(pid, SIGKILL); @@ -235,7 +240,7 @@ main(int argc, char *argv[]) } void -talk(int nflag, long omask, pid_t pid, int rem, int timeout) +talk(int nflag, int Nflag, long omask, pid_t pid, int rem, int timeout) { int cc, wc; fd_set readfrom, ready, rembits; @@ -276,8 +281,8 @@ rewrite: if (cc == 0) goto reread; goto rewrite; -done: - (void)shutdown(rem, SHUT_WR); +done: if (!Nflag) + (void)shutdown(rem, SHUT_WR); exit(0); } @@ -371,6 +376,6 @@ usage(void) { (void)fprintf(stderr, - "usage: rsh [-46dn] [-l username] [-t timeout] host [command]\n"); + "usage: rsh [-46Ndn] [-l username] [-t timeout] host [command]\n"); exit(1); }