[3778] in Kerberos

home help back first fref pref prev next nref lref last post

Patch for window-size propagation in krb5 krlogin

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Wed Aug 31 14:00:11 1994

Date: Wed, 31 Aug 1994 13:54:34 -0400
From: "Jonathan I. Kamens" <jik@cam.ov.com>
To: krb5-bugs@MIT.EDU
Cc: kerberos@MIT.EDU

I got window-size propagation to work in krb5 beta 2 krlogin by making
the following changes:

1) Where it's available, use sigprocmask() instead of sigblock() to
   block SIGURG and SIGUSR1 signals.  (This change has already been
   made in beta 4.)
2) Where F_SETOWN isn't available but SIOCSPGRP is, use SIOCSPGRP to
   set the owner of the socket.
3) Always set the owner of the socket to getpid(); never use
   -getpid().  I don't understand why -getpid() would ever be correct,
   and in any case, it isn't correct to use it on everything except
   "(defined(BSD) && BSD+0 >= 43) || defined(ultrix)".  Using getpid()
   instead of -getpid() works on SunOS 4.1.3, Solaris, HP-UX 9 and AIX
   3.2.5.  If -getpid() really is correct on some systems, then those
   systems should be the one's explicitly listed in the #ifdef, not
   the systems for which getpid() is correct.

I tried to duplicate my beta 2 changes against beta 4, and came up
with the patch below, which is untested but should give you some idea
of the changes I think need to be made.

As I mentioned, window-size propagation appears to work on SunOS
4.1.3, Solaris, HP-UX and AIX after my changes.

Jonathan Kamens  |  OpenVision Technologies, Inc.  |   jik@cam.ov.com

--- /afs/gza.com/development/krb5.beta4/src/appl/bsd/kcmd.c	Fri Aug  5 19:45:20 1994
+++ kcmd.c	Wed Aug 31 13:46:30 1994
@@ -43,6 +43,7 @@
 #ifdef NEED_SYS_FCNTL_H
 #include <sys/fcntl.h>
 #endif
+#include <sys/ioctl.h>
 
      
      
@@ -202,9 +203,13 @@
 	    krb5_free_creds(ret_cred);
 	    return (-1);
     	}
-#ifdef HAVE_SETOWN
-    	fcntl(s, F_SETOWN, pid);
-#endif
+#ifdef F_SETOWN
+    	(void) fcntl(s, F_SETOWN, pid);
+#else
+#ifdef SIOCSPGRP
+	(void) ioctl(s, SIOCSPGRP, &pid);
+#endif /* SIOCSPGRP */
+#endif /* F_SETOWN */
     	sin.sin_family = hp->h_addrtype;
     	memcpy((caddr_t)&sin.sin_addr,hp->h_addr, hp->h_length);
     	sin.sin_port = rport;
--- /afs/gza.com/development/krb5.beta4/src/appl/bsd/krlogin.c	Sun Aug  7 00:45:32 1994
+++ krlogin.c	Wed Aug 31 13:49:28 1994
@@ -322,6 +322,7 @@
     krb5_error_code status;
     int debug_port = 0;
 #endif /* KERBEROS */
+    int pid = getpid();
    
     if (strrchr(argv[0], '/'))
       argv[0] = strrchr(argv[0], '/')+1;
@@ -596,15 +597,17 @@
 #ifdef hpux
 	/* hpux invention */
 	{
-	  int pid = getpid();
 	  ioctl(rem, FIOSSAIOSTAT, &pid); /* trick: pid is non-zero */
 	  ioctl(rem, FIOSSAIOOWN, &pid);
 	}
-#else
-#ifdef HAVE_SETOWN
-    (void) fcntl(rem, F_SETOWN, getpid());
-#endif
 #endif
+#ifdef F_SETOWN
+    (void) fcntl(rem, F_SETOWN, pid);
+#else
+#ifdef SIOCSPGRP
+    (void) ioctl(rem, SIOCSPGRP, &pid);
+#endif /* SIOCSPGRP */
+#endif /* F_SETOWN */
     if (options & SO_DEBUG &&
 	setsockopt(rem, SOL_SOCKET, SO_DEBUG, (char*)&on, sizeof (on)) < 0)
       perror("rlogin: setsockopt (SO_DEBUG)");
@@ -1273,11 +1276,7 @@
      int oldmask;
 #endif
 {
-#if (defined(BSD) && BSD+0 >= 43) || defined(ultrix)
     int pid = getpid();
-#else
-    int pid = -getpid();
-#endif
     int n, remaining;
     char *bufp = rcvbuf;
     
@@ -1284,9 +1283,13 @@
     (void) signal(SIGTTOU, SIG_IGN);
     (void) signal(SIGURG, oob);
     ppid = getppid();
-#ifdef HAVE_SETOWN
+#ifdef F_SETOWN
     (void) fcntl(rem, F_SETOWN, pid);
-#endif
+#else
+#ifdef SIOCSPGRP
+    (void) ioctl(rem, SIOCSPGRP, &pid);
+#endif /* SIOCSPGRP */
+#endif /* F_SETOWN */
     (void) setjmp(rcvtop);
 #ifdef POSIX_SIGNALS
     sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0);

home help back first fref pref prev next nref lref last post