]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
auth: Relocate NetRestrict support functions
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 20 May 2012 11:57:00 +0000 (12:57 +0100)
committerDerrick Brashear <shadow@dementix.org>
Fri, 31 Aug 2012 17:39:59 +0000 (10:39 -0700)
Pull the NetRestrict and NetInfo support functions out of libutil,
and into libauth. This starts to concentrate all of our configuration
file parsing functions into the same place.

It also gets rid of a circular dependency. NetRestrict parsing relies
on functions from rx, so with this in libutil, we had the dependency
chain util->rx->util

Change-Id: I250d4d8264da8db61f603a06d1b7fdab44384cd3
Reviewed-on: http://gerrit.openafs.org/8027
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
36 files changed:
src/WINNT/install/wix/files.wxi
src/afsd/afsd.c
src/auth/Makefile.in
src/auth/NTMakefile
src/auth/cellconfig.p.h
src/auth/netrestrict.c [new file with mode: 0644]
src/bozo/bosserver.c
src/budb/server.c
src/butc/tcmain.c
src/dviced/Makefile.in
src/dvolser/Makefile.in
src/kauth/kaserver.c
src/libafsauthent/Makefile.in
src/libafsauthent/NTMakefile
src/libafsauthent/afsauthent.def
src/libuafs/Makefile.common.in
src/ptserver/ptserver.c
src/tbudb/Makefile.in
src/tptserver/Makefile.in
src/tsalvaged/Makefile.in
src/tsalvaged/NTMakefile
src/tubik/Makefile.in
src/tvlserver/Makefile.in
src/tvolser/Makefile.in
src/ubik/Makefile.in
src/ubik/beacon.c
src/update/server.c
src/util/Makefile.in
src/util/NTMakefile
src/util/afsutil_prototypes.h
src/util/netutils.c [deleted file]
src/util/netutils.h [deleted file]
src/viced/Makefile.in
src/viced/viced.c
src/vlserver/vlserver.c
src/volser/volmain.c

index 764ff6fb7c9e0d879e8481c5bf6009b90258def8..c3e864fd816aee229eabca28309fa6209fcbd7ee 100644 (file)
                                 <File Id="filelockprocs_prototypes_H" Name="LOCKPROC.h" LongName="lockprocs_prototypes.h" DiskId="1" src="$(var.IncDir)afs\lockprocs_prototypes.h" />
                                 <File Id="filemit_sipb_cr_H" Name="MITSIPBC.h" LongName="mit-sipb-cr.h" DiskId="1" src="$(var.IncDir)afs\mit-sipb-cr.h" />
                                 <File Id="filenamei_ops_H" Name="nameiops.h" LongName="namei_ops.h" DiskId="1" src="$(var.IncDir)afs\namei_ops.h" />
-                                <File Id="filenetutils_H" Name="netutil.h" LongName="netutils.h" DiskId="1" src="$(var.IncDir)afs\netutils.h" />
                                 <File Id="filenfs_H" Name="nfs.h" LongName="nfs.h" DiskId="1" src="$(var.IncDir)afs\nfs.h" /> 
                                 <File Id="filentops_H" Name="ntops.h" LongName="ntops.h" DiskId="1" src="$(var.IncDir)afs\ntops.h" /> 
                                 <File Id="fileopr_H" Name="opr.h" LongName="opr.h" DiskId="1" src="$(var.IncDir)afs\opr.h" />
index adc63b0405c689133b115a71f66f8496af3073cd..9050ef535fb3767dba748175da5f8f9c27d7642d 100644 (file)
@@ -398,10 +398,9 @@ afsd_update_addresses(CFRunLoopTimerRef timer, void *info)
     char reason[1024];
     int code;
 
