]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-netrestrict-netinfo-20081129
authorJeffrey Altman <jaltman@your-file-system.com>
Sat, 29 Nov 2008 18:55:43 +0000 (18:55 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 29 Nov 2008 18:55:43 +0000 (18:55 +0000)
LICENSE MIT

Rename rxi_getAllAddrMaskMtu to rx_getAllAddrMaskMtu.

Implement rx_getAllAddrMaskMtu for Windows.

Add rx_getAllAddrMaskMtu to the libafsrpc exports list.

Remove restrictions on use of NetRestrict / NetInfo files from
all services on Windows.

(cherry picked from commit 55ac2b7aa7da8ead2b3457781d9d60958bfad6be)

15 files changed:
src/bozo/bosserver.c
src/budb/server.c
src/butc/tcmain.c
src/kauth/kaserver.c
src/libafsrpc/afsrpc.def
src/ptserver/ptserver.c
src/rx/rx_getaddr.c
src/rx/rx_prototypes.h
src/rx/rx_user.c
src/ubik/beacon.c
src/update/server.c
src/util/NTMakefile
src/util/netutils.c
src/viced/viced.c
src/volser/volmain.c

index 4f54953cfa0ad86e0ad94bc97083bb6a76d4809d..f29ba8f0a76c519c0762e72247252d5df86ff5c2 100644 (file)
@@ -1041,7 +1041,6 @@ main(int argc, char **argv, char **envp)
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -1050,7 +1049,6 @@ main(int argc, char **argv, char **envp)
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index 1da790052d6769150f489b2415f017a0dea26673..b92930575fc16e3136d7eed5cba2280153cb31bc 100644 (file)
@@ -542,7 +542,6 @@ main(argc, argv)
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -551,7 +550,6 @@ main(argc, argv)
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index c9bb6c0bc27ad9b09c4b1fac9be04f8a7617da6e..935aea40636135c38a73a08ae291b99bdaaa95d8 100644 (file)
@@ -1034,7 +1034,6 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     if (rxBind) {
         afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -1043,7 +1042,6 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index 396830c63ed7a9a30d6a5ae071b3dbb4dca9fbcb..9c22ba27ad31b0ff7349fa74fff263cede27344c 100644 (file)
@@ -390,7 +390,6 @@ main(argc, argv)
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -399,7 +398,6 @@ main(argc, argv)
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index 2cf4b9f90f2cb2833efd207a881503c3d7cbaa06..640961838c76670c6f5941829771c04e7f9aec8e 100644 (file)
@@ -236,6 +236,7 @@ EXPORTS
         rx_SetRxDeadTime                        @241
         rx_GetMinUdpBufSize                     @242
         rx_SetUdpBufSize                        @243        
+        rx_getAllAddrMaskMtu                    @244        
 
 ; for performance testing
         rx_TSFPQGlobSize                        @2001 DATA
index 9b33ecf29a85b9e4409293ad962b818fd958b0bd..d2ee0771ed8f6c32aafd46bcd673c982783aded2 100644 (file)
@@ -515,7 +515,6 @@ main(int argc, char **argv)
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
            AFSDIR_SERVER_NETINFO_FILEPATH) {
            char reason[1024];
@@ -524,7 +523,6 @@ main(int argc, char **argv)
                                           AFSDIR_SERVER_NETINFO_FILEPATH,
                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        } else 
-#endif
        {
            ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
        }
index b6c0bc74b3eb529d6f411d9992e09c93ee7b1d7d..768543b0799d38717e6aa8bd32cef8938214c471 100644 (file)
@@ -222,8 +222,8 @@ rx_getAllAddr_internal(afs_uint32 buffer[], int maxSize, int loopbacks)
 }
 
 int
