From: Derrick Brashear Date: Wed, 17 Apr 2002 23:29:04 +0000 (+0000) Subject: ubik-allow-netinfo-netrestrict-to-mask-address-pointed-to-by-hostname-20020417 X-Git-Tag: openafs-devel_1_3_3~154 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7158ef3ae57a97c4b7bb03527cb162ba968a2b35;p=packages%2Fo%2Fopenafs.git ubik-allow-netinfo-netrestrict-to-mask-address-pointed-to-by-hostname-20020417 if you really want to mask the IP address from gethostbyname(gethostname()) there's not really any reason to stand in your way --- diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c index 7abd78325..598f5d390 100644 --- a/src/ubik/beacon.c +++ b/src/ubik/beacon.c @@ -455,7 +455,8 @@ static verifyInterfaceAddress(ame, info, aservers) afs_uint32 aservers[]; /* list of all possible server addresses */ { afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr; - int count, found, i, j, totalServers, start, end; + afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR]; + int count, found, i, j, totalServers, start, end, usednetfiles = 0; if (info) totalServers = info->numServers; @@ -484,6 +485,7 @@ static verifyInterfaceAddress(ame, info, aservers) ubik_print("Aborting..\n"); return UBADHOST; } + usednetfiles++; } else { /* get all my interface addresses in net byte order */ @@ -511,7 +513,32 @@ static verifyInterfaceAddress(ame, info, aservers) { ubik_print("ubik: primary address %s does not exist\n", afs_inet_ntoa(*ame)); - return UBADHOST; + /* if we had the result of rx_getAllAddr already, avoid subverting + the "is gethostbyname(gethostname()) us" check. If we're + using NetInfo/NetRestrict, we assume they have enough clue + to avoid that big hole in their foot from the loaded gun. */ + if (usednetfiles) { + /* take the address we did get, then see if ame was masked */ + *ame=myAddr[0]; + count = rx_getAllAddr(myAddr2, UBIK_MAX_INTERFACE_ADDR); + if ( count <= 0 ) /* no address found */ + { + ubik_print("ubik: No network addresses found, aborting.."); + return UBADHOST; + } + + /* verify that the My-address passed in by ubik is correct */ + for ( j=0, found = 0; j < count; j++) + { + if ( *ame == myAddr2[j] ) /* both in net byte order */ + { + found = 1; + break; + } + } + } + if ( !found ) + return UBADHOST; } /* if any of my addresses are there in serverList, then