Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <000c01c02884$0d7e0290$1000010a@tzi> From: "Steve O'Brien" To: Subject: patch for inetutils Date: Wed, 27 Sep 2000 14:08:39 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 I have produced a patch that fixes some of the known problems with inetutils on cygwin: 1) rlogin - does not terminate cleanly This is because of an error in setting signals - specifically catch_client does not get installed as the handler for SIGCHLD so that the parent process does not tidy up correctly when its child terminates. My fix is a very minor change to libinetutils/setsig.c 2) rshd - must wait 10 minutes between connections from same client This is caused by the abnormally long TIME_WAIT state employed by winsock sockets. My fix is to repeatedly call the pair rresvport(..); connect(..) with a decreasing port, until either the connect succeeds or we run out of valid ports. 3) rshd - always segvs without execing the command (on my system at least). Occurs when syslog is called to log the request. The variable "hostname" appears to be a "wild" pointer where it is passed to syslog just before the call to execl. My fix is just to remove the syslog call - not ideal but at least not I can rsh onto my NT box again! 4) rsh - cannot invoke it as rsh.exe I have modified the test of argv[0] in rsh.c so that either rsh or rsh.exe are accepted as being not host names. The patch follows: diff -Naur inetutils-1.3.2/libinetutils/setsig.c inetutils-1.3.2-patched/libinetutils/setsig.c --- inetutils-1.3.2/libinetutils/setsig.c Wed Jul 5 11:44:40 2000 +++ inetutils-1.3.2-patched/libinetutils/setsig.c Wed Sep 27 09:27:38 2000 @@ -42,7 +42,7 @@ sa.sa_flags = SA_RESTART; #endif sa.sa_handler = handler; - sigaction (sig, &sa, &sa); + sigaction (sig, &sa, NULL); return sa.sa_handler; #else /* !HAVE_SIGACTION */ #ifdef HAVE_SIGVEC diff -Naur inetutils-1.3.2/rsh/rsh.c inetutils-1.3.2-patched/rsh/rsh.c --- inetutils-1.3.2/rsh/rsh.c Thu Jul 6 12:25:40 2000 +++ inetutils-1.3.2-patched/rsh/rsh.c Wed Sep 27 09:38:07 2000 @@ -218,10 +218,10 @@ ++p; else p = argv[0]; - if (strcmp(p, "rsh")) - host = p; + if (!strcmp(p, "rsh") || !strcmp(p, "rsh.exe")) + asrsh = 1; else - asrsh = 1; + host = p; /* handle "rsh host flags" */ if (!host && argc > 2 && argv[1][0] != '-') { diff -Naur inetutils-1.3.2/rshd/rshd.c inetutils-1.3.2-patched/rshd/rshd.c --- inetutils-1.3.2/rshd/rshd.c Wed Jul 5 11:44:42 2000 +++ inetutils-1.3.2-patched/rshd/rshd.c Wed Sep 27 10:13:52 2000 @@ -333,23 +333,51 @@ (void) alarm(0); if (port != 0) { int lport = IPPORT_RESERVED - 1; + +#ifndef __CYGWIN__ s = rresvport(&lport); if (s < 0) { syslog(LOG_ERR, "can't get stderr port: %m"); exit(1); } +#endif /* ! __CYGWIN__ */ + #ifdef KERBEROS if (!use_kerberos) #endif if (port >= IPPORT_RESERVED) { - syslog(LOG_ERR, "2nd port not reserved\n"); + syslog(LOG_ERR, "2nd port not reserved"); exit(1); } fromp->sin_port = htons(port); + +#ifdef __CYGWIN__ + while(lport >= 512) { + if ((s = rresvport(&lport)) >= 0) { + if (connect(s, (struct sockaddr *)fromp, sizeof (*fromp)) >= 0) { + break; + } + else { + close(s); + s = -1; + --lport; + } + } + else { + syslog(LOG_ERR, "can't get stderr port: %m"); + exit(1); + } + } + if (s < 0) { + syslog(LOG_INFO, "connect second port %d: %m", port); + exit(1); + } +#else if (connect(s, (struct sockaddr *)fromp, sizeof (*fromp)) < 0) { syslog(LOG_INFO, "connect second port %d: %m", port); exit(1); } +#endif /* __CYGWIN */ } #ifdef KERBEROS @@ -778,8 +806,10 @@ hostname, locuser, cmdbuf); else #endif +#ifndef __CYGWIN__ syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: cmd='%.80s'", remuser, hostname, locuser, cmdbuf); +#endif /* !__CYGWIN__ */ } execl(pwd->pw_shell, cp, "-c", cmdbuf, 0); perror(pwd->pw_shell); -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com