]> andersk Git - moira.git/blob - update/ticket.c
use krb_get_phost, not local routine; don't try to kinit again
[moira.git] / update / ticket.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5 /*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /*  For copying and distribution information, please see the file */
7 /*  <mit-copyright.h>. */
8
9 #ifndef lint
10 static char *rcsid_ticket_c = "$Header$";
11 #endif  lint
12
13 #include <mit-copyright.h>
14 #include <stdio.h>
15 #include <krb.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <strings.h>
19 #include <update.h>
20 #include <com_err.h>
21 #include <krb_et.h>
22
23 /* too bad we can't set the pathname easily */
24 static char *srvtab = KEYFILE; /* default == /etc/srvtab */
25 static char realm[REALM_SZ];
26 static char master[INST_SZ] = "sms";
27 static char service[ANAME_SZ] = "rcmd";
28
29
30 static init()
31 {
32     static int initialized = 0;
33
34     if (!initialized) {
35         if (krb_get_lrealm(realm, 1))
36             strcpy(realm, KRB_REALM);
37         initialize_krb_error_table();
38         initialized=1;
39     }
40 }
41
42
43 int
44 get_mr_update_ticket(host, ticket)
45      char *host;
46      KTEXT ticket;
47 {
48      register int code;
49      register int pass;
50      char phost[BUFSIZ];
51
52      pass = 1;
53      init();
54      strcpy(phost, krb_get_phost(host));
55  try_it:
56      code = krb_mk_req(ticket, service, phost, realm, (long)0);
57      if (code) {
58          code += ERROR_TABLE_BASE_krb;
59          com_err(whoami, code, "in krb_mk_req");
60      }
61 #ifdef notdef
62      if (pass == 1) {
63          /* maybe we're taking too long? */
64          if ((code = get_mr_tgt()) != 0) {
65              com_err(whoami, code, " can't get Kerberos TGT");
66              return(code);
67          }
68          pass++;
69          goto try_it;
70      }
71 #endif /* notdef */
72      return(code);
73 }
74
75 int
76 get_mr_tgt()
77 {
78     register int code;
79     char linst[INST_SZ], kinst[INST_SZ];
80
81     init();
82     linst[0] = '\0';
83     strcpy(kinst, "krbtgt");
84     code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, 1, srvtab);
85     if (!code)
86         return(0);
87     else
88         return(code + ERROR_TABLE_BASE_krb);
89 }
This page took 0.042536 seconds and 5 git commands to generate.