]> andersk Git - moira.git/blame - update/ticket.c
punt mrgdb
[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
5c87ce34 21static char *srvtab = KEYFILE; /* default == /etc/srvtab */
de56407f 22static char realm[REALM_SZ];
b95ec814 23static char master[INST_SZ] = "sms";
24static char service[ANAME_SZ] = "rcmd";
85330553 25des_cblock session;
de56407f 26
85330553 27static int get_mr_tgt(void);
de56407f 28
5eaef520 29int get_mr_update_ticket(char *host, KTEXT ticket)
de56407f 30{
85330553 31 int code, pass;
5eaef520 32 char phost[BUFSIZ];
33 CREDENTIALS cr;
de56407f 34
5eaef520 35 pass = 1;
85330553 36 if (krb_get_lrealm(realm, 1))
37 strcpy(realm, KRB_REALM);
5eaef520 38 strcpy(phost, (char *)krb_get_phost(host));
85330553 39
5eaef520 40try_it:
41 code = krb_mk_req(ticket, service, phost, realm, (long)0);
42 if (code)
43 {
44 if (pass == 1)
45 {
46 /* maybe we're taking too long? */
47 if ((code = get_mr_tgt()))
48 {
49 com_err(whoami, code, "can't get Kerberos TGT");
50 return code;
51 }
52 pass++;
53 goto try_it;
54 }
55 code += ERROR_TABLE_BASE_krb;
56 com_err(whoami, code, "in krb_mk_req");
57 }
58 else
59 {
60 code = krb_get_cred(service, phost, realm, &cr);
61 if (code)
62 code += ERROR_TABLE_BASE_krb;
63 memcpy(session, cr.session, sizeof(session));
64 }
65 return code;
de56407f 66}
67
85330553 68static int get_mr_tgt(void)
de56407f 69{
44d12d58 70 int code;
5eaef520 71 char linst[INST_SZ], kinst[INST_SZ];
b95ec814 72
5eaef520 73 linst[0] = '\0';
74 strcpy(kinst, "krbtgt");
75 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
76 DEFAULT_TKT_LIFE, srvtab);
77 if (!code)
78 return 0;
79 else
80 return code + ERROR_TABLE_BASE_krb;
de56407f 81}
This page took 0.137006 seconds and 5 git commands to generate.