|
|
1.1 root 1: /*
2: * $Source: /usr/src/kerberosIV/krb/RCS/get_cred.c,v $
3: * $Author: kfall $
4: *
5: * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
6: * of Technology.
7: *
8: * For copying and distribution information, please see the file
9: * <mit-copyright.h>.
10: */
11:
12: #ifndef lint
13: static char *rcsid_get_cred_c =
14: "$Header: /usr/src/kerberosIV/krb/RCS/get_cred.c,v 4.11 90/06/25 20:55:51 kfall Exp $";
15: #endif /* lint */
16:
17: #include <mit-copyright.h>
18: #include <stdio.h>
19: #include <des.h>
20: #include <krb.h>
21:
22: /*
23: * krb_get_cred takes a service name, instance, and realm, and a
24: * structure of type CREDENTIALS to be filled in with ticket
25: * information. It then searches the ticket file for the appropriate
26: * ticket and fills in the structure with the corresponding
27: * information from the file. If successful, it returns KSUCCESS.
28: * On failure it returns a Kerberos error code.
29: */
30:
31: krb_get_cred(service,instance,realm,c)
32: char *service; /* Service name */
33: char *instance; /* Instance */
34: char *realm; /* Auth domain */
35: CREDENTIALS *c; /* Credentials struct */
36: {
37: int tf_status; /* return value of tf function calls */
38:
39: /* Open ticket file and lock it for shared reading */
40: if ((tf_status = tf_init(TKT_FILE, R_TKT_FIL)) != KSUCCESS)
41: return(tf_status);
42:
43: /* Copy principal's name and instance into the CREDENTIALS struc c */
44:
45: if ( (tf_status = tf_get_pname(c->pname)) != KSUCCESS ||
46: (tf_status = tf_get_pinst(c->pinst)) != KSUCCESS )
47: return (tf_status);
48:
49: /* Search for requested service credentials and copy into c */
50:
51: while ((tf_status = tf_get_cred(c)) == KSUCCESS) {
52: /* Is this the right ticket? */
53: if ((strcmp(c->service,service) == 0) &&
54: (strcmp(c->instance,instance) == 0) &&
55: (strcmp(c->realm,realm) == 0))
56: break;
57: }
58: (void) tf_close();
59:
60: if (tf_status == EOF)
61: return (GC_NOTKT);
62: return(tf_status);
63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.