]>
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> | |
a6e20de8 | 18 | #include <string.h> |
5c87ce34 | 19 | #include <update.h> |
20 | #include <com_err.h> | |
851fd300 | 21 | #include <krb_et.h> |
de56407f | 22 | |
23 | /* too bad we can't set the pathname easily */ | |
5c87ce34 | 24 | static char *srvtab = KEYFILE; /* default == /etc/srvtab */ |
de56407f | 25 | static char realm[REALM_SZ]; |
b95ec814 | 26 | static char master[INST_SZ] = "sms"; |
27 | static char service[ANAME_SZ] = "rcmd"; | |
49b589d4 | 28 | C_Block session; |
851fd300 | 29 | |
5c87ce34 | 30 | |
31 | static init() | |
32 | { | |
33 | static int initialized = 0; | |
34 | ||
35 | if (!initialized) { | |
f4f2cbe9 | 36 | if (krb_get_lrealm(realm, 1)) |
37 | strcpy(realm, KRB_REALM); | |
851fd300 | 38 | initialize_krb_error_table(); |
5c87ce34 | 39 | initialized=1; |
40 | } | |
41 | } | |
de56407f | 42 | |
de56407f | 43 | |
44 | int | |
2ad0a777 | 45 | get_mr_update_ticket(host, ticket) |
de56407f | 46 | char *host; |
47 | KTEXT ticket; | |
48 | { | |
49 | register int code; | |
50 | register int pass; | |
51 | char phost[BUFSIZ]; | |
49b589d4 | 52 | CREDENTIALS cr; |
de56407f | 53 | |
54 | pass = 1; | |
55 | init(); | |
b95ec814 | 56 | strcpy(phost, krb_get_phost(host)); |
de56407f | 57 | try_it: |
5c87ce34 | 58 | code = krb_mk_req(ticket, service, phost, realm, (long)0); |
b95ec814 | 59 | if (code) { |
64ac4338 | 60 | if (pass == 1) { |
61 | /* maybe we're taking too long? */ | |
62 | if ((code = get_mr_tgt()) != 0) { | |
63 | com_err(whoami, code, " can't get Kerberos TGT"); | |
64 | return(code); | |
65 | } | |
66 | pass++; | |
67 | goto try_it; | |
68 | } | |
b95ec814 | 69 | com_err(whoami, code, "in krb_mk_req"); |
49b589d4 | 70 | } else { |
71 | code = krb_get_cred(service, phost, realm, &cr); | |
a6e20de8 | 72 | memcpy(session, cr.session, sizeof(session)); |
b95ec814 | 73 | } |
5c87ce34 | 74 | return(code); |
de56407f | 75 | } |
76 | ||
77 | int | |
2ad0a777 | 78 | get_mr_tgt() |
de56407f | 79 | { |
80 | register int code; | |
b95ec814 | 81 | char linst[INST_SZ], kinst[INST_SZ]; |
82 | ||
de56407f | 83 | init(); |
b95ec814 | 84 | linst[0] = '\0'; |
85 | strcpy(kinst, "krbtgt"); | |
ec14a982 | 86 | code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, |
87 | DEFAULT_TKT_LIFE, srvtab); | |
de56407f | 88 | if (!code) |
89 | return(0); | |
90 | else | |
851fd300 | 91 | return(code + ERROR_TABLE_BASE_krb); |
de56407f | 92 | } |