]> andersk Git - moira.git/blob - update/ticket.c
added copyright message
[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
22 /* too bad we can't set the pathname easily */
23 static char *srvtab = KEYFILE; /* default == /etc/srvtab */
24 static char realm[REALM_SZ];
25 static char master[] = "sms";
26 static char service[] = "rcmd";
27
28 extern char *tkt_string(), *PrincipalHostname();
29 extern int krb_err_base;
30
31 static init()
32 {
33     static int initialized = 0;
34
35     if (!initialized) {
36         get_krbrlm(realm, 1);
37         init_krb_err_tbl();
38         initialized=1;
39     }
40 }
41
42
43 int
44 get_sms_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, PrincipalHostname(host));
55  try_it:
56      code = krb_mk_req(ticket, service, phost, realm, (long)0);
57      if (code)
58        code += krb_err_base;
59      if (pass == 1) {
60          /* maybe we're taking too long? */
61          if ((code = get_sms_tgt()) != 0) {
62              /* don't need phost buffer any more */
63              com_err(whoami, code, " can't get Kerberos TGT");
64              return(code);
65          }
66          pass++;
67          goto try_it;
68      }
69      return(code);
70 }
71
72 int
73 get_sms_tgt()
74 {
75     register int code;
76     init();
77     code = get_svc_in_tkt(master, "", realm, "krbtgt", realm, 1, srvtab);
78     if (!code)
79         return(0);
80     else
81         return(code + krb_err_base);
82 }
This page took 0.039893 seconds and 5 git commands to generate.