/*
* 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
#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
+#include <roken.h>
+#include <afs/opr.h>
#include <afs/pthread_glock.h>
#include <afs/afsutil.h>
-#include <sys/types.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <fcntl.h>
-#include <io.h>
-#else
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include <rx/rxkad.h>
+
#include "cellconfig.h"
#include "keys.h"
*/
static int
-VerifyEntries(register struct afsconf_cell *aci)
+VerifyEntries(struct afsconf_cell *aci)
{
- register int i;
- register struct hostent *th;
+ int i;
+ struct hostent *th;
for (i = 0; i < aci->numServers; i++) {
if (aci->hostAddr[i].sin_addr.s_addr == 0) {
/* no address spec'd */
if (*(aci->hostName[i]) != 0) {
- th = gethostbyname(aci->hostName[i]);
- if (!th) {
+ int code;
+ struct addrinfo hints;
+ struct addrinfo *result;
+ struct addrinfo *rp;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_DGRAM;
+
+ code = getaddrinfo(aci->hostName[i], NULL, &hints, &result);
+ if (code) {
printf("Host %s not found in host database...\n",
aci->hostName[i]);
return AFSCONF_FAILURE;
}
- memcpy(&aci->hostAddr[i].sin_addr, th->h_addr,
- sizeof(afs_int32));
+ for (rp = result; rp != NULL; rp = rp->ai_next) {
+ struct sockaddr_in *sa = (struct sockaddr_in *)rp->ai_addr;
+ if (!rx_IsLoopbackAddr(ntohl(sa->sin_addr.s_addr))) {
+ aci->hostAddr[i].sin_addr.s_addr = sa->sin_addr.s_addr;
+ break;
+ }
+ }
+ freeaddrinfo(result);
+ if (aci->hostAddr[i].sin_addr.s_addr == 0) {
+ printf("No non-loopback addresses found for host %s\n",
+ aci->hostName[i]);
+ return AFSCONF_FAILURE;
+ }
}
/* otherwise we're deleting this entry */
} else {
if (!th) {
strcpy(aci->hostName[i], "UNKNOWNHOST");
} else {
- strcpy(aci->hostName[i], th->h_name);
+ if (strlcpy(aci->hostName[i],
+ th->h_name,
+ sizeof(aci->hostName[i]))
+ >= sizeof(aci->hostName[i])) {
+ strcpy(aci->hostName[i], "UNKNOWNHOST");
+ }
}
}
}
*/
int
-afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
+afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
struct afsconf_cell *acellInfo)
{
afs_int32 code;
}
int
-afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
- const char *apath,
+afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
+ const char *apath,
struct afsconf_cell *acellInfo, char clones[])
{
- register afs_int32 code;
- register int fd;
+ afs_int32 code;
+ int fd;
char tbuffer[1024];
- register FILE *tf;
- register afs_int32 i;
+ FILE *tf;
+ afs_int32 i;
LOCK_GLOBAL_MUTEX;
/* write ThisCell file */
- strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL);
+ strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, (char *)NULL);
fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
}
/* write CellServDB */
- strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, NULL);
+ strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, (char *)NULL);
tf = fopen(tbuffer, "w");
if (!tf) {
UNLOCK_GLOBAL_MUTEX;