]> andersk Git - moira.git/blob - update/ticket.c
additional argument to get_file()
[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 C_Block session;
29
30
31 static init()
32 {
33     static int initialized = 0;
34
35     if (!initialized) {
36         if (krb_get_lrealm(realm, 1))
37             strcpy(realm, KRB_REALM);
38         initialize_krb_error_table();
39         initialized=1;
40     }
41 }
42
43
44 int
45 get_mr_update_ticket(host, ticket)
46      char *host;
47      KTEXT ticket;
48 {
49      register int code;
50      register int pass;
51      char phost[BUFSIZ];
52      CREDENTIALS cr;
53
54      pass = 1;
55      init();
56      strcpy(phost, krb_get_phost(host));
57  try_it:
58      code = krb_mk_req(ticket, service, phost, realm, (long)0);
59      if (code) {
60          code += ERROR_TABLE_BASE_krb;
61          com_err(whoami, code, "in krb_mk_req");
62      } else {
63          code = krb_get_cred(service, phost, realm, &cr);
64          bcopy(cr.session, session, sizeof(session));
65      }
66 #ifdef notdef
67      if (pass == 1) {
68          /* maybe we're taking too long? */
69          if ((code = get_mr_tgt()) != 0) {
70              com_err(whoami, code, " can't get Kerberos TGT");
71              return(code);
72          }
73          pass++;
74          goto try_it;
75      }
76 #endif /* notdef */
77      return(code);
78 }
79
80 int
81 get_mr_tgt()
82 {
83     register int code;
84     char linst[INST_SZ], kinst[INST_SZ];
85
86     init();
87     linst[0] = '\0';
88     strcpy(kinst, "krbtgt");
89     code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, 1, srvtab);
90     if (!code)
91         return(0);
92     else
93         return(code + ERROR_TABLE_BASE_krb);
94 }
This page took 0.039465 seconds and 5 git commands to generate.