#include <sys/utime.h>
#include <io.h>
#include <WINNT/afssw.h>
+#ifdef AFS_AFSDB_ENV
+#include <cm_dns.h>
+#endif /* AFS_AFSDB_ENV */
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <resolv.h>
#endif /* AFS_AFSDB_ENV */
#endif /* AFS_NT40_ENV */
+#include <afs/afsint.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#endif /* UKERNEL */
#include <afs/afsutil.h>
#include "cellconfig.h"
static afsconf_Reopen();
static struct afsconf_servPair serviceTable [] = {
- "afs", 7000,
- "afscb", 7001,
- "afsprot", 7002,
- "afsvldb", 7003,
- "afskauth", 7004,
- "afsvol", 7005,
- "afserror", 7006,
- "afsnanny", 7007,
- "afsupdate",7008,
- "afsrmtsys",7009,
- "afsres", 7010, /* residency database for MR-AFS */
- "afsremio", 7011, /* remote I/O interface for MR-AFS */
- 0, 0 /* insert new services before this spot */
+ { "afs", 7000, },
+ { "afscb", 7001, },
+ { "afsprot", 7002, },
+ { "afsvldb", 7003, },
+ { "afskauth", 7004, },
+ { "afsvol", 7005, },
+ { "afserror", 7006, },
+ { "afsnanny", 7007, },
+ { "afsupdate", 7008, },
+ { "afsrmtsys", 7009, },
+ { "afsres", 7010, }, /* residency database for MR-AFS */
+ { "afsremio", 7011, }, /* remote I/O interface for MR-AFS */
+ { 0, 0 } /* insert new services before this spot */
};
/*
register int tc;
tp = abuffer;
- while (tc = *tp) {
+ while ((tc = *tp)) {
if (!isspace(tc)) break;
tp++;
}
static afsconf_Touch(adir)
register struct afsconf_dir *adir; {
char tbuffer[256];
+#ifndef AFS_NT40_ENV
struct timeval tvp[2];
+#endif
+
+ adir->timeRead = 0; /* just in case */
#ifdef AFS_NT40_ENV
/* NT client CellServDB has different file name than NT server or Unix */
+
if (IsClientConfigDirectory(adir->name)) {
strcompose(tbuffer, 256,
adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL);
strcompose(tbuffer, 256,
adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL);
}
-#else
- strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL);
-#endif /* AFS_NT40_ENV */
- adir->timeRead = 0; /* just in case */
-#ifdef AFS_NT40_ENV
return _utime(tbuffer, NULL);
+
#else
+ strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL);
gettimeofday(&tvp[0], NULL);
tvp[1] = tvp[0];
return utimes(tbuffer, tvp);
LOCK_GLOBAL_MUTEX
/* zero structure and fill in name; rest is done by internal routine */
tdir = (struct afsconf_dir *) malloc(sizeof(struct afsconf_dir));
- bzero(tdir, sizeof(struct afsconf_dir));
+ memset(tdir, 0, sizeof(struct afsconf_dir));
tdir->name = (char *) malloc(strlen(adir)+1);
strcpy(tdir->name, adir);
/* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs/<cell>/common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */
char *home_dir;
FILE *fp;
- int len;
+ size_t len;
if (!(home_dir = getenv("HOME"))) {
/* Our last chance is the "/.AFSCONF" file */
#else
i = GetCellUnix(adir);
#endif
+
+#ifndef AFS_FREELANCE_CLIENT /* no local cell not fatal in freelance */
if (i) {
return i;
}
+#endif
/* now parse the individual lines */
curEntry = 0;
curEntry = 0;
}
curEntry = (struct afsconf_entry *) malloc(sizeof(struct afsconf_entry));
- bzero(curEntry, sizeof(struct afsconf_entry));
+ memset(curEntry, 0, sizeof(struct afsconf_entry));
code = ParseCellLine(tbuffer, curEntry->cellInfo.name, linkedcell);
if (code) {
afsconf_CloseInternal(adir);
}
#ifdef AFS_AFSDB_ENV
+#if !defined(AFS_NT40_ENV)
afsconf_GetAfsdbInfo(acellName, aservice, acellInfo)
char *acellName;
char *aservice;
struct afsconf_cell *acellInfo;
{
afs_int32 code;
- int tservice, len, i;
+ int tservice, i;
+ size_t len;
unsigned char answer[1024];
unsigned char *p;
+ char realCellName[256];
char host[256];
int server_num = 0;
int minttl = 0;
code = dn_expand(answer, answer + len, p, host, sizeof(host));
if (code < 0)
return AFSCONF_NOTFOUND;
- strncpy(acellInfo->name, host, sizeof(acellInfo->name));
p += code + QFIXEDSZ; /* Skip name */
short afsdb_type;
afsdb_type = (p[0] << 8) | p[1];
+ if (afsdb_type == 1) {
+ /*
+ * We know this is an AFSDB record for our cell, of the
+ * right AFSDB type. Write down the true cell name that
+ * the resolver gave us above.
+ */
+ strcpy(realCellName, host);
+ }
+
code = dn_expand(answer, answer+len, p+2, host, sizeof(host));
if (code < 0)
return AFSCONF_NOTFOUND;
if (server_num == 0) /* No AFSDB records */
return AFSCONF_NOTFOUND;
+ strncpy(acellInfo->name, realCellName, sizeof(acellInfo->name));
acellInfo->numServers = server_num;
if (aservice) {
return 0;
}
+#else /* windows */
+int afsconf_GetAfsdbInfo(acellName, aservice, acellInfo)
+ char *aservice;
+ char *acellName;
+ struct afsconf_cell *acellInfo;
+{
+ register afs_int32 i;
+ int tservice;
+ struct afsconf_entry DNSce;
+ char *DNStmpStrp; /* a temp string pointer */
+ struct hostent *thp;
+ afs_int32 cellHosts[AFSMAXCELLHOSTS];
+ int numServers;
+ int rc;
+ int *ttl;
+
+ DNSce.cellInfo.numServers=0;
+ DNSce.next = NULL;
+ rc = getAFSServer(acellName, cellHosts, &numServers, &ttl);
+ /* ignore the ttl here since this code is only called by transitory programs
+ like klog, etc. */
+ if (rc < 0)
+ return -1;
+ if (numServers == 0)
+ return -1;
+
+ for (i = 0; i < numServers; i++)
+ {
+ memcpy(&acellInfo->hostAddr[i].sin_addr.s_addr, &cellHosts[i], sizeof(long));
+ acellInfo->hostAddr[i].sin_family = AF_INET;
+
+ /* sin_port supplied by connection code */
+ }
+
+ acellInfo->numServers = numServers;
+ strcpy(acellInfo->name, acellName);
+ if (aservice) {
+ LOCK_GLOBAL_MUTEX
+ tservice = afsconf_FindService(aservice);
+ UNLOCK_GLOBAL_MUTEX
+ if (tservice < 0) {
+ return AFSCONF_NOTFOUND; /* service not found */
+ }
+ for(i=0; i< acellInfo->numServers; i++) {
+ acellInfo->hostAddr[i].sin_port = tservice;
+ }
+ }
+ acellInfo->linkedCell = NULL; /* no linked cell */
+ acellInfo->flags = 0;
+ return 0;
+}
+#endif /* windows */
#endif /* AFS_AFSDB_ENV */
afsconf_GetCellInfo(adir, acellName, aservice, acellInfo)
register afs_int32 i;
int tservice;
char *tcell;
- int cnLen, ambig;
+ size_t cnLen;
+ int ambig;
char tbuffer[64];
LOCK_GLOBAL_MUTEX
if (adir->keystr) free(adir->keystr);
/* reinit */
- bzero(adir, sizeof(struct afsconf_dir));
+ memset(adir, 0, sizeof(struct afsconf_dir));
adir->name = tname; /* restore it */
return 0;
}
code = afsconf_Check(adir);
if (code)
return AFSCONF_FAILURE;
- bcopy(adir->keystr, astr, sizeof(struct afsconf_keys));
+ memcpy(astr, adir->keystr, sizeof(struct afsconf_keys));
UNLOCK_GLOBAL_MUTEX
return 0;
}
}
}
if (bestk) { /* found any */
- if (akey) bcopy(bestk->key, akey, 8); /* copy out latest key */
+ if (akey) memcpy(akey, bestk->key, 8); /* copy out latest key */
if (avno) *avno = bestk->kvno; /* and kvno to caller */
UNLOCK_GLOBAL_MUTEX
return 0;
for(tk = adir->keystr->key,i=0;i<maxa;i++,tk++) {
if (tk->kvno == avno) {
- bcopy(tk->key, akey, 8);
+ memcpy(akey, tk->key, 8);
UNLOCK_GLOBAL_MUTEX
return 0;
}
register afs_int32 i;
char tbuffer[256];
- bcopy(adir->keystr, &tkeys, sizeof(struct afsconf_keys));
+ memcpy(&tkeys, adir->keystr, sizeof(struct afsconf_keys));
/* convert it to net byte order */
for(i = 0; i<tkeys.nkeys; i++ )
tkey = &tk->key[tk->nkeys++];
}
tkey->kvno = akvno;
- bcopy(akey, tkey->key, 8);
+ memcpy(tkey->key, akey, 8);
i = SaveKeys(adir);
afsconf_Touch(adir);
UNLOCK_GLOBAL_MUTEX
/* otherwise slide the others down. i and tkey point at the guy to delete */
for(;i<tk->nkeys-1; i++,tkey++) {
tkey->kvno = (tkey+1)->kvno;
- bcopy((tkey+1)->key, tkey->key, 8);
+ memcpy(tkey->key, (tkey+1)->key, 8);
}
tk->nkeys--;
i = SaveKeys(adir);