-    code =
-       parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
-                     AFSDIR_CLIENT_NETINFO_FILEPATH,
-                     AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
+    code = afsconf_ParseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS,
+                                reason, AFSDIR_CLIENT_NETINFO_FILEPATH,
+                                AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
 
     if (code > 0) {
        /* Note we're refreshing */
@@ -2125,10 +2124,9 @@ afsd_run(void)
        afs_uint32 addrbuf[MAXIPADDRS], maskbuf[MAXIPADDRS],
            mtubuf[MAXIPADDRS];
        char reason[1024];
-       code =
-           parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
-                         AFSDIR_CLIENT_NETINFO_FILEPATH,
-                         AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
+       code = afsconf_ParseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
+                                    AFSDIR_CLIENT_NETINFO_FILEPATH,
+                                    AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
        if (code > 0) {
            if (enable_rxbind)
                code = code | 0x80000000;
index 8f2cf1cb607b60ea28edb1224dc738a9c6ae2909..4825a420798b8d482f7c239ce8bdf0fa3781d704 100644 (file)
@@ -11,9 +11,9 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
 
 
 OBJS= cellconfig.o keys.o ktc.o userok.o writeconfig.o authcon.o \
-    acfg_errors.o ktc_errors.o token.xdr.o token.o realms.o
+    acfg_errors.o ktc_errors.o token.xdr.o token.o realms.o netrestrict.o
 KOBJS= cellconfig.o keys.o ktc.krb.o userok.o writeconfig.o authcon.o \
-    acfg_errors.o ktc_errors.o token.xdr.o token.o realms.o
+    acfg_errors.o ktc_errors.o token.xdr.o token.o realms.o netrestrict.o
 
 LIBS=libauth.a \
       ${TOP_LIBDIR}/librxkad.a \
@@ -71,6 +71,7 @@ cellconfig.o: cellconfig.c ${INCLS}
 copyauth.o: copyauth.c ${INCLS} AFS_component_version_number.o
 setkey.o: setkey.c ${INCLS} AFS_component_version_number.o
 realms.o: realms.c ${INCLS}
+netrestrict.o: ${INCLS}
 
 CFLAGS_ktc.krb.o = -DAFS_KERBEROS_ENV
 ktc.krb.o: ktc.c ${INCLS} ${TOP_INCDIR}/afs/vice.h
index feb304070d78c3902f4b98e6a3ca339a7752d645..37146e8216e9ee6382d49bb92fb71d5a0f6e6263 100644 (file)
@@ -47,6 +47,7 @@ AFSAUTH_LIBOBJS =\
        $(OUT)\ktc_nt.obj \
         $(OUT)\token.obj \
         $(OUT)\token.xdr.obj \
+       $(OUT)\netrestrict.obj \
        $(OUT)\AFS_component_version_number.obj
 
 AFSDOBJS =\
index 57519683dbfdefca0094ac411e857181eec02030..f22153d97013c80b47f569628e555a596dc108eb 100644 (file)
@@ -260,6 +260,18 @@ extern int afsconf_IsLocalRealmMatch(struct afsconf_dir *dir, afs_int32 * local,
                                const char *name, const char *instance,
                                const char *cell);
 
+/* netrestrict.c */
+
+extern int afsconf_ParseNetRestrictFile(afs_uint32 outAddrs[],
+                                       afs_uint32 * mask, afs_uint32 * mtu,
+                                       afs_uint32 maxAddrs, afs_uint32 * nAddrs,
+                                       char reason[], const char *fileName);
+
+extern int afsconf_ParseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[],
+                                afs_uint32 mtubuf[], afs_uint32 max,
+                                char reason[], const char *niFileName,
+                                const char *nrFileName);
+
 /* some well-known ports and their names; new additions to table in cellconfig.c, too */
 #define        AFSCONF_FILESERVICE             "afs"
 #define        AFSCONF_FILEPORT                7000
diff --git a/src/auth/netrestrict.c b/src/auth/netrestrict.c
new file mode 100644 (file)
index 0000000..9c5675e
--- /dev/null
@@ -0,0 +1,480 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+
+/*
+ * Network utility functions
+ * Parsing NetRestrict file and filtering IP addresses
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#include <roken.h>
+#include <ctype.h>
+
+#include <rx/rx.h>
+#include <afs/dirpath.h>
+
+#include "cellconfig.h"
+
+#define AFS_IPINVALID        0xffffffff        /* invalid IP address */
+#define AFS_IPINVALIDIGNORE  0xfffffffe        /* no input given to extractAddr */
+#define MAX_NETFILE_LINE       2048    /* length of a line in the netrestrict file */
+#define MAXIPADDRS             1024    /* from afsd.c */
+
+static int ParseNetInfoFile_int(afs_uint32 *, afs_uint32 *, afs_uint32 *,
+                         int, char reason[], const char *,
+                         int);
+/*
+ * The line parameter is a pointer to a buffer containing a string of
+ * bytes of the form
+** w.x.y.z     # machineName
+ * returns the network interface IP Address in NBO
+ */
+afs_uint32
+extract_Addr(char *line, int maxSize)
+{
+    char bytes[4][32];
+    int i = 0, n = 0;
+    char *endPtr;
+    afs_uint32 val[4];
+    afs_uint32 retval = 0;
+
+    /* skip empty spaces */
+    while (isspace(*line) && maxSize) {
+       line++;
+       maxSize--;
+    }
+    /* skip empty lines */
+    if (!maxSize || !*line)
+       return AFS_IPINVALIDIGNORE;
+
+    for (n = 0; n < 4; n++) {
+       while ((*line != '.') && !isspace(*line) && maxSize) {  /* extract nth byte */
+           if (!isdigit(*line))
+               return AFS_IPINVALID;
+           if (i > 31)
+               return AFS_IPINVALID;   /* no space */
+           bytes[n][i++] = *line++;
+           maxSize--;
+       }                       /* while */
+       if (!maxSize)
+           return AFS_IPINVALID;
+       bytes[n][i] = 0;
+       i = 0, line++;
+       errno = 0;
+       val[n] = strtol(bytes[n], &endPtr, 10);
+       if ((val[n] == 0) && (errno != 0 || bytes[n] == endPtr))        /* no conversion */
+           return AFS_IPINVALID;
+    }                          /* for */
+
+    retval = (val[0] << 24) | (val[1] << 16) | (val[2] << 8) | val[3];
+    return htonl(retval);
+}
+
+
+
+
+/* parseNetRestrictFile()
+ * Get a list of IP addresses for this host removing any address found
+ * in the config file (fileName parameter): /usr/vice/etc/NetRestrict
+ * for clients and /usr/afs/local/NetRestrict for servers.
+ *
+ * Returns the number of valid addresses in outAddrs[] and count in
+ * nAddrs.  Returns 0 on success; or 1 if the config file was not
+ * there or empty (we still return the host's IP addresses). Returns
+ * -1 on fatal failure with reason in the reason argument (so the
+ * 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_getAllAddrMaskMtu() and
+ * parsed by extract_Addr().
+ */
+/*
+  afs_uint32  outAddrs[];          * output address array *
+  afs_uint32  *mask, *mtu;         * optional mask and mtu *
+  afs_uint32 maxAddrs;            * max number of addresses *
+  afs_uint32 *nAddrs;              * number of Addresses in output array *
+  char       reason[];             * reason for failure *
+  const char *fileName;            * filename to parse *
+*/
+
+static int
+parseNetRestrictFile_int(afs_uint32 outAddrs[], afs_uint32 * mask,
+                        afs_uint32 * mtu, afs_uint32 maxAddrs,
+                        afs_uint32 * nAddrs, char reason[],
+                        const char *fileName, const char *fileName_ni)
+{
+    FILE *fp;
+    char line[MAX_NETFILE_LINE];
+    int lineNo, usedfile = 0;
+    afs_uint32 i, neaddrs, nOutaddrs;
+    afs_uint32 addr, eAddrs[MAXIPADDRS], eMask[MAXIPADDRS], eMtu[MAXIPADDRS];
+
+    osi_Assert(outAddrs);
+    osi_Assert(reason);
+    osi_Assert(fileName);
+    osi_Assert(nAddrs);
+    if (mask)
+       osi_Assert(mtu);
+
+    /* Initialize */
+    *nAddrs = 0;
+    for (i = 0; i < maxAddrs; i++)
+       outAddrs[i] = 0;
+    strcpy(reason, "");
+
+    /* get all network interfaces from the kernel */
+    neaddrs = rx_getAllAddrMaskMtu(eAddrs, eMask, eMtu, MAXIPADDRS);
+    if (neaddrs <= 0) {
+       sprintf(reason, "No existing IP interfaces found");
+       return -1;
+    }
+    i = 0;
+    if ((neaddrs < MAXIPADDRS) && fileName_ni)
+       i = ParseNetInfoFile_int(&(eAddrs[neaddrs]), &(eMask[neaddrs]),
+                                &(eMtu[neaddrs]), MAXIPADDRS-neaddrs, reason,
+                                fileName_ni, 1);
+
+    if (i > 0)
+       neaddrs += i;
+
+    if ((fp = fopen(fileName, "r")) == 0) {
+       sprintf(reason, "Could not open file %s for reading:%s", fileName,
+               strerror(errno));
+       goto done;
+    }
+
+    /* For each line in the NetRestrict file */
+    lineNo = 0;
+    usedfile = 0;
+    while (fgets(line, MAX_NETFILE_LINE, fp) != NULL) {
+       lineNo++;               /* input line number */
+       addr = extract_Addr(line, strlen(line));
+       if (addr == AFS_IPINVALID) {    /* syntactically invalid */
+           fprintf(stderr, "%s : line %d : parse error - invalid IP\n",
+                   fileName, lineNo);
+           continue;
+       }
+       if (addr == AFS_IPINVALIDIGNORE) {      /* ignore error */
+           fprintf(stderr, "%s : line %d : invalid address ... ignoring\n",
+                   fileName, lineNo);
+           continue;
+       }
+       usedfile = 1;
+
+       /* Check if we need to exclude this address */
+       for (i = 0; i < neaddrs; i++) {
+           if (eAddrs[i] && (eAddrs[i] == addr)) {
+               eAddrs[i] = 0;  /* Yes - exclude it by zeroing it for now */
+           }
+       }
+    }                          /* while */
+
+    fclose(fp);
+
+    if (!usedfile) {
+       sprintf(reason, "No valid IP addresses in %s\n", fileName);
+       goto done;
+    }
+
+  done:
+    /* Collect the addresses we have left to return */
+    nOutaddrs = 0;
+    for (i = 0; i < neaddrs; i++) {
+       if (!eAddrs[i])
+           continue;
+       outAddrs[nOutaddrs] = eAddrs[i];
+       if (mask) {
+           mask[nOutaddrs] = eMask[i];
+           mtu[nOutaddrs] = eMtu[i];
+       }
+       if (++nOutaddrs >= maxAddrs)
+           break;
+    }
+    if (nOutaddrs == 0) {
+       sprintf(reason, "No addresses to use after parsing %s", fileName);
+       return -1;
+    }
+    *nAddrs = nOutaddrs;
+    return (usedfile ? 0 : 1); /* 0=>used the file.  1=>didn't use file */
+}
+
+int
+afsconf_ParseNetRestrictFile(afs_uint32 outAddrs[], afs_uint32 * mask,
+                            afs_uint32 * mtu, afs_uint32 maxAddrs,
+                            afs_uint32 * nAddrs, char reason[],
+                            const char *fileName)
+{
+    return parseNetRestrictFile_int(outAddrs, mask, mtu, maxAddrs, nAddrs, reason, fileName, NULL);
+}
+
+/*
+ * this function reads in stuff from InterfaceAddr file in
+ * /usr/vice/etc ( if it exists ) and verifies the addresses
+ * specified.
+ * 'final' contains all those addresses that are found to
+ * be valid. This function returns the number of valid
+ * interface addresses. Pulled out from afsd.c
+ */
+static int
+ParseNetInfoFile_int(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu,
+                    int max, char reason[], const char *fileName,
+                    int fakeonly)
+{
+
+    afs_uint32 existingAddr[MAXIPADDRS], existingMask[MAXIPADDRS],
+       existingMtu[MAXIPADDRS];
+    char line[MAX_NETFILE_LINE];
+    FILE *fp;
+    int i, existNu, count = 0;
+    afs_uint32 addr;
+    int lineNo = 0;
+    int l;
+
+    osi_Assert(fileName);
+    osi_Assert(final);
+    osi_Assert(mask);
+    osi_Assert(mtu);
+    osi_Assert(reason);
+
+    /* get all network interfaces from the kernel */
+    existNu =
+       rx_getAllAddrMaskMtu(existingAddr, existingMask, existingMtu,
+                             MAXIPADDRS);
+    if (existNu < 0)
+       return existNu;
+
+    if ((fp = fopen(fileName, "r")) == 0) {
+       /* If file does not exist or is not readable, then
+        * use all interface addresses.
+        */
+       sprintf(reason,
+               "Failed to open %s(%s)\nUsing all configured addresses\n",
+               fileName, strerror(errno));
+       for (i = 0; i < existNu; i++) {
+           final[i] = existingAddr[i];
+           mask[i] = existingMask[i];
+           mtu[i] = existingMtu[i];
+       }
+       return existNu;
+    }
+
+    /* For each line in the NetInfo file */
+    while (fgets(line, MAX_NETFILE_LINE, fp) != NULL) {
+       int fake = 0;
+
+       /* See if first char is an 'F' for fake */
+       /* Added to allow the fileserver to advertise fake IPS for use with
+        * the translation tables for NAT-like firewalls - defect 12462 */
+       for (fake = 0; ((fake < strlen(line)) && isspace(line[fake]));
+            fake++);
+       if ((fake < strlen(line))
+           && ((line[fake] == 'f') || (line[fake] == 'F'))) {
+           fake++;
+       } else {
+           fake = 0;
+       }
+
+       lineNo++;               /* input line number */
+       addr = extract_Addr(&line[fake], strlen(&line[fake]));
+
+       if (addr == AFS_IPINVALID) {    /* syntactically invalid */
+           fprintf(stderr, "afs:%s : line %d : parse error\n", fileName,
+                   lineNo);
+           continue;
+       }
+       if (addr == AFS_IPINVALIDIGNORE) {      /* ignore error */
+           continue;
+       }
+
+       /* See if it is an address that really exists */
+       for (i = 0; i < existNu; i++) {
+           if (existingAddr[i] == addr)
+               break;
+       }
+       if ((i >= existNu) && (!fake))
+           continue;           /* not found/fake - ignore */
+
+       /* Check if it is a duplicate address we alread have */
+       for (l = 0; l < count; l++) {
+           if (final[l] == addr)
+               break;
+       }
+       if (l < count) {
+           fprintf(stderr, "afs:%x specified twice in NetInfo file\n",
+                   ntohl(addr));
+           continue;           /* duplicate addr - ignore */
+       }
+
+       if (count > max) {      /* no more space */
+           fprintf(stderr,
+                   "afs:Too many interfaces. The current kernel configuration supports a maximum of %d interfaces\n",
+                   max);
+       } else if (fake) {
+           if (!fake)
+               fprintf(stderr, "Client (2) also has address %s\n", line);
+           final[count] = addr;
+           mask[count] = 0xffffffff;
+           mtu[count] = htonl(1500);
+           count++;
+       } else if (!fakeonly) {
+           final[count] = existingAddr[i];
+           mask[count] = existingMask[i];
+           mtu[count] = existingMtu[i];
+           count++;
+       }
+    }                          /* while */
+
+    /* in case of any error, we use all the interfaces present */
+    if (count <= 0) {
+       sprintf(reason,
+               "Error in reading/parsing Interface file\nUsing all configured interface addresses \n");
+       for (i = 0; i < existNu; i++) {
+           final[i] = existingAddr[i];
+           mask[i] = existingMask[i];
+           mtu[i] = existingMtu[i];
+       }
+       return existNu;
+    }
+    return count;
+}
+
+int
+afsconf_ParseNetInfoFile(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu,
+                        int max, char reason[], const char *fileName)
+{
+    return ParseNetInfoFile_int(final, mask, mtu, max, reason, fileName, 0);
+}
+
+/*
+ * Given two arrays of addresses, masks and mtus find the common ones
+ * and return them in the first buffer. Return number of common
+ * entries.
+ */
+static int
+filterAddrs(afs_uint32 addr1[], afs_uint32 addr2[], afs_uint32 mask1[],
+           afs_uint32 mask2[], afs_uint32 mtu1[], afs_uint32 mtu2[], int n1,
+           int n2)
+{
+    afs_uint32 taddr[MAXIPADDRS];
+    afs_uint32 tmask[MAXIPADDRS];
+    afs_uint32 tmtu[MAXIPADDRS];
+    int count = 0, i = 0, j = 0, found = 0;
+
+    osi_Assert(addr1);
+    osi_Assert(addr2);
+    osi_Assert(mask1);
+    osi_Assert(mask2);
+    osi_Assert(mtu1);
+    osi_Assert(mtu2);
+
+    for (i = 0; i < n1; i++) {
+       found = 0;
+       for (j = 0; j < n2; j++) {
+           if (addr1[i] == addr2[j]) {
+               found = 1;
+               break;
+           }
+       }
+
+       /* Always mask loopback address */
+       if (found && rx_IsLoopbackAddr(addr1[i]))
+           found = 0;
+
+       if (found) {
+           taddr[count] = addr1[i];
+           tmask[count] = mask1[i];
+           tmtu[count] = mtu1[i];
+           count++;
+       }
+    }
+    /* copy everything into addr1, mask1 and mtu1 */
+    for (i = 0; i < count; i++) {
+       addr1[i] = taddr[i];
+       if (mask1) {
+           mask1[i] = tmask[i];
+           mtu1[i] = tmtu[i];
+       }
+    }
+    /* and zero out the rest */
+    for (i = count; i < n1; i++) {
+       addr1[i] = 0;
+       if (mask1) {
+           mask1[i] = 0;
+           mtu1[i] = 0;
+       }
+    }
+    return count;
+}
+
+/*
+ * parse both netinfo and netrerstrict files and return the final
+ * set of IP addresses to use
+ */
+/* max - Entries in addrbuf, maskbuf and mtubuf */
+int
+afsconf_ParseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[],
+                     afs_uint32 mtubuf[], afs_uint32 max, char reason[],
+                     const char *niFileName, const char *nrFileName)
+{
+    afs_uint32 addrbuf1[MAXIPADDRS], maskbuf1[MAXIPADDRS],
+       mtubuf1[MAXIPADDRS];
+    afs_uint32 addrbuf2[MAXIPADDRS], maskbuf2[MAXIPADDRS],
+       mtubuf2[MAXIPADDRS];
+    int nAddrs1 = 0;
+    afs_uint32 nAddrs2 = 0;
+    int code, i;
+
+    nAddrs1 =
+       afsconf_ParseNetInfoFile(addrbuf1, maskbuf1, mtubuf1, MAXIPADDRS,
+                                reason, niFileName);
+    code =
+       parseNetRestrictFile_int(addrbuf2, maskbuf2, mtubuf2, MAXIPADDRS,
+                            &nAddrs2, reason, nrFileName, niFileName);
+    if ((nAddrs1 < 0) && (code)) {
+       /* both failed */
+       return -1;
+    } else if ((nAddrs1 > 0) && (code)) {
+       /* netinfo succeeded and netrestrict failed */
+       for (i = 0; ((i < nAddrs1) && (i < max)); i++) {
+           addrbuf[i] = addrbuf1[i];
+           if (maskbuf) {
+               maskbuf[i] = maskbuf1[i];
+               mtubuf[i] = mtubuf1[i];
+           }
+       }
+       return i;
+    } else if ((!code) && (nAddrs1 < 0)) {
+       /* netrestrict succeeded and netinfo failed */
+       for (i = 0; ((i < nAddrs2) && (i < max)); i++) {
+           addrbuf[i] = addrbuf2[i];
+           if (maskbuf) {
+               maskbuf[i] = maskbuf2[i];
+               mtubuf[i] = mtubuf2[i];
+           }
+       }
+       return i;
+    } else if ((!code) && (nAddrs1 >= 0)) {
+       /* both succeeded */
+       /* take the intersection of addrbuf1 and addrbuf2 */
+       code =
+           filterAddrs(addrbuf1, addrbuf2, maskbuf1, maskbuf2, mtubuf1,
+                       mtubuf2, nAddrs1, nAddrs2);
+       for (i = 0; ((i < code) && (i < max)); i++) {
+           addrbuf[i] = addrbuf1[i];
+           if (maskbuf) {
+               maskbuf[i] = maskbuf1[i];
+               mtubuf[i] = mtubuf1[i];
+           }
+       }
+       return i;
+    }
+    return 0;
+}
index bab0f622ef99179e78269f5343a4df98549dfd61..9ab975b948dd0b1cce56e827709c9a4b3f4c6e05 100644 (file)
@@ -1060,10 +1060,10 @@ main(int argc, char **argv, char **envp)
        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
            AFSDIR_SERVER_NETINFO_FILEPATH) {
            char reason[1024];
-           ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                 ADDRSPERSITE, reason,
-                                 AFSDIR_SERVER_NETINFO_FILEPATH,
-                                 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+           ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                         ADDRSPERSITE, reason,
+                                         AFSDIR_SERVER_NETINFO_FILEPATH,
+                                         AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
index 14c83446e0b31e13820752f9f979e8bd59be41e2..dd8f24f1bc2276e0f5f6fa82c66193b1d20e046b 100644 (file)
@@ -514,10 +514,10 @@ main(int argc, char **argv)
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                           ADDRSPERSITE, reason,
-                                           AFSDIR_SERVER_NETINFO_FILEPATH,
-                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
index 088def14faf853e4e666cd744cd34017ff023972..98e6f71fd58237d49c35d7b68a0954423a4f8bfe 100644 (file)
@@ -1028,10 +1028,10 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                           ADDRSPERSITE, reason,
-                                           AFSDIR_SERVER_NETINFO_FILEPATH,
-                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
index 30fbefec58778928272ae38cc17c2998b832619e..b4246d42d6614e68aa5c8a7c48981d1af315e823 100644 (file)
@@ -34,7 +34,7 @@ LWPOBJS=lock.o threadname.o
 
 LIBACLOBJS=aclprocs.o netprocs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o volparse.o flipbase64.o softsig.o
 
 DIROBJS=buffer.o dir.o salvage.o
 
@@ -100,9 +100,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) -I../util $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 0ebd2075936a75e30a741d1ac64940fca649520e..e35123e09598ac2f0cfbc6f28e533fe6b51a6bf6 100644 (file)
@@ -30,7 +30,7 @@ LWPOBJS=lock.o threadname.o
 
 LIBACLOBJS=aclprocs.o netprocs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o volparse.o flipbase64.o softsig.o
 
 DIROBJS=buffer.o dir.o salvage.o
 
