]>
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> | |
5c87ce34 | 15 | #include <update.h> |
16 | #include <com_err.h> | |
de56407f | 17 | |
18 | /* too bad we can't set the pathname easily */ | |
5c87ce34 | 19 | static char *srvtab = KEYFILE; /* default == /etc/srvtab */ |
de56407f | 20 | static char realm[REALM_SZ]; |
1c6164bb | 21 | static char master[] = "sms"; |
22 | static char service[] = "rcmd"; | |
de56407f | 23 | |
24 | extern char *tkt_string(), *PrincipalHostname(); | |
5c87ce34 | 25 | extern int krb_err_base; |
26 | ||
27 | static init() | |
28 | { | |
29 | static int initialized = 0; | |
30 | ||
31 | if (!initialized) { | |
32 | get_krbrlm(realm, 1); | |
33 | init_krb_err_tbl(); | |
34 | initialized=1; | |
35 | } | |
36 | } | |
de56407f | 37 | |
de56407f | 38 | |
39 | int | |
40 | get_sms_update_ticket(host, ticket) | |
41 | char *host; | |
42 | KTEXT ticket; | |
43 | { | |
44 | register int code; | |
45 | register int pass; | |
46 | char phost[BUFSIZ]; | |
47 | ||
48 | pass = 1; | |
49 | init(); | |
50 | strcpy(phost, PrincipalHostname(host)); | |
51 | try_it: | |
5c87ce34 | 52 | code = krb_mk_req(ticket, service, phost, realm, (long)0); |
53 | if (code) | |
54 | code += krb_err_base; | |
de56407f | 55 | if (pass == 1) { |
56 | /* maybe we're taking too long? */ | |
57 | if ((code = get_sms_tgt()) != 0) { | |
58 | /* don't need phost buffer any more */ | |
5c87ce34 | 59 | com_err(whoami, code, " can't get Kerberos TGT"); |
de56407f | 60 | return(code); |
61 | } | |
62 | pass++; | |
63 | goto try_it; | |
64 | } | |
5c87ce34 | 65 | return(code); |
de56407f | 66 | } |
67 | ||
68 | int | |
69 | get_sms_tgt() | |
70 | { | |
71 | register int code; | |
72 | init(); | |
1c6164bb | 73 | code = get_svc_in_tkt(master, "", realm, "krbtgt", realm, 1, srvtab); |
de56407f | 74 | if (!code) |
75 | return(0); | |
76 | else | |
5c87ce34 | 77 | return(code + krb_err_base); |
de56407f | 78 | } |