]> andersk Git - moira.git/blame_incremental - update/ticket.c
Use strncpy instead of bcopy when copying the entity argument, to prevent
[moira.git] / update / ticket.c
... / ...
CommitLineData
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
10static 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 */
24static char *srvtab = KEYFILE; /* default == /etc/srvtab */
25static char realm[REALM_SZ];
26static char master[INST_SZ] = "sms";
27static char service[ANAME_SZ] = "rcmd";
28C_Block session;
29
30
31static 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
44int
45get_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 if (pass == 1) {
61 /* maybe we're taking too long? */
62 if ((code = get_mr_tgt()) != 0) {
63 com_err(whoami, code, " can't get Kerberos TGT");
64 return(code);
65 }
66 pass++;
67 goto try_it;
68 }
69 com_err(whoami, code, "in krb_mk_req");
70 } else {
71 code = krb_get_cred(service, phost, realm, &cr);
72 bcopy(cr.session, session, sizeof(session));
73 }
74 return(code);
75}
76
77int
78get_mr_tgt()
79{
80 register int code;
81 char linst[INST_SZ], kinst[INST_SZ];
82
83 init();
84 linst[0] = '\0';
85 strcpy(kinst, "krbtgt");
86 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
87 DEFAULT_TKT_LIFE, srvtab);
88 if (!code)
89 return(0);
90 else
91 return(code + ERROR_TABLE_BASE_krb);
92}
This page took 0.032169 seconds and 5 git commands to generate.