@@ -110,9 +110,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) -I../util $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 146239cb7de1471ea1beeae8ab82d95f739d184b..108bfa98de8ee239fdb831e933581c242b50a266 100644 (file)
@@ -379,10 +379,10 @@ main(int argc, char *argv[])
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                           ADDRSPERSITE, reason,
-                                           AFSDIR_SERVER_NETINFO_FILEPATH,
-                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
index 160268251d2baa1c531e7564fd1bce72873fa680..92d325de6a635aab8f9f546587c9bd5a267b997d 100644 (file)
@@ -36,7 +36,8 @@ AUTHOBJS = \
        acfg_errors.o \
        token.o \
        token.xdr.o \
-       realms.o
+       realms.o \
+       netrestrict.o
 
 KAUTHOBJS = \
        kauth.xdr.o \
@@ -227,6 +228,9 @@ ptclient.o: ${PTSERVER}/ptclient.c
 realms.o: ${AUTH}/realms.c
        ${AFS_CCRULE} -I../auth ${AUTH}/realms.c
 
+netrestrict.o: ${AUTH}/netrestrict.c
+       ${AFS_CCRULE} -I../auth ${AUTH}/netrestrict.c
+
 ptuser.o: ${PTSERVER}/ptuser.c
        ${AFS_CCRULE} -I../ptserver ${PTSERVER}/ptuser.c
 
