]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id$ |
2 | * | |
3 | * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology. | |
4 | * For copying and distribution information, please see the file | |
5 | * <mit-copyright.h>. | |
de56407f | 6 | */ |
de56407f | 7 | |
546bc43b | 8 | #include <mit-copyright.h> |
7ac48069 | 9 | #include <moira.h> |
10 | ||
de56407f | 11 | #include <sys/stat.h> |
7ac48069 | 12 | |
13 | #include <stdio.h> | |
a6e20de8 | 14 | #include <string.h> |
7ac48069 | 15 | |
16 | #include <krb.h> | |
5c87ce34 | 17 | #include <update.h> |
7ac48069 | 18 | |
19 | RCSID("$Header$"); | |
de56407f | 20 | |
de56407f | 21 | static char realm[REALM_SZ]; |
b95ec814 | 22 | static char master[INST_SZ] = "sms"; |
23 | static char service[ANAME_SZ] = "rcmd"; | |
85330553 | 24 | des_cblock session; |
de56407f | 25 | |
85330553 | 26 | static int get_mr_tgt(void); |
de56407f | 27 | |
5eaef520 | 28 | int get_mr_update_ticket(char *host, KTEXT ticket) |
de56407f | 29 | { |
85330553 | 30 | int code, pass; |
5eaef520 | 31 | char phost[BUFSIZ]; |
32 | CREDENTIALS cr; | |
de56407f | 33 | |
5eaef520 | 34 | pass = 1; |
85330553 | 35 | if (krb_get_lrealm(realm, 1)) |
36 | strcpy(realm, KRB_REALM); | |
5eaef520 | 37 | strcpy(phost, (char *)krb_get_phost(host)); |
85330553 | 38 | |
5eaef520 | 39 | try_it: |
40 | code = krb_mk_req(ticket, service, phost, realm, (long)0); | |
41 | if (code) | |
42 | { | |
43 | if (pass == 1) | |
44 | { | |
45 | /* maybe we're taking too long? */ | |
46 | if ((code = get_mr_tgt())) | |
47 | { | |
48 | com_err(whoami, code, "can't get Kerberos TGT"); | |
49 | return code; | |
50 | } | |
51 | pass++; | |
52 | goto try_it; | |
53 | } | |
54 | code += ERROR_TABLE_BASE_krb; | |
55 | com_err(whoami, code, "in krb_mk_req"); | |
56 | } | |
57 | else | |
58 | { | |
59 | code = krb_get_cred(service, phost, realm, &cr); | |
60 | if (code) | |
61 | code += ERROR_TABLE_BASE_krb; | |
62 | memcpy(session, cr.session, sizeof(session)); | |
63 | } | |
64 | return code; | |
de56407f | 65 | } |
66 | ||
85330553 | 67 | static int get_mr_tgt(void) |
de56407f | 68 | { |
44d12d58 | 69 | int code; |
5eaef520 | 70 | char linst[INST_SZ], kinst[INST_SZ]; |
b95ec814 | 71 | |
5eaef520 | 72 | linst[0] = '\0'; |
73 | strcpy(kinst, "krbtgt"); | |
74 | code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, | |
91519120 | 75 | DEFAULT_TKT_LIFE, KEYFILE); |
5eaef520 | 76 | if (!code) |
77 | return 0; | |
78 | else | |
79 | return code + ERROR_TABLE_BASE_krb; | |
de56407f | 80 | } |