krshd.c (doit): Apply ghudson's patch so that rshd passes the port
authorTheodore Tso <tytso@mit.edu>
Thu, 8 Oct 1998 05:51:33 +0000 (05:51 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 8 Oct 1998 05:51:33 +0000 (05:51 +0000)
numbers for the local and foreign addresses so that the V4 encrypted
RCP will work correctly.  [krb5-appl/638]

v4rcp.c (answer_auth): Apply ghudson's patch so that if KRB5LOCALPORT
and KRB5REMOTEPORT are set, use them to set the foreign and
local ports so that encrypted rcp for the same machine.
[krb5-appl/638]

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10971 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/bsd/ChangeLog
src/appl/bsd/krshd.c
src/appl/bsd/v4rcp.c

index cee8827413f4fc95963ef3e335cf47dc4b9101b3..6eaa52942e524716fdecd147f0dbc3c7e841b6e2 100644 (file)
@@ -1,3 +1,13 @@
+1998-10-06  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * krshd.c (doit): Apply ghudson's patch so that rshd passes the
+               port numbers for the local and foreign addresses so that
+               the V4 encrypted RCP will work correctly.  [krb5-appl/638]
+       * v4rcp.c (answer_auth): Apply ghudson's patch so that if
+               KRB5LOCALPORT and KRB5REMOTEPORT are set, use them to set
+               the foreign and local ports so that encrypted rcp for the
+               same machine.  [krb5-appl/638]
+
 Sat Aug 15 00:01:15 1998  Geoffrey King  <gjking@mit.edu>
 
        * krcp.c (error): Don't call rcmd_stream_write if iamremote is not
index 164dd6d55b42b53094b830e8a6eeada8eeac3331..6f9468e80137b45d094fe797ed6ef0f9c93d22b0 100644 (file)
@@ -443,8 +443,10 @@ char    term[64] = "TERM=network";
 char   path_rest[] = RPATH;
 
 char   remote_addr[64];        /* = "KRB5REMOTEADDR=" */
+char   remote_port[64];        /* = "KRB5REMOTEPORT=" */
 char   local_addr[64];         /* = "KRB5LOCALADDR=" */
-#define ADDRPAD 0,0            /* remoteaddr, localaddr */
+char   local_port[64];         /* = "KRB5LOCALPORT=" */
+#define ADDRPAD 0,0,0,0
 #define KRBPAD 0               /* KRB5CCNAME, optional */
 
 /* The following include extra space for TZ and MAXENV pointers... */
@@ -1348,14 +1350,22 @@ if(port)
 
     {
       int i;
-      /* these two are covered by ADDRPAD */
+      /* these four are covered by ADDRPAD */
       sprintf(local_addr,  "KRB5LOCALADDR=%s", inet_ntoa(localaddr.sin_addr));
       for (i = 0; envinit[i]; i++);
       envinit[i] =local_addr;
 
+      sprintf(local_port,  "KRB5LOCALPORT=%d", ntohs(localaddr.sin_port));
+      for (; envinit[i]; i++);
+      envinit[i] =local_port;
+
       sprintf(remote_addr, "KRB5REMOTEADDR=%s", inet_ntoa(fromp->sin_addr));
       for (; envinit[i]; i++);
       envinit[i] =remote_addr;
+
+      sprintf(remote_port, "KRB5REMOTEPORT=%d", ntohs(fromp->sin_port));
+      for (; envinit[i]; i++);
+      envinit[i] =remote_port;
     }
 
     /* If we do anything else, make sure there is space in the array. */
index 4ddef36da2b087dbb8644052c7c406318904a76c..36754deadcb6c88e4b3b7dc74527f093277dcca4 100644 (file)
@@ -1003,7 +1003,10 @@ answer_auth()
          local.sin_addr.s_addr = inet_addr(envaddr);
 #endif
          local.sin_family = AF_INET;
-         local.sin_port = 0;
+         if (envaddr = getenv("KRB5LOCALPORT"))
+           local.sin_port = htons(atoi(envaddr));
+         else
+           local.sin_port = 0;
        } else {
          fprintf(stderr, "v4rcp: couldn't get local address (KRB5LOCALADDR)\n");
          exit(1);
@@ -1015,7 +1018,10 @@ answer_auth()
          foreign.sin_addr.s_addr = inet_addr(envaddr);
 #endif
          foreign.sin_family = AF_INET;
-         foreign.sin_port = 0;
+         if (envaddr = getenv("KRB5REMOTEPORT"))
+           foreign.sin_port = htons(atoi(envaddr));
+         else
+           foreign.sin_port = 0;
        } else {
          fprintf(stderr, "v4rcp: couldn't get remote address (KRB5REMOTEADDR)\n");
          exit(1);