index c06436edeb07036abb02dbda6187b7cc3320580f..1a04fb3f5755e1c4b99a2843f2499b64ac679a9e 100644 (file)
@@ -45,7 +45,8 @@ AUTHOBJS = \
        $(OUT)\keys.obj \
         $(OUT)\token.obj \
         $(OUT)\token.xdr.obj \
-       $(OUT)\acfg_errors.obj
+       $(OUT)\acfg_errors.obj \
+       $(OUT)\netrestrict.obj
 
 KAUTHOBJS = \
        $(OUT)\kauth.xdr.obj \
index 02243fe6fb4a89fb5c72b46f529a94460415fe0d..e46e55ddbcfcf96db984c50a83d3688784728dc5 100644 (file)
@@ -154,3 +154,4 @@ EXPORTS
        afsconf_SetSecurityFlags                        @153
        afsconf_SetLocalRealm                           @154
        afsconf_IsLocalRealmMatch                       @155
+       afsconf_ParseNetFiles                           @156
index 2439c7a71db1c49a82c2f28cdf1ba333c3efe1a1..eb73b2034e935b1701afb79097c4857adfaa987f 100644 (file)
@@ -216,7 +216,7 @@ UAFSOBJ = \
        $(UOBJ)/casestrcpy.o \
        $(UOBJ)/dirpath.o \
        $(UOBJ)/fileutil.o \
-       $(UOBJ)/netutils.o \
+       $(UOBJ)/netrestrict.o \
        $(UOBJ)/et_name.o \
        $(UOBJ)/com_err.o \
        $(UOBJ)/error_msg.o \
@@ -365,7 +365,7 @@ PICUAFSOBJ = \
        $(PICOBJ)/casestrcpy.o \
        $(PICOBJ)/dirpath.o \
        $(PICOBJ)/fileutil.o \
-       $(PICOBJ)/netutils.o \
+       $(PICOBJ)/netrestrict.o \
        $(PICOBJ)/et_name.o \
        $(PICOBJ)/com_err.o \
        $(PICOBJ)/error_msg.o \
@@ -514,7 +514,7 @@ AFSWEBOBJ = \
        $(WEBOBJ)/casestrcpy.o \
        $(WEBOBJ)/dirpath.o \
        $(WEBOBJ)/fileutil.o \
-       $(WEBOBJ)/netutils.o \
+       $(WEBOBJ)/netrestrict.o \
        $(WEBOBJ)/et_name.o \
        $(WEBOBJ)/com_err.o \
        $(WEBOBJ)/error_msg.o \
@@ -657,7 +657,7 @@ AFSWEBOBJKRB = \
        $(WEBOBJ)/casestrcpy.o \
        $(WEBOBJ)/dirpath.o \
        $(WEBOBJ)/fileutil.o \
-       $(WEBOBJ)/netutils.o \
+       $(WEBOBJ)/netrestrict.o \
        $(WEBOBJ)/et_name.o \
        $(WEBOBJ)/com_err.o \
        $(WEBOBJ)/error_msg.o \
@@ -804,7 +804,7 @@ JUAFSOBJ = \
        $(JUAFS)/casestrcpy.o \
        $(JUAFS)/dirpath.o \
        $(JUAFS)/fileutil.o \
-       $(JUAFS)/netutils.o \
+       $(JUAFS)/netrestrict.o \
        $(JUAFS)/et_name.o \
        $(JUAFS)/com_err.o \
        $(JUAFS)/error_msg.o \
@@ -1116,7 +1116,7 @@ $(UOBJ)/dirpath.o: $(TOP_SRCDIR)/util/dirpath.c
        $(CRULE1)
 $(UOBJ)/fileutil.o: $(TOP_SRCDIR)/util/fileutil.c
        $(CRULE1)
-$(UOBJ)/netutils.o: $(TOP_SRCDIR)/util/netutils.c
+$(UOBJ)/netrestrict.o: $(TOP_SRCDIR)/auth/netrestrict.c
        $(CRULE1)
 $(UOBJ)/et_name.o: $(TOP_SRCDIR)/comerr/et_name.c
        $(CRULE1)
@@ -1421,7 +1421,7 @@ $(PICOBJ)/dirpath.o: $(TOP_SRCDIR)/util/dirpath.c
        $(CRULEPIC)
 $(PICOBJ)/fileutil.o: $(TOP_SRCDIR)/util/fileutil.c
        $(CRULEPIC)
-$(PICOBJ)/netutils.o: $(TOP_SRCDIR)/util/netutils.c
+$(PICOBJ)/netrestrict.o: $(TOP_SRCDIR)/auth/netrestrict.c
        $(CRULEPIC)
 $(PICOBJ)/et_name.o: $(TOP_SRCDIR)/comerr/et_name.c
        $(CRULEPIC)
@@ -1735,7 +1735,7 @@ $(WEBOBJ)/dirpath.o: $(TOP_SRCDIR)/util/dirpath.c
        $(CRULE1)
 $(WEBOBJ)/fileutil.o: $(TOP_SRCDIR)/util/fileutil.c
        $(CRULE1)
-$(WEBOBJ)/netutils.o: $(TOP_SRCDIR)/util/netutils.c
+$(WEBOBJ)/netrestrict.o: $(TOP_SRCDIR)/auth/netrestrict.c
        $(CRULE1)
 $(WEBOBJ)/et_name.o: $(TOP_SRCDIR)/comerr/et_name.c
        $(CRULE2)
@@ -2035,7 +2035,7 @@ $(JUAFS)/dirpath.o: $(TOP_SRCDIR)/util/dirpath.c
        $(CRULE1)
 $(JUAFS)/fileutil.o: $(TOP_SRCDIR)/util/fileutil.c
        $(CRULE1)
-$(JUAFS)/netutils.o: $(TOP_SRCDIR)/util/netutils.c
+$(JUAFS)/netrestrict.o: $(TOP_SRCDIR)/auth/netrestrict.c
        $(CRULE1)
 $(JUAFS)/et_name.o: $(TOP_SRCDIR)/comerr/et_name.c
        $(CRULE1)
index 2fc7462568ade27251ce3cacf94b6122768fa8c7..b73e0c50b1b1f1b3a3f6bbd0bab6613eca159f81 100644 (file)
@@ -492,10 +492,10 @@ main(int argc, char **argv)
        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
            AFSDIR_SERVER_NETINFO_FILEPATH) {
            char reason[1024];
-           ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                          ADDRSPERSITE, reason,
-                                          AFSDIR_SERVER_NETINFO_FILEPATH,
-                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+           ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                         ADDRSPERSITE, reason,
+                                         AFSDIR_SERVER_NETINFO_FILEPATH,
+                                         AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        } else
        {
            ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
index ba24342ef787ded2b3743edec8d7382893ac9e3a..6107ff17c1a0d7c2aed65e76a4c3240decc41aaa 100644 (file)
@@ -18,7 +18,7 @@ BUDB=$(srcdir)/../budb
 
 RXOBJS= rx_pthread.o rxkad_errs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o \
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o \
      volparse.o flipbase64.o softsig.o hostparse.o pthread_glock.o
 
 
@@ -90,9 +90,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index ab54bff77282d506e37c225197a53a416b886a9c..38e54da4ad47bcae94df3a344c14ab61dc014dca 100644 (file)
@@ -18,7 +18,7 @@ PTSERVER=$(srcdir)/../ptserver
 
 RXOBJS= rx_pthread.o rxkad_errs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o \
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o \
      volparse.o flipbase64.o softsig.o hostparse.o pthread_glock.o \
      pthread_threadname.o
 
@@ -82,9 +82,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index e4df38ff0cd46d139a0774765a12cace40f3e833..199a9b0c28b94456b03393ed8fb4b67383636005 100644 (file)
@@ -34,7 +34,7 @@ DIROBJS=buffer.o dir.o salvage.o
 
 LWPOBJS=lock.o threadname.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o fstab.o
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o volparse.o flipbase64.o softsig.o fstab.o
 
 VLIBOBJS=volume.o vnode.o vutil.o partition.o fssync-client.o \
         clone.o nuke.o devname.o listinodes.o ihandle.o \
@@ -129,9 +129,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) -I../util $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 2e5b49a8f39e7fe2716c92f987764da57b54b48d..17b5421a5ccc247262cd8bc32db2239d2c1fbab4 100644 (file)
@@ -47,7 +47,6 @@ UTILOBJS =\
         $(OUT)\uuid.obj \
         $(OUT)\serverLog.obj \
         $(OUT)\fileutil.obj \
-        $(OUT)\netutils.obj \
         $(OUT)\dirpath.obj \
         $(OUT)\volparse.obj \
         $(OUT)\flipbase64.obj \
index ba7b202d3fee31cc58c8ff7b66e122f3d07e8e2e..8a2e639aaff472b32c738c764af09a234b5d313a 100644 (file)
@@ -26,7 +26,7 @@ INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h \
 
 RXOBJS = rx_pthread.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o \
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o \
        volparse.o flipbase64.o softsig.o hostparse.o pthread_glock.o \
        pthread_threadname.o
 
@@ -72,9 +72,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 6648b3f57ce0e8c6ed59553b6eb5d3c550827704..7a1fa5e9d1b07c0442206d48bc9b02c0cddbc551 100644 (file)
@@ -18,7 +18,7 @@ VLSERVER=$(srcdir)/../vlserver
 
 RXOBJS= rx_pthread.o rxkad_errs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o \
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o \
      volparse.o flipbase64.o softsig.o hostparse.o pthread_glock.o \
      pthread_threadname.o
 
@@ -75,9 +75,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 8a215390432b7eea291d44f67c08303b99ef132f..3f3e27a59a7a7e08848aa49a58ce379c144fbc54 100644 (file)
@@ -33,7 +33,7 @@ LWPOBJS=lock.o threadname.o
 
 LIBACLOBJS=aclprocs.o netprocs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o pthread_threadname.o
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o volparse.o flipbase64.o softsig.o pthread_threadname.o
 
 DIROBJS=buffer.o dir.o salvage.o
 
@@ -116,9 +116,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) -I../util $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 7f167d53b4a9ac0468e550efc2c5bfacddf1f14e..00bd23d996f00fcf64a8e56a061611b5bd6f8b2f 100644 (file)
@@ -18,7 +18,7 @@ INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h \
        ${TOP_INCDIR}/rx/rx.h ${TOP_INCDIR}/rx/xdr.h \
        ${TOP_INCDIR}/lock.h ubik.h ubik_int.h
 
-LIBS=${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a \
+LIBS=${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libauth.a \
        ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/libcmd.a \
        ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libafsutil.a \
        ${TOP_LIBDIR}/libopr.a ${XLIBS}
index 9fdcfc3ff306aba99f03e958f5e5531d9cdfe90e..2c1db5ecaa25e6cde3ff85a64b1997ba24a06e96 100644 (file)
@@ -20,7 +20,6 @@
 #include <afs/cellconfig.h>
 #ifndef AFS_NT40_ENV
 #include <afs/afsutil.h>
-#include <afs/netutils.h>
 #endif
 
 #define UBIK_INTERNALS
@@ -615,10 +614,10 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
         * host as returned by rx_getAllAddr (in NBO)
         */
        char reason[1024];
-       count =
-           parseNetFiles(myAddr, NULL, NULL, UBIK_MAX_INTERFACE_ADDR, reason,
-                         AFSDIR_SERVER_NETINFO_FILEPATH,
-                         AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+       count = afsconf_ParseNetFiles(myAddr, NULL, NULL,
+                                     UBIK_MAX_INTERFACE_ADDR, reason,
+                                     AFSDIR_SERVER_NETINFO_FILEPATH,
+                                     AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        if (count < 0) {
            ubik_print("ubik: Can't register any valid addresses:%s\n",
                       reason);
index 37d79b9b7781268cf5ce15ec3ab5420d266358ca..b4257c06ae900d1f09280e0601d92ab308fc4d86 100644 (file)
@@ -264,10 +264,10 @@ main(int argc, char *argv[])
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                           ADDRSPERSITE, reason,
-                                           AFSDIR_SERVER_NETINFO_FILEPATH,
-                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
index 69866a9447e5059ddff7779d666bd5061ed1d1f1..b31ac3b1fe59d21e625644ba946cfae0237dd7e5 100644 (file)
@@ -14,7 +14,7 @@ HELPER_SPLINT=@HELPER_SPLINT@
 
 objects =base64.o ktime.o volparse.o hostparse.o exec.o \
         hputil.o kreltime.o uuid.o serverLog.o \
-        dirpath.o fileutil.o netutils.o flipbase64.o fstab.o \
+        dirpath.o fileutil.o flipbase64.o fstab.o \
         afs_atomlist.o afs_lhash.o pthread_glock.o tabular_output.o \
         pthread_threadname.o ${REGEX_OBJ}
 
@@ -30,7 +30,6 @@ objects_pic = \
        serverLog_pic.o \
        dirpath_pic.o \
        fileutil_pic.o \
-       netutils_pic.o \
        flipbase64_pic.o \
        fstab_pic.o \
        afs_atomlist_pic.o \
@@ -47,7 +46,6 @@ includes = \
        ${TOP_INCDIR}/afs/vice.h \
        ${TOP_INCDIR}/afs/ktime.h \
        ${TOP_INCDIR}/afs/fileutil.h \
-       ${TOP_INCDIR}/afs/netutils.h \
        ${TOP_INCDIR}/afs/afsutil.h \
        ${TOP_INCDIR}/afs/afsutil_prototypes.h \
        ${TOP_INCDIR}/afs/pthread_glock.h \
@@ -89,9 +87,6 @@ ${TOP_INCDIR}/afs/ktime.h: ${srcdir}/ktime.h
 ${TOP_INCDIR}/afs/fileutil.h: ${srcdir}/fileutil.h
        ${INSTALL_DATA} $? $@
 
-${TOP_INCDIR}/afs/netutils.h: ${srcdir}/netutils.h
-       ${INSTALL_DATA} $? $@
-
 ${TOP_INCDIR}/afs/afsutil.h: ${srcdir}/afsutil.h
        ${INSTALL_DATA} $? $@
 
@@ -214,9 +209,6 @@ dirpath_pic.o: ${srcdir}/dirpath.c ${includes}
 fileutil_pic.o: ${srcdir}/fileutil.c ${includes}
        $(SHD_CCRULE) ${srcdir}/fileutil.c
 
-netutils_pic.o: ${srcdir}/netutils.c ${includes}
-       $(SHD_CCRULE) ${srcdir}/netutils.c
-
 flipbase64_pic.o: ${srcdir}/flipbase64.c ${includes}
        $(SHD_CCRULE) ${srcdir}/flipbase64.c
 
@@ -257,7 +249,6 @@ install: dirpath.h util.a util_pic.a sys
        ${INSTALL_DATA} ${srcdir}/vice.h ${DESTDIR}${includedir}/afs/vice.h
        ${INSTALL_DATA} ${srcdir}/ktime.h ${DESTDIR}${includedir}/afs/ktime.h
        ${INSTALL_DATA} ${srcdir}/fileutil.h ${DESTDIR}${includedir}/afs/fileutil.h
-       ${INSTALL_DATA} ${srcdir}/netutils.h ${DESTDIR}${includedir}/afs/netutils.h
        ${INSTALL_DATA} ${srcdir}/afsutil.h ${DESTDIR}${includedir}/afs/afsutil.h
        ${INSTALL_DATA} ${srcdir}/afsutil_prototypes.h ${DESTDIR}${includedir}/afs/afsutil_prototypes.h
        ${INSTALL_DATA} ${srcdir}/pthread_glock.h ${DESTDIR}${includedir}/afs/pthread_glock.h
@@ -284,7 +275,6 @@ dest: dirpath.h util.a util_pic.a sys
        ${INSTALL_DATA} ${srcdir}/vice.h ${DEST}/include/afs/vice.h
        ${INSTALL_DATA} ${srcdir}/ktime.h ${DEST}/include/afs/ktime.h
        ${INSTALL_DATA} ${srcdir}/fileutil.h ${DEST}/include/afs/fileutil.h
-       ${INSTALL_DATA} ${srcdir}/netutils.h ${DEST}/include/afs/netutils.h
        ${INSTALL_DATA} ${srcdir}/afsutil.h ${DEST}/include/afs/afsutil.h
        ${INSTALL_DATA} ${srcdir}/afsutil_prototypes.h ${DEST}/include/afs/afsutil_prototypes.h
        ${INSTALL_DATA} ${srcdir}/pthread_glock.h ${DEST}/include/afs/pthread_glock.h
@@ -318,5 +308,5 @@ check-splint:
        sh $(HELPER_SPLINT) $(CFLAGS) \
            base64.c ktime.c volparse.c hostparse.c \
            hputil.c kreltime.c uuid.c serverLog.c \
-           dirpath.c fileutil.c netutils.c flipbase64.c \
+           dirpath.c fileutil.c flipbase64.c \
            afs_atomlist.c afs_lhash.c fstab.c
index 6a31d47eebe3d5e994792afcf3f0ebedb9971cf4..8a908c605cee1726928d49745d531feffdd009ca 100644 (file)
@@ -17,7 +17,6 @@ INCFILES =\
        $(INCFILEDIR)\afsutil.h \
        $(INCFILEDIR)\errors.h \
        $(INCFILEDIR)\vice.h \
-        $(INCFILEDIR)\netutils.h \
        $(INCFILEDIR)\pthread_glock.h \
        $(INCFILEDIR)\pthread_nosigs.h \
        $(INCFILEDIR)\errmap_nt.h \
@@ -44,7 +43,6 @@ LIBOBJS = \
         $(OUT)\krb5_nt.obj \
        $(OUT)\kreltime.obj \
        $(OUT)\ktime.obj \
-        $(OUT)\netutils.obj \
        $(OUT)\regex.obj \
        $(OUT)\readdir_nt.obj \
        $(OUT)\serverLog.obj \
@@ -62,7 +60,6 @@ MT_LIBOBJS = \
         $(OUT)\krb5_nt.obj \
        $(OUT)\kreltime.obj \
        $(OUT)\ktime.obj \
-        $(OUT)\netutils.obj \
        $(OUT)\regex.obj \
        $(OUT)\readdir_nt.obj \
        $(OUT)\serverLog_mt.obj \
index 15136b16ef33ce0e5ebf7d450d6d68e2d1d486c9..b969ab224549a1fc24983602253ffce9ee3b5d2b 100644 (file)
@@ -102,23 +102,6 @@ extern afs_int32 ktime_DateToInt32(char *adate, afs_int32 * aint32);
 extern char *ktime_GetDateUsage(void);
 extern afs_int32 ktime_InterpretDate(struct ktime_date *akdate);
 
-/* netutils.c */
-extern afs_uint32 extract_Addr(char *line, int maxSize);
-extern int parseNetRestrictFile(afs_uint32 outAddrs[], afs_uint32 * mask,
-                               afs_uint32 * mtu, afs_uint32 maxAddrs,
-                               afs_uint32 * nAddrs, char reason[],
-                               const char *fileName);
-extern int ParseNetInfoFile(afs_uint32 * final, afs_uint32 * mask,
-                           afs_uint32 * mtu, int max, char reason[],
-                           const char *fileName);
-extern int filterAddrs(afs_uint32 addr1[], afs_uint32 addr2[],
-                      afs_uint32 mask1[], afs_uint32 mask2[],
-                      afs_uint32 mtu1[], afs_uint32 mtu2[], int n1, int n2);
-extern int parseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[],
-                        afs_uint32 mtubuf[], afs_uint32 max, char reason[],
-                        const char *niFileName, const char *nrFileName);
-
-
 /* pthread_glock.c */
 
 
diff --git a/src/util/netutils.c b/src/util/netutils.c
deleted file mode 100644 (file)
index 013cc82..0000000
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright 2000, International Business Machines Corporation and others.
- * All Rights Reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License.  For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- */
-
-/*
- * Network utility functions
- * Parsing NetRestrict file and filtering IP addresses
- */
-
-#include <afsconfig.h>
-#include <afs/param.h>
-
-#include <roken.h>
-#include <ctype.h>
-
-#include <rx/rx.h>
-#include <afs/dirpath.h>
-
-#include "afsutil.h"
-
-#define AFS_IPINVALID        0xffffffff        /* invalid IP address */
-#define AFS_IPINVALIDIGNORE  0xfffffffe        /* no input given to extractAddr */
-#define MAX_NETFILE_LINE       2048    /* length of a line in the netrestrict file */
-#define MAXIPADDRS             1024    /* from afsd.c */
-
-int ParseNetInfoFile_int(afs_uint32 *, afs_uint32 *, afs_uint32 *,
-                         int, char reason[], const char *,
-                         int);
-/*
- * The line parameter is a pointer to a buffer containing a string of
- * bytes of the form
-** w.x.y.z     # machineName
- * returns the network interface IP Address in NBO
- */
-afs_uint32
-extract_Addr(char *line, int maxSize)
-{
-    char bytes[4][32];
-    int i = 0, n = 0;
-    char *endPtr;
-    afs_uint32 val[4];
-    afs_uint32 retval = 0;
-
-    /* skip empty spaces */
-    while (isspace(*line) && maxSize) {
-       line++;
-       maxSize--;
-    }
-    /* skip empty lines */
-    if (!maxSize || !*line)
-       return AFS_IPINVALIDIGNORE;
-
-    for (n = 0; n < 4; n++) {
-       while ((*line != '.') && !isspace(*line) && maxSize) {  /* extract nth byte */
-           if (!isdigit(*line))
-               return AFS_IPINVALID;
-           if (i > 31)
-               return AFS_IPINVALID;   /* no space */
-           bytes[n][i++] = *line++;
-           maxSize--;
-       }                       /* while */
-       if (!maxSize)
-           return AFS_IPINVALID;
-       bytes[n][i] = 0;
-       i = 0, line++;
-       errno = 0;
-       val[n] = strtol(bytes[n], &endPtr, 10);
-       if ((val[n] == 0) && (errno != 0 || bytes[n] == endPtr))        /* no conversion */
-           return AFS_IPINVALID;
-    }                          /* for */
-
-    retval = (val[0] << 24) | (val[1] << 16) | (val[2] << 8) | val[3];
-    return htonl(retval);
-}
-
-
-
-
-/* parseNetRestrictFile()
- * Get a list of IP addresses for this host removing any address found
- * in the config file (fileName parameter): /usr/vice/etc/NetRestrict
- * for clients and /usr/afs/local/NetRestrict for servers.
- *
- * Returns the number of valid addresses in outAddrs[] and count in
- * nAddrs.  Returns 0 on success; or 1 if the config file was not
- * there or empty (we still return the host's IP addresses). Returns
- * -1 on fatal failure with reason in the reason argument (so the
- * 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_getAllAddrMaskMtu() and
- * parsed by extract_Addr().
- */
-/*
-  afs_uint32  outAddrs[];          * output address array *
-  afs_uint32  *mask, *mtu;         * optional mask and mtu *
-  afs_uint32 maxAddrs;            * max number of addresses *
-  afs_uint32 *nAddrs;              * number of Addresses in output array *
-  char       reason[];             * reason for failure *
-  const char *fileName;            * filename to parse *
-*/
-
-int
-parseNetRestrictFile_int(afs_uint32 outAddrs[], afs_uint32 * mask,
-                        afs_uint32 * mtu, afs_uint32 maxAddrs,
-                        afs_uint32 * nAddrs, char reason[],
-                        const char *fileName, const char *fileName_ni)
-{
-    FILE *fp;
-    char line[MAX_NETFILE_LINE];
-    int lineNo, usedfile = 0;
-    afs_uint32 i, neaddrs, nOutaddrs;
-    afs_uint32 addr, eAddrs[MAXIPADDRS], eMask[MAXIPADDRS], eMtu[MAXIPADDRS];
-
-    osi_Assert(outAddrs);
-    osi_Assert(reason);
-    osi_Assert(fileName);
-    osi_Assert(nAddrs);
-    if (mask)
-       osi_Assert(mtu);
-
-    /* Initialize */
-    *nAddrs = 0;
-    for (i = 0; i < maxAddrs; i++)
-       outAddrs[i] = 0;
-    strcpy(reason, "");
-
-    /* get all network interfaces from the kernel */
-    neaddrs = rx_getAllAddrMaskMtu(eAddrs, eMask, eMtu, MAXIPADDRS);
-    if (neaddrs <= 0) {
-       sprintf(reason, "No existing IP interfaces found");
-       return -1;
-    }
-    i = 0;
-    if ((neaddrs < MAXIPADDRS) && fileName_ni)
-       i = ParseNetInfoFile_int(&(eAddrs[neaddrs]), &(eMask[neaddrs]),
-                                &(eMtu[neaddrs]), MAXIPADDRS-neaddrs, reason,
-                                fileName_ni, 1);
-
-    if (i > 0)
-       neaddrs += i;
-
-    if ((fp = fopen(fileName, "r")) == 0) {
-       sprintf(reason, "Could not open file %s for reading:%s", fileName,
-               strerror(errno));
-       goto done;
-    }
-
-    /* For each line in the NetRestrict file */
-    lineNo = 0;
-    usedfile = 0;
-    while (fgets(line, MAX_NETFILE_LINE, fp) != NULL) {
-       lineNo++;               /* input line number */
-       addr = extract_Addr(line, strlen(line));
-       if (addr == AFS_IPINVALID) {    /* syntactically invalid */
-           fprintf(stderr, "%s : line %d : parse error - invalid IP\n",
-                   fileName, lineNo);
-           continue;
-       }
-       if (addr == AFS_IPINVALIDIGNORE) {      /* ignore error */
-           fprintf(stderr, "%s : line %d : invalid address ... ignoring\n",
-                   fileName, lineNo);
-           continue;
-       }
-       usedfile = 1;
-
-       /* Check if we need to exclude this address */
-       for (i = 0; i < neaddrs; i++) {
-           if (eAddrs[i] && (eAddrs[i] == addr)) {
-               eAddrs[i] = 0;  /* Yes - exclude it by zeroing it for now */
-           }
-       }
-    }                          /* while */
-
-    fclose(fp);
-
-    if (!usedfile) {
-       sprintf(reason, "No valid IP addresses in %s\n", fileName);
-       goto done;
-    }
-
-  done:
-    /* Collect the addresses we have left to return */
-    nOutaddrs = 0;
-    for (i = 0; i < neaddrs; i++) {
-       if (!eAddrs[i])
-           continue;
-       outAddrs[nOutaddrs] = eAddrs[i];
-       if (mask) {
-           mask[nOutaddrs] = eMask[i];
-           mtu[nOutaddrs] = eMtu[i];
-       }
-       if (++nOutaddrs >= maxAddrs)
-           break;
-    }
-    if (nOutaddrs == 0) {
-       sprintf(reason, "No addresses to use after parsing %s", fileName);
-       return -1;
-    }
-    *nAddrs = nOutaddrs;
-    return (usedfile ? 0 : 1); /* 0=>used the file.  1=>didn't use file */
-}
-
-int
-parseNetRestrictFile(afs_uint32 outAddrs[], afs_uint32 * mask,
-                        afs_uint32 * mtu, afs_uint32 maxAddrs,
-                        afs_uint32 * nAddrs, char reason[],
-                        const char *fileName)
-{
-    return parseNetRestrictFile_int(outAddrs, mask, mtu, maxAddrs, nAddrs, reason, fileName, NULL);
-}
-
-/*
- * this function reads in stuff from InterfaceAddr file in
- * /usr/vice/etc ( if it exists ) and verifies the addresses
- * specified.
- * 'final' contains all those addresses that are found to
- * be valid. This function returns the number of valid
- * interface addresses. Pulled out from afsd.c
- */
-int
-ParseNetInfoFile_int(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu,
-                    int max, char reason[], const char *fileName,
-                    int fakeonly)
-{
-
-    afs_uint32 existingAddr[MAXIPADDRS], existingMask[MAXIPADDRS],
-       existingMtu[MAXIPADDRS];
-    char line[MAX_NETFILE_LINE];
-    FILE *fp;
-    int i, existNu, count = 0;
-    afs_uint32 addr;
-    int lineNo = 0;
-    int l;
-
-    osi_Assert(fileName);
-    osi_Assert(final);
-    osi_Assert(mask);
-    osi_Assert(mtu);
-    osi_Assert(reason);
-
-    /* get all network interfaces from the kernel */
-    existNu =
-       rx_getAllAddrMaskMtu(existingAddr, existingMask, existingMtu,
-                             MAXIPADDRS);
-    if (existNu < 0)
-       return existNu;
-
-    if ((fp = fopen(fileName, "r")) == 0) {
-       /* If file does not exist or is not readable, then
-        * use all interface addresses.
-        */
-       sprintf(reason,
-               "Failed to open %s(%s)\nUsing all configured addresses\n",
-               fileName, strerror(errno));
-       for (i = 0; i < existNu; i++) {
-           final[i] = existingAddr[i];
-           mask[i] = existingMask[i];
-           mtu[i] = existingMtu[i];
-       }
-       return existNu;
-    }
-
-    /* For each line in the NetInfo file */
-    while (fgets(line, MAX_NETFILE_LINE, fp) != NULL) {
-       int fake = 0;
-
-       /* See if first char is an 'F' for fake */
-       /* Added to allow the fileserver to advertise fake IPS for use with
-        * the translation tables for NAT-like firewalls - defect 12462 */
-       for (fake = 0; ((fake < strlen(line)) && isspace(line[fake]));
-            fake++);
-       if ((fake < strlen(line))
-           && ((line[fake] == 'f') || (line[fake] == 'F'))) {
-           fake++;
-       } else {
-           fake = 0;
-       }
-
-       lineNo++;               /* input line number */
-       addr = extract_Addr(&line[fake], strlen(&line[fake]));
-
-       if (addr == AFS_IPINVALID) {    /* syntactically invalid */
-           fprintf(stderr, "afs:%s : line %d : parse error\n", fileName,
-                   lineNo);
-           continue;
-       }
-       if (addr == AFS_IPINVALIDIGNORE) {      /* ignore error */
-           continue;
-       }
-
-       /* See if it is an address that really exists */
-       for (i = 0; i < existNu; i++) {
-           if (existingAddr[i] == addr)
-               break;
-       }
-       if ((i >= existNu) && (!fake))
-           continue;           /* not found/fake - ignore */
-
-       /* Check if it is a duplicate address we alread have */
-       for (l = 0; l < count; l++) {
-           if (final[l] == addr)
-               break;
-       }
-       if (l < count) {
-           fprintf(stderr, "afs:%x specified twice in NetInfo file\n",
-                   ntohl(addr));
-           continue;           /* duplicate addr - ignore */
-       }
-
-       if (count > max) {      /* no more space */
-           fprintf(stderr,
-                   "afs:Too many interfaces. The current kernel configuration supports a maximum of %d interfaces\n",
-                   max);
-       } else if (fake) {
-           if (!fake)
-               fprintf(stderr, "Client (2) also has address %s\n", line);
-           final[count] = addr;
-           mask[count] = 0xffffffff;
-           mtu[count] = htonl(1500);
-           count++;
-       } else if (!fakeonly) {
-           final[count] = existingAddr[i];
-           mask[count] = existingMask[i];
-           mtu[count] = existingMtu[i];
-           count++;
-       }
-    }                          /* while */
-
-    /* in case of any error, we use all the interfaces present */
-    if (count <= 0) {
-       sprintf(reason,
-               "Error in reading/parsing Interface file\nUsing all configured interface addresses \n");
-       for (i = 0; i < existNu; i++) {
-           final[i] = existingAddr[i];
-           mask[i] = existingMask[i];
-           mtu[i] = existingMtu[i];
-       }
-       return existNu;
-    }
-    return count;
-}
-
-int
-ParseNetInfoFile(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu,
-                int max, char reason[], const char *fileName)
-{
-    return ParseNetInfoFile_int(final, mask, mtu, max, reason, fileName, 0);
-}
-
-/*
- * Given two arrays of addresses, masks and mtus find the common ones
- * and return them in the first buffer. Return number of common
- * entries.
- */
-int
-filterAddrs(afs_uint32 addr1[], afs_uint32 addr2[], afs_uint32 mask1[],
-           afs_uint32 mask2[], afs_uint32 mtu1[], afs_uint32 mtu2[], int n1,
-           int n2)
-{
-    afs_uint32 taddr[MAXIPADDRS];
-    afs_uint32 tmask[MAXIPADDRS];
-    afs_uint32 tmtu[MAXIPADDRS];
-    int count = 0, i = 0, j = 0, found = 0;
-
-    osi_Assert(addr1);
-    osi_Assert(addr2);
-    osi_Assert(mask1);
-    osi_Assert(mask2);
-    osi_Assert(mtu1);
-    osi_Assert(mtu2);
-
-    for (i = 0; i < n1; i++) {
-       found = 0;
-       for (j = 0; j < n2; j++) {
-           if (addr1[i] == addr2[j]) {
-               found = 1;
-               break;
-           }
-       }
-
-       /* Always mask loopback address */
-       if (found && rx_IsLoopbackAddr(addr1[i]))
-           found = 0;
-
-       if (found) {
-           taddr[count] = addr1[i];
-           tmask[count] = mask1[i];
-           tmtu[count] = mtu1[i];
-           count++;
-       }
-    }
-    /* copy everything into addr1, mask1 and mtu1 */
-    for (i = 0; i < count; i++) {
-       addr1[i] = taddr[i];
-       if (mask1) {
-           mask1[i] = tmask[i];
-           mtu1[i] = tmtu[i];
-       }
-    }
-    /* and zero out the rest */
-    for (i = count; i < n1; i++) {
-       addr1[i] = 0;
-       if (mask1) {
-           mask1[i] = 0;
-           mtu1[i] = 0;
-       }
-    }
-    return count;
-}
-
-/*
- * parse both netinfo and netrerstrict files and return the final
- * set of IP addresses to use
- */
-/* max - Entries in addrbuf, maskbuf and mtubuf */
-int
-parseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[], afs_uint32 mtubuf[],
-             afs_uint32 max, char reason[], const char *niFileName,
-             const char *nrFileName)
-{
-    afs_uint32 addrbuf1[MAXIPADDRS], maskbuf1[MAXIPADDRS],
-       mtubuf1[MAXIPADDRS];
-    afs_uint32 addrbuf2[MAXIPADDRS], maskbuf2[MAXIPADDRS],
-       mtubuf2[MAXIPADDRS];
-    int nAddrs1 = 0;
-    afs_uint32 nAddrs2 = 0;
-    int code, i;
-
-    nAddrs1 =
-       ParseNetInfoFile(addrbuf1, maskbuf1, mtubuf1, MAXIPADDRS, reason,
-                        niFileName);
-    code =
-       parseNetRestrictFile_int(addrbuf2, maskbuf2, mtubuf2, MAXIPADDRS,
-                            &nAddrs2, reason, nrFileName, niFileName);
-    if ((nAddrs1 < 0) && (code)) {
-       /* both failed */
-       return -1;
-    } else if ((nAddrs1 > 0) && (code)) {
-       /* netinfo succeeded and netrestrict failed */
-       for (i = 0; ((i < nAddrs1) && (i < max)); i++) {
-           addrbuf[i] = addrbuf1[i];
-           if (maskbuf) {
-               maskbuf[i] = maskbuf1[i];
-               mtubuf[i] = mtubuf1[i];
-           }
-       }
-       return i;
-    } else if ((!code) && (nAddrs1 < 0)) {
-       /* netrestrict succeeded and netinfo failed */
-       for (i = 0; ((i < nAddrs2) && (i < max)); i++) {
-           addrbuf[i] = addrbuf2[i];
-           if (maskbuf) {
-               maskbuf[i] = maskbuf2[i];
-               mtubuf[i] = mtubuf2[i];
-           }
-       }
-       return i;
-    } else if ((!code) && (nAddrs1 >= 0)) {
-       /* both succeeded */
-       /* take the intersection of addrbuf1 and addrbuf2 */
-       code =
-           filterAddrs(addrbuf1, addrbuf2, maskbuf1, maskbuf2, mtubuf1,
-                       mtubuf2, nAddrs1, nAddrs2);
-       for (i = 0; ((i < code) && (i < max)); i++) {
-           addrbuf[i] = addrbuf1[i];
-           if (maskbuf) {
-               maskbuf[i] = maskbuf1[i];
-               mtubuf[i] = mtubuf1[i];
-           }
-       }
-       return i;
-    }
-    return 0;
-}
diff --git a/src/util/netutils.h b/src/util/netutils.h
deleted file mode 100644 (file)
index 075edad..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright 2000, International Business Machines Corporation and others.
- * All Rights Reserved.
- *
- * This software has been released under the terms of the IBM Public
- * License.  For details, see the LICENSE file in the top-level source
- * directory or online at http://www.openafs.org/dl/license10.html
- */
-
-#ifndef OPENAFS_NETUTILS_H
-#define OPENAFS_NETUTILS_H
-
-#include "afsutil_prototypes.h"
-
-#endif /* OPENAFS_NETUTILS_H */
index f97c8cecfb894bd7d15310c92860e9f663a60425..43f70e404216bfeac97a377e8ea959da7a436646 100644 (file)
@@ -32,7 +32,7 @@ LWPOBJS=lock.o threadname.o
 
 LIBACLOBJS=aclprocs.o netprocs.o
 
-UTILOBJS=uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o pthread_threadname.o
+UTILOBJS=uuid.o serverLog.o fileutil.o dirpath.o volparse.o flipbase64.o softsig.o pthread_threadname.o
 
 DIROBJS=buffer.o dir.o salvage.o
 
@@ -94,9 +94,6 @@ volparse.o: ${UTIL}/volparse.c
 flipbase64.o: ${UTIL}/flipbase64.c
        $(AFS_CCRULE) $(UTIL)/flipbase64.c
 
-netutils.o: ${UTIL}/netutils.c
-       $(AFS_CCRULE) -I../util $(UTIL)/netutils.c
-
 dirpath.o: ${UTIL}/dirpath.c
        $(AFS_CCRULE) $(UTIL)/dirpath.c
 
index 35a7e266a30f7f24078d833dbb76e3add0da29ad..7dc5a75c848c736248c337b9fce1f00e75f400f8 100644 (file)
@@ -68,7 +68,6 @@
 #include <afs/partition.h>
 #include <afs/dir.h>
 #ifndef AFS_NT40_ENV
-# include <afs/netutils.h>
 # include <afs/softsig.h>
 #endif
 #include "viced_prototypes.h"
@@ -1725,10 +1724,12 @@ SetupVL(void)
         * /usr/afs/local/NetRestict)
         */
        char reason[1024];
-       afs_int32 code = parseNetFiles(FS_HostAddrs, NULL, NULL,
-                                      ADDRSPERSITE, reason,
-                                      AFSDIR_SERVER_NETINFO_FILEPATH,
-                                      AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+       afs_int32 code;
+
+       code = afsconf_ParseNetFiles(FS_HostAddrs, NULL, NULL,
+                                    ADDRSPERSITE, reason,
+                                    AFSDIR_SERVER_NETINFO_FILEPATH,
+                                    AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        if (code < 0) {
            ViceLog(0, ("Can't register any valid addresses: %s\n", reason));
            exit(1);
index 5b1c370e6b1323f0a8e1d4fd30a1b521ce85bc72..805020d9ad4627d57f33119fcbe98b011ba9bb89 100644 (file)
@@ -393,10 +393,10 @@ main(int argc, char **argv)
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                 ADDRSPERSITE, reason,
-                                 AFSDIR_SERVER_NETINFO_FILEPATH,
-                                 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                         ADDRSPERSITE, reason,
+                                         AFSDIR_SERVER_NETINFO_FILEPATH,
+                                         AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
 #endif
        {
index 458dfd6a665182863cb68af9737013d87077dd9e..7f5eefffe9f0183d557b3b481f5209548efa5bbc 100644 (file)
@@ -446,10 +446,10 @@ main(int argc, char **argv)
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
-            ccode = parseNetFiles(SHostAddrs, NULL, NULL,
-                                           ADDRSPERSITE, reason,
-                                           AFSDIR_SERVER_NETINFO_FILEPATH,
-                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);