]> andersk Git - moira.git/blame - update/ticket.c
Was completely broken; took code from xfer_001.c
[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];
1c6164bb 26static char master[] = "sms";
27static char service[] = "rcmd";
de56407f 28
29extern char *tkt_string(), *PrincipalHostname();
851fd300 30
5c87ce34 31
32static init()
33{
34 static int initialized = 0;
35
36 if (!initialized) {
f4f2cbe9 37 if (krb_get_lrealm(realm, 1))
38 strcpy(realm, KRB_REALM);
851fd300 39 initialize_krb_error_table();
5c87ce34 40 initialized=1;
41 }
42}
de56407f 43
de56407f 44
45int
2ad0a777 46get_mr_update_ticket(host, ticket)
de56407f 47 char *host;
48 KTEXT ticket;
49{
50 register int code;
51 register int pass;
52 char phost[BUFSIZ];
53
54 pass = 1;
55 init();
56 strcpy(phost, PrincipalHostname(host));
57 try_it:
5c87ce34 58 code = krb_mk_req(ticket, service, phost, realm, (long)0);
59 if (code)
851fd300 60 code += ERROR_TABLE_BASE_krb;
de56407f 61 if (pass == 1) {
62 /* maybe we're taking too long? */
2ad0a777 63 if ((code = get_mr_tgt()) != 0) {
de56407f 64 /* don't need phost buffer any more */
5c87ce34 65 com_err(whoami, code, " can't get Kerberos TGT");
de56407f 66 return(code);
67 }
68 pass++;
69 goto try_it;
70 }
5c87ce34 71 return(code);
de56407f 72}
73
74int
2ad0a777 75get_mr_tgt()
de56407f 76{
77 register int code;
78 init();
35b49ca5 79 code = krb_get_svc_in_tkt(master, "", realm, "krbtgt", realm, 1, srvtab);
de56407f 80 if (!code)
81 return(0);
82 else
851fd300 83 return(code + ERROR_TABLE_BASE_krb);
de56407f 84}
This page took 0.08457 seconds and 5 git commands to generate.