]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
546bc43b | 5 | /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ |
6 | /* For copying and distribution information, please see the file */ | |
7 | /* <mit-copyright.h>. */ | |
de56407f | 8 | |
9 | #ifndef lint | |
10 | static char *rcsid_ticket_c = "$Header$"; | |
11 | #endif lint | |
12 | ||
546bc43b | 13 | #include <mit-copyright.h> |
de56407f | 14 | #include <stdio.h> |
15 | #include <krb.h> | |
16 | #include <sys/types.h> | |
17 | #include <sys/stat.h> | |
18 | #include <strings.h> | |
5c87ce34 | 19 | #include <update.h> |
20 | #include <com_err.h> | |
de56407f | 21 | |
22 | /* too bad we can't set the pathname easily */ | |
5c87ce34 | 23 | static char *srvtab = KEYFILE; /* default == /etc/srvtab */ |
de56407f | 24 | static char realm[REALM_SZ]; |
1c6164bb | 25 | static char master[] = "sms"; |
26 | static char service[] = "rcmd"; | |
de56407f | 27 | |
28 | extern char *tkt_string(), *PrincipalHostname(); | |
5c87ce34 | 29 | extern int krb_err_base; |
30 | ||
31 | static init() | |
32 | { | |
33 | static int initialized = 0; | |
34 | ||
35 | if (!initialized) { | |
36 | get_krbrlm(realm, 1); | |
37 | init_krb_err_tbl(); | |
38 | initialized=1; | |
39 | } | |
40 | } | |
de56407f | 41 | |
de56407f | 42 | |
43 | int | |
44 | get_sms_update_ticket(host, ticket) | |
45 | char *host; | |
46 | KTEXT ticket; | |
47 | { | |
48 | register int code; | |
49 | register int pass; | |
50 | char phost[BUFSIZ]; | |
51 | ||
52 | pass = 1; | |
53 | init(); | |
54 | strcpy(phost, PrincipalHostname(host)); | |
55 | try_it: | |
5c87ce34 | 56 | code = krb_mk_req(ticket, service, phost, realm, (long)0); |
57 | if (code) | |
58 | code += krb_err_base; | |
de56407f | 59 | if (pass == 1) { |
60 | /* maybe we're taking too long? */ | |
61 | if ((code = get_sms_tgt()) != 0) { | |
62 | /* don't need phost buffer any more */ | |
5c87ce34 | 63 | com_err(whoami, code, " can't get Kerberos TGT"); |
de56407f | 64 | return(code); |
65 | } | |
66 | pass++; | |
67 | goto try_it; | |
68 | } | |
5c87ce34 | 69 | return(code); |
de56407f | 70 | } |
71 | ||
72 | int | |
73 | get_sms_tgt() | |
74 | { | |
75 | register int code; | |
76 | init(); | |
1c6164bb | 77 | code = get_svc_in_tkt(master, "", realm, "krbtgt", realm, 1, srvtab); |
de56407f | 78 | if (!code) |
79 | return(0); | |
80 | else | |
5c87ce34 | 81 | return(code + krb_err_base); |
de56407f | 82 | } |