]> andersk Git - moira.git/blob - update/ticket.c
punt mrgdb
[moira.git] / update / ticket.c
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>.
6  */
7
8 #include <mit-copyright.h>
9 #include <moira.h>
10
11 #include <sys/stat.h>
12
13 #include <stdio.h>
14 #include <string.h>
15
16 #include <krb.h>
17 #include <update.h>
18
19 RCSID("$Header$");
20
21 static char *srvtab = KEYFILE; /* default == /etc/srvtab */
22 static char realm[REALM_SZ];
23 static char master[INST_SZ] = "sms";
24 static char service[ANAME_SZ] = "rcmd";
25 des_cblock session;
26
27 static int get_mr_tgt(void);
28
29 int get_mr_update_ticket(char *host, KTEXT ticket)
30 {
31   int code, pass;
32   char phost[BUFSIZ];
33   CREDENTIALS cr;
34
35   pass = 1;
36   if (krb_get_lrealm(realm, 1))
37     strcpy(realm, KRB_REALM);
38   strcpy(phost, (char *)krb_get_phost(host));
39
40 try_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;
66 }
67
68 static int get_mr_tgt(void)
69 {
70   int code;
71   char linst[INST_SZ], kinst[INST_SZ];
72
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;
81 }
This page took 0.095799 seconds and 5 git commands to generate.