]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
5 | ||
6 | #ifndef lint | |
7 | static char *rcsid_ticket_c = "$Header$"; | |
8 | #endif lint | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <krb.h> | |
12 | #include <sys/types.h> | |
13 | #include <sys/stat.h> | |
14 | #include <strings.h> | |
15 | #include "sms_update_int.h" | |
16 | #include "com_err.h" | |
17 | #include "kludge.h" | |
18 | ||
19 | /* too bad we can't set the pathname easily */ | |
20 | /*static char tkt_pathname[] = "/tmp/tkt:sms";*/ | |
21 | static char *srvtab = SRVTAB; /* default == /etc/srvtab */ | |
22 | static char realm[REALM_SZ]; | |
23 | static char sms[] = "sms"; | |
24 | ||
25 | extern char *tkt_string(), *PrincipalHostname(); | |
26 | static int initialized = 0; | |
27 | ||
28 | #define init() { if (!initialized) { get_krbrlm(realm,0); initialized=1; }} | |
29 | ||
30 | int | |
31 | get_sms_update_ticket(host, ticket) | |
32 | char *host; | |
33 | KTEXT ticket; | |
34 | { | |
35 | register int code; | |
36 | register int pass; | |
37 | char phost[BUFSIZ]; | |
38 | ||
39 | pass = 1; | |
40 | init(); | |
41 | strcpy(phost, PrincipalHostname(host)); | |
42 | try_it: | |
43 | code = mk_ap_req(ticket, sms, phost, realm, (long)0); | |
44 | if (pass == 1) { | |
45 | /* maybe we're taking too long? */ | |
46 | if ((code = get_sms_tgt()) != 0) { | |
47 | /* don't need phost buffer any more */ | |
48 | sprintf(phost, "%s: can't get Kerberos TGT", | |
49 | error_message(code)); | |
50 | sms_log_error(phost); | |
51 | return(code); | |
52 | } | |
53 | pass++; | |
54 | goto try_it; | |
55 | } | |
56 | return(krb_err_frob(code)); | |
57 | } | |
58 | ||
59 | int | |
60 | get_sms_tgt() | |
61 | { | |
62 | register int code; | |
63 | init(); | |
64 | code = get_svc_in_tkt(sms, "", realm, "krbtgt", realm, 1, srvtab); | |
65 | if (!code) | |
66 | return(0); | |
67 | else | |
68 | return(krb_err_frob(code)); | |
69 | } |