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