idlist lid;
namelist lnames;
- init_afs();
+ if (init_afs()) return NSS_STATUS_UNAVAIL;
if (uid==AFS_MAGIC_ANONYMOUS_USERID) {
if (!cpstr("anonymous", buffer, buflen)) return NSS_STATUS_UNAVAIL;
lnames.namelist_len = 0;
if (ubik_Call(PR_IDToName,pruclient,0,&lid,&lnames) != PRSUCCESS) {
- perror("ubik_Call() in ptsid2name() failed");
+ perror("ubik_Call() in ptsid2name() failed\n");
pthread_mutex_unlock(&mutex);
return NSS_STATUS_UNAVAIL;
}
namelist lnames;
char uname[MAXUSERNAMELEN];
- init_afs();
+ if (init_afs()) return NSS_STATUS_UNAVAIL;
if (!strcmp(name,"anonymous")) {
*uid = AFS_MAGIC_ANONYMOUS_USERID;
lid.idlist_val = 0;
lid.idlist_len = 0;
- lnames.namelist_val = (prname*)(&uname);
+ lnames.namelist_val = (prname*)uname;
// apparently ubik expects to be able to modify this?
strncpy(uname, name, MAXUSERNAMELEN);
lnames.namelist_len = 1;
if (ubik_Call(PR_NameToID,pruclient,0,&lnames,&lid) != PRSUCCESS) {
- perror("ubik_Call() in ptsname2id() failed");
+ perror("ubik_Call() in ptsname2id() failed\n");
pthread_mutex_unlock(&mutex);
return NSS_STATUS_UNAVAIL;
}
int len;
struct stat statbuf;
+ char buf[6];
+ int fd;
+ int pos;
+
if (afs_initialized) {
/* wait until /afs/@cell/ appears as a proxy for "the network is up" */
if (stat(cell_root, &statbuf)) return -1;
return 0;
}
+
+ // check to make sure that we are running inside nscd
+ pos = 0;
+ fd = open("/proc/self/cmdline", O_RDONLY);
+ if (fd==-1) return -1;
+ while(1) {
+ int numread;
+ numread = read(fd, buf+pos, 1);
+ if (buf[ (pos+5)%6 ] == 'd' &&
+ buf[ (pos+4)%6 ] == 'c' &&
+ buf[ (pos+3)%6 ] == 's' &&
+ buf[ (pos+2)%6 ] == 'n' &&
+ (buf[(pos+1)%6 ] == '/' || pos==4) &&
+ (buf[(pos+0)%6 ] == 0 || numread==-1)
+ )
+ break;
+ pos = (pos+1)%6;
+ if (numread==0) { close(fd); return -1; }
+ }
+ close(fd);
if (pthread_mutex_lock(&mutex)) return -1;
do {
len = snprintf(cellname, MAXCELLNAMELEN,
"%s/ThisCell", AFSDIR_CLIENT_ETC_DIRPATH);
- if (len < 0 || len >= MAXCELLNAMELEN) break;
+ if (len < 0 || len >= MAXCELLNAMELEN) return -1;
thiscell=fopen(cellname,"r");
if (thiscell == NULL) break;
rx_SetRxDeadTime(5);
if (pr_Initialize(0L,AFSDIR_CLIENT_ETC_DIRPATH, 0)) {
- perror("pr_Initialize() failed");
+ perror("pr_Initialize() failed\n");
break;
}