]> andersk Git - moira.git/blame - update/ticket.c
fix RCS Id strings
[moira.git] / update / ticket.c
CommitLineData
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
19RCSID("$Header$");
de56407f 20
7da203a3 21extern char *whoami;
22
de56407f 23/* too bad we can't set the pathname easily */
5c87ce34 24static char *srvtab = KEYFILE; /* default == /etc/srvtab */
de56407f 25static char realm[REALM_SZ];
b95ec814 26static char master[INST_SZ] = "sms";
27static char service[ANAME_SZ] = "rcmd";
49b589d4 28C_Block session;
851fd300 29
7ac48069 30int get_mr_tgt(void);
5c87ce34 31
7ac48069 32static void init(void)
5c87ce34 33{
5eaef520 34 static int initialized = 0;
5c87ce34 35
5eaef520 36 if (!initialized)
37 {
38 if (krb_get_lrealm(realm, 1))
39 strcpy(realm, KRB_REALM);
40 initialize_krb_error_table();
41 initialized = 1;
5c87ce34 42 }
43}
de56407f 44
de56407f 45
5eaef520 46int get_mr_update_ticket(char *host, KTEXT ticket)
de56407f 47{
44d12d58 48 int code;
49 int pass;
5eaef520 50 char phost[BUFSIZ];
51 CREDENTIALS cr;
de56407f 52
5eaef520 53 pass = 1;
54 init();
55 strcpy(phost, (char *)krb_get_phost(host));
56try_it:
57 code = krb_mk_req(ticket, service, phost, realm, (long)0);
58 if (code)
59 {
60 if (pass == 1)
61 {
62 /* maybe we're taking too long? */
63 if ((code = get_mr_tgt()))
64 {
65 com_err(whoami, code, "can't get Kerberos TGT");
66 return code;
67 }
68 pass++;
69 goto try_it;
70 }
71 code += ERROR_TABLE_BASE_krb;
72 com_err(whoami, code, "in krb_mk_req");
73 }
74 else
75 {
76 code = krb_get_cred(service, phost, realm, &cr);
77 if (code)
78 code += ERROR_TABLE_BASE_krb;
79 memcpy(session, cr.session, sizeof(session));
80 }
81 return code;
de56407f 82}
83
5eaef520 84int get_mr_tgt(void)
de56407f 85{
44d12d58 86 int code;
5eaef520 87 char linst[INST_SZ], kinst[INST_SZ];
b95ec814 88
5eaef520 89 init();
90 linst[0] = '\0';
91 strcpy(kinst, "krbtgt");
92 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
93 DEFAULT_TKT_LIFE, srvtab);
94 if (!code)
95 return 0;
96 else
97 return code + ERROR_TABLE_BASE_krb;
de56407f 98}
This page took 0.480092 seconds and 5 git commands to generate.