From midom@watcher.delfi.lt  Mon May  7 12:39:25 2001
Return-Path: <midom@watcher.delfi.lt>
Received: from watcher.delfi.lt (watcher.delfi.lt [213.197.128.84])
	by hub.freebsd.org (Postfix) with SMTP id F329737B42C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 May 2001 12:39:23 -0700 (PDT)
	(envelope-from midom@watcher.delfi.lt)
Received: (qmail 36706 invoked by uid 1000); 7 May 2001 19:39:22 -0000
Message-Id: <20010507193922.36705.qmail@watcher.delfi.lt>
Date: 7 May 2001 19:39:22 -0000
From: Domas Mituzas <midom@dammit.lt>
Reply-To: Domas Mituzas <midom@delfi.lt>
To: FreeBSD-gnats-submit@freebsd.org
Subject: fix of rsh non-interactive mode behaviour
X-Send-Pr-Version: 3.2

>Number:         27188
>Category:       bin
>Synopsis:       fix of rsh non-interactive mode behaviour
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jon
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 07 12:40:11 PDT 2001
>Closed-Date:    Sat Jan 26 00:33:45 UTC 2008
>Last-Modified:  Sat Jan 26 00:33:45 UTC 2008
>Originator:     Domas Mituzas
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
DELFI Internet, UAB
Juozapaviciaus 6/2
2005 Vilnius
>Environment:

rsh connecting to some strange devices like 3com TotalControl.

	

>Description:

This issue catched my observations when I had to do some background tasks 
rsh'ing into devices, but doing nothing. That turned to be background task
issue, documented in BUGS, but still, after specifying -n, nothing worked.

Then I tried to do some listing commands in interactive mode, but specifying
-n flag. The command immediately terminated. If I used sleep | rsh, then it worked,
but additional delay was not the solution. Then I tried to fix this problem and here
we have a working fix.

	

>How-To-Repeat:

rsh -n IP COMMAND

make sure IP is address of really strange device.

	

>Fix:

diff -ur rsh.old/rsh.1 rsh/rsh.1
--- rsh.old/rsh.1	Mon May  7 21:21:08 2001
+++ rsh/rsh.1	Mon May  7 21:30:52 2001
@@ -96,6 +96,9 @@
 (see the
 .Sx BUGS
 section of this manual page).
+.It Fl c
+Do not shutdown sending socket. This solves problems connecting to
+some proprietary devices in non-interactive mode.
 .It Fl x
 Turn on
 .Tn DES
diff -ur rsh.old/rsh.c rsh/rsh.c
--- rsh.old/rsh.c	Mon May  7 21:21:08 2001
+++ rsh/rsh.c	Mon May  7 21:28:09 2001
@@ -100,7 +100,7 @@
 	struct passwd *pw;
 	struct servent *sp;
 	long omask;
-	int argoff, asrsh, ch, dflag, nflag, one, rem;
+	int argoff, asrsh, ch, dflag, nflag, cflag, one, rem;
 	pid_t pid = 0;
 	uid_t uid;
 	char *args, *host, *p, *user;
@@ -109,7 +109,7 @@
 	char *k;
 #endif
 
-	argoff = asrsh = dflag = nflag = 0;
+	argoff = asrsh = dflag = cflag = nflag = 0;
 	one = 1;
 	host = user = NULL;
 
@@ -131,12 +131,12 @@
 
 #ifdef KERBEROS
 #ifdef CRYPT
-#define	OPTIONS	"468KLde:k:l:nt:wx"
+#define	OPTIONS	"468KLde:k:l:nct:wx"
 #else
-#define	OPTIONS	"468KLde:k:l:nt:w"
+#define	OPTIONS	"468KLde:k:l:nct:w"
 #endif
 #else
-#define	OPTIONS	"468KLde:l:nt:w"
+#define	OPTIONS	"468KLde:l:nct:w"
 #endif
 	while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
 		switch(ch) {
@@ -173,6 +173,9 @@
 		case 'n':
 			nflag = 1;
 			break;
+		case 'c':
+			cflag = 1;
+			break;
 #ifdef KERBEROS
 #ifdef CRYPT
 		case 'x':
@@ -315,7 +318,7 @@
 		if (pid < 0)
 			err(1, "fork");
 	}
-        else
+        else if (!cflag)
 		(void)shutdown(rem, 1);
 
 #ifdef KERBEROS
@@ -491,7 +494,7 @@
 {
 
 	(void)fprintf(stderr,
-	    "usage: rsh [-46] [-ndK%s]%s[-l login] [-t timeout] host [command]\n",
+	    "usage: rsh [-46] [-ncdK%s]%s[-l login] [-t timeout] host [command]\n",
 #ifdef KERBEROS
 #ifdef CRYPT
 	    "x", " [-k realm] ");

	

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: ru 
Responsible-Changed-When: Mon May 14 12:00:01 PDT 2001 
Responsible-Changed-Why:  
Misfiled PR. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27188 

From: Jonathan Chen <jon@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, midom@delfi.lt
Cc:  
Subject: Re: bin/27188: fix of rsh non-interactive mode behaviour
Date: Sun, 7 Jul 2002 12:19:02 -0400

 I'm a little hesitant of adding new features to support broken proprietary 
 software.  Please let me know if this is still a problem for you, and if 
 so, you can also try 'rsh IP command < /dev/null &', which would be another 
 workaround that doesn't involve modifying the source code.
 
 -Jon
State-Changed-From-To: open->feedback 
State-Changed-By: jon 
State-Changed-When: Sun Jul 7 09:20:42 PDT 2002 
State-Changed-Why:  

awaiting user feedback 


Responsible-Changed-From-To: freebsd-bugs->jon 
Responsible-Changed-By: jon 
Responsible-Changed-When: Sun Jul 7 09:20:42 PDT 2002 
Responsible-Changed-Why:  

awaiting user feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=27188 

From: Domas Mituzas <domas.mituzas@microlink.lt>
To: freebsd-gnats-submit@FreeBSD.org, jon@freebsd.org
Cc:  
Subject: Re: bin/27188: fix of rsh non-interactive mode behaviour
Date: Sat, 11 Jan 2003 18:01:19 +0200

 Hi,
 
 the method you suggested is one of millions I tried (and afaik is same 
 as -n), and that obviously does not work. Anyway, right now I don't have 
 to execute any commands on that hardware, but the problem for other 
 users still remains :)
 
 I shared my case, it's a software designer's choice whether to bother 
 about such proprietary cases.
 
 Cheers,
 Domas
 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Jan 26 00:28:02 UTC 2008 
State-Changed-Why:  
Close this one, with bugmeister hat on. 

It's been several years since it came in, and it doesn't seem that 
anyone else has had a similar problem (or at least enough of them to 
make it worth our while to change the software).  Working around 
uncommon hardware is probably best left to local patches.  But thanks 
for the submission. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=27188 
>Unformatted:
