X-Git-Url: http://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fvenus%2Fafsio.c;h=e795e6bb0da658cf623cc2f2df7e6a8769e1eed1;hp=8d2cd8f785124521fd1472738641790e3c3504a9;hb=d008089a79ef268bbca91d660a840f32cb416865;hpb=b9eaf43bbe31ac20604e79b0fd4e35aa029a06bd diff --git a/src/venus/afsio.c b/src/venus/afsio.c index 8d2cd8f..e795e6b 100644 --- a/src/venus/afsio.c +++ b/src/venus/afsio.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -99,7 +100,6 @@ #include #include #include "../rxkad/md5.h" -#define MAXHOSTS 13 #ifdef O_LARGEFILE #define afs_stat stat64 #define afs_fstat fstat64 @@ -159,7 +159,7 @@ struct connectionLookup { struct cellLookup { struct cellLookup *next; struct afsconf_cell info; - struct rx_securityClass *sc[3]; + struct rx_securityClass *sc; afs_int32 scIndex; }; @@ -274,7 +274,7 @@ main (int argc, char **argv) AFS_UNUSED afs_int32 -HandleLocalAuth(struct rx_securityClass **sc[3], afs_int32 *scIndex) +HandleLocalAuth(struct rx_securityClass **sc, afs_int32 *scIndex) { static struct afsconf_dir *tdir = NULL; struct ktc_principal sname; @@ -285,45 +285,20 @@ HandleLocalAuth(struct rx_securityClass **sc[3], afs_int32 *scIndex) char *cell; afs_int32 code; + *sc = NULL; + *scIndex = 0; + tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { fprintf(stderr,"Could not open configuration directory: %s.\n", AFSDIR_SERVER_ETC_DIRPATH); return -1; } - cell = tdir->cellName; - strcpy(sname.cell, cell); - sname.instance[0] = 0; - strcpy(sname.name, "afs"); - code=afsconf_GetLatestKey(tdir, &kvno, &key); + code = afsconf_ClientAuth(tdir, sc, &scIndex); if (code) { - fprintf(stderr,"afsconf_GetLatestKey returned %d\n", code); + fprintf(stderr,"afsconf_ClientAuth returned %d\n", code); return -1; } - ttoken.kvno = kvno; - des_init_random_number_generator(ktc_to_cblock(&key)); - code = des_random_key(ktc_to_cblock(&ttoken.sessionKey)); - if (code) { - fprintf(stderr,"des_random_key returned %d\n", code); - return -1; - } - ttoken.ticketLen = MAXKTCTICKETLEN; - code = tkt_MakeTicket(ttoken.ticket, &ttoken.ticketLen, &key, - AUTH_SUPERUSER, "", sname.cell, - 0, 0xffffffff, - &ttoken.sessionKey, host, - sname.name, sname.instance); - if (code) - *scIndex = 0; - else { - *scIndex = 2; - *sc[2] = (struct rx_securityClass *) - rxkad_NewClientSecurityObject(rxkad_clear, - &ttoken.sessionKey, ttoken.kvno, - ttoken.ticketLen, ttoken.ticket); - } - if (*scIndex == 0) - *sc[0] = (struct rx_securityClass *) rxnull_NewClientSecurityObject(); return 0; } @@ -798,7 +773,7 @@ get_vnode_hosts(char *fname, char **cellp, afs_int32 *hosts, AFSFid *Fid, i++; } } - for (; iparms[6].items) { @@ -993,7 +968,7 @@ readFile(struct cmd_syndesc *as, void *unused) } first = 0; RXConn = FindRXConnection(useHost, htons(AFSCONF_FILEPORT), 1, - cl->sc[cl->scIndex], cl->scIndex); + cl->sc, cl->scIndex); if (!RXConn) { fprintf(stderr,"rx_NewConnection failed to server 0x%X\n", useHost); @@ -1130,7 +1105,7 @@ writeFile(struct cmd_syndesc *as, void *unused) char *fname = NULL; char *cell = 0; afs_int32 code, localcode = 0; - afs_int32 hosts[MAXHOSTS]; + afs_int32 hosts[AFS_MAXHOSTS]; afs_uint32 useHost; AFSFid Fid; int i; @@ -1205,7 +1180,7 @@ writeFile(struct cmd_syndesc *as, void *unused) gettimeofday (&starttime, &Timezone); useHost = hosts[0]; RXConn = FindRXConnection(useHost, htons(AFSCONF_FILEPORT), 1, - cl->sc[cl->scIndex], cl->scIndex); + cl->sc, cl->scIndex); if (!RXConn) { fprintf(stderr,"rx_NewConnection failed to server 0x%X\n", hosts[0]); @@ -1452,29 +1427,11 @@ FindCell(char *cellName) if (code = VLDBInit(1, &p->info)) fprintf(stderr,"VLDBInit failed for cell %s\n", p->info.name); #endif - strcpy((char *)&sname.cell, (char *)&p->info.name); - sname.instance[0] = 0; - strcpy(sname.name, "afs"); - code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL); - if (code) - p->scIndex = 0; - else { - if ((ttoken.kvno >= 0) && (ttoken.kvno <= 255)) - /* this is a kerberos ticket, set scIndex accordingly */ - p->scIndex = 2; - else { - fprintf(stderr,"funny kvno (%d) in ticket, proceeding\n", - ttoken.kvno); - p->scIndex = 2; - } - p->sc[2] = (struct rx_securityClass *) - rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey, - ttoken.kvno, ttoken.ticketLen, - ttoken.ticket); - } - if (p->scIndex == 0) - p->sc[0] = (struct rx_securityClass *) - rxnull_NewClientSecurityObject(); + code = afsconf_ClientAuthToken(&p->info, 0, &p->sc, &p->scIndex); + if (code) { + p->scIndex = 0; + p->sc = rxnull_NewClientSecurityObject(); + } } if (p)