-rxi_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
-                     afs_uint32 mtuBuffer[], int maxSize)
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+                    afs_uint32 mtuBuffer[], int maxSize)
 {
     int s;
 
@@ -419,8 +419,8 @@ rx_getAllAddr(afs_uint32 buffer[], int maxSize)
  * by afsi_SetServerIPRank().
  */
 int
-rxi_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
-                     afs_uint32 mtuBuffer[], int maxSize)
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+                     afs_uint32 mtuBuffer[], int maxSize)
 {
     int s;
     int i, len, count = 0;
index b0c3652caaa1cfec9a9ee96e4b7c7912046a48de..97c57bdf13c585a1f1b13e4ed93ab693e9f2b87c 100644 (file)
@@ -334,7 +334,7 @@ extern int rxevent_RaiseEvents(struct clock *next);
 extern void rxi_setaddr(afs_uint32 x);
 extern afs_uint32 rxi_getaddr(void);
 extern int rx_getAllAddr(afs_uint32 * buffer, int maxSize);
-extern int rxi_getAllAddrMaskMtu(afs_uint32 addrBuffer[], 
+extern int rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], 
                                 afs_uint32 maskBuffer[],
                                 afs_uint32 mtuBuffer[],
                                 int maxSize);
index 708d014b24392e533f6c48308c7250a67d6ac5e2..4ad17f731fba50f579cf2d25c5129982f23a641e 100644 (file)
@@ -309,14 +309,14 @@ rx_getAllAddr(afs_uint32 * buffer, int maxSize)
     /* The IP address list can change so we must query for it */
     rx_GetIFInfo();
 
-#ifndef AFS_NT40_ENV
+#ifdef AFS_DJGPP_ENV
     /* we don't want to use the loopback adapter which is first */
     /* this is a bad bad hack.
      * and doesn't hold true on Windows.
      */
     if ( rxi_numNetAddrs > 1 )
         offset = 1;
-#endif /* AFS_NT40_ENV */
+#endif /* AFS_DJGPP_ENV */
 
     for (count = 0; offset < rxi_numNetAddrs && maxSize > 0;
         count++, offset++, maxSize--)
@@ -324,6 +324,39 @@ rx_getAllAddr(afs_uint32 * buffer, int maxSize)
 
     return count;
 }
+
+/* this function returns the total number of interface addresses
+ * the buffer has to be passed in by the caller. It also returns
+ * the matching interface mask and mtu.  All values are returned
+ * in network byte order.
+ */
+int
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+                     afs_uint32 mtuBuffer[], int maxSize)
+{
+    int count = 0, offset = 0;
+
+    /* The IP address list can change so we must query for it */
+    rx_GetIFInfo();
+
+#ifdef AFS_DJGPP_ENV
+    /* we don't want to use the loopback adapter which is first */
+    /* this is a bad bad hack.
+     * and doesn't hold true on Windows.
+     */
+    if ( rxi_numNetAddrs > 1 )
+        offset = 1;
+#endif /* AFS_DJGPP_ENV */
+
+    for (count = 0; 
+         offset < rxi_numNetAddrs && maxSize > 0;
+         count++, offset++, maxSize--) {
+       addrBuffer[count] = htonl(rxi_NetAddrs[offset]);
+       maskBuffer[count] = htonl(myNetMasks[offset]);
+       mtuBuffer[count]  = htonl(myNetMTUs[offset]);
+    }
+    return count;
+}
 #endif
 
 #ifdef AFS_NT40_ENV
index 9a996c78b48ce65d8ecd1d47bceb2d7705776d14..c2e3c41fa0b1e28fc5ba95149c3406a37638e27f 100644 (file)
@@ -528,10 +528,6 @@ verifyInterfaceAddress(ame, info, aservers)
            totalServers++;
     }
 
-#ifdef AFS_NT40_ENV
-    /* get all my interface addresses in net byte order */
-    count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
-#else
     if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
        /*
         * Find addresses we are supposed to register as per the netrestrict file
@@ -554,7 +550,6 @@ verifyInterfaceAddress(ame, info, aservers)
        /* get all my interface addresses in net byte order */
        count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR);
     }
-#endif
 
     if (count <= 0) {          /* no address found */
        ubik_print("ubik: No network addresses found, aborting..");
index f66edc0ce75ba9e41ad56a24be0a1956b15536dc..b91c9a105ac429943083b61d13cd0c189ac0d182 100644 (file)
@@ -278,7 +278,6 @@ main(int argc, char *argv[])
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -287,7 +286,6 @@ main(int argc, char *argv[])
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index e63ea76e847606c6a578cf3121f7e8105066e92b..cdcbf79be1b79b1ff048e47ce8f7262dd830941e 100644 (file)
@@ -19,6 +19,7 @@ INCFILES =\
        $(INCFILEDIR)\errors.h \
        $(INCFILEDIR)\itc.h \
        $(INCFILEDIR)\vice.h \
+        $(INCFILEDIR)\netutils.h \
        $(INCFILEDIR)\pthread_glock.h \
        $(INCFILEDIR)\pthread_nosigs.h \
        $(INCFILEDIR)\errmap_nt.h \
@@ -45,6 +46,7 @@ LIBOBJS = \
        $(OUT)\isathing.obj \
        $(OUT)\kreltime.obj \
        $(OUT)\ktime.obj \
+        $(OUT)\netutils.obj \
        $(OUT)\regex.obj \
        $(OUT)\readdir_nt.obj \
        $(OUT)\serverLog.obj \
index 63d2995d4d2983ac85f190fdef33e114992ff033..5f807c29cff37f6ce7414a5dfb1f81dddc37e477 100644 (file)
@@ -30,13 +30,17 @@ RCSID
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
 #else
+#ifdef AFS_NT40_ENV
+#include <winsock2.h>
+#else 
 #ifdef __FreeBSD__
 #include <sys/types.h>
 #endif
 #include <netinet/in.h>
-#include <errno.h>
 #include <sys/errno.h>
 #endif
+#include <errno.h>
+#endif
 
 #include "assert.h"
 #include "afsutil.h"
@@ -116,7 +120,7 @@ extract_Addr(char *line, int maxSize)
  * caller can choose to ignore the entire file but should write
  * something to a log file).
  *
- * All addresses should be in NBO (as returned by rx_getAllAddr() and
+ * All addresses should be in NBO (as returned by rx_getAllAddrMaskMtu() and
  * parsed by extract_Addr().
  */
 /*
@@ -154,7 +158,7 @@ parseNetRestrictFile_int(afs_uint32 outAddrs[], afs_uint32 * mask,
     strcpy(reason, "");
 
     /* get all network interfaces from the kernel */
-    neaddrs = rxi_getAllAddrMaskMtu(eAddrs, eMask, eMtu, MAXIPADDRS);
+    neaddrs = rx_getAllAddrMaskMtu(eAddrs, eMask, eMtu, MAXIPADDRS);
     if (neaddrs <= 0) {
        sprintf(reason, "No existing IP interfaces found");
        return -1;
@@ -269,7 +273,7 @@ ParseNetInfoFile_int(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu,
 
     /* get all network interfaces from the kernel */
     existNu =
-       rxi_getAllAddrMaskMtu(existingAddr, existingMask, existingMtu,
+       rx_getAllAddrMaskMtu(existingAddr, existingMask, existingMtu,
                              MAXIPADDRS);
     if (existNu < 0)
        return existNu;
index f24ad7c040dee0a59d94611e5f865d3dc0e049e4..05e7746eb97dc6256d1b4c522c479af245b0c19d 100644 (file)
@@ -1812,7 +1812,6 @@ SetupVL()
     extern int rxi_numNetAddrs;
     extern afs_uint32 rxi_NetAddrs[];
 
-#ifndef AFS_NT40_ENV
     if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
        /*
         * Find addresses we are supposed to register as per the netrestrict 
@@ -1830,7 +1829,6 @@ SetupVL()
        }
        FS_HostAddr_cnt = (afs_uint32) code;
     } else
-#endif
     {
        FS_HostAddr_cnt = rx_getAllAddr(FS_HostAddrs, ADDRSPERSITE);
     }
index 629356ec5f209c28ce9de635cd90813f93a4fefd..98c09016d13b127e5a62de2ccf33a6a6c48b437c 100644 (file)
@@ -450,7 +450,6 @@ main(int argc, char **argv)
        rx_SetUdpBufSize(udpBufSize);   /* set the UDP buffer size for receive */
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
@@ -459,7 +458,6 @@ main(int argc, char **argv)
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else 
-#endif 
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }