#ifdef KERBEROS /* * $Source$ * $Header$ */ #ifndef lint static char rcsid_kstuff_c[] = "$Header$"; #endif lint #include "zserver.h" #include #include char *index(); /* * GetKerberosData * * get ticket from file descriptor and decode it. * Return KFAILURE if we barf on reading the ticket, else return * the value of rd_ap_req() applied to the ticket. */ int GetKerberosData(fd, haddr, kdata, service, srvtab) int fd; /* file descr. to read from */ struct in_addr haddr; /* address of foreign host on fd */ AUTH_DAT *kdata; /* kerberos data (returned) */ char *service; /* service principal desired */ char *srvtab; /* file to get keys from */ { char p[20]; KTEXT_ST ticket; /* will get Kerberos ticket from client */ int i; char instance[INST_SZ]; /* * Get the Kerberos ticket. The first few characters, terminated * by a blank, should give us a length; then get than many chars * which will be the ticket proper. */ for (i=0; i<20; i++) { if (read(fd, &p[i], 1) != 1) { syslog(LOG_WARNING,"bad read tkt len"); return(KFAILURE); } if (p[i] == ' ') { p[i] = '\0'; break; } } ticket.length = atoi(p); if ((i==20) || (ticket.length<=0) || (ticket.length>MAX_KTXT_LEN)) { syslog(LOG_WARNING,"bad tkt len %d",ticket.length); return(KFAILURE); } for (i=0; ilength); if ((written = write(fd, p, strlen(p))) != strlen(p)) if (written < 0) return(written); else return(ZSRV_PKSHORT); if ((written = write(fd, (caddr_t) (ticket->dat), ticket->length)) != ticket->length) if (written < 0) return(written); else return(ZSRV_PKSHORT); return(rem); } static char tkt_file[] = ZEPHYR_TKFILE; /* Hack to replace the kerberos library's idea of the ticket file with our idea */ char * tkt_string() { return(tkt_file); } #endif KERBEROS