X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/7da203a3ff879dbcfde52503b22799e2b5b5149f..9d3d51ad672f0e2d3961581c4675362349a3fe9d:/update/ticket.c diff --git a/update/ticket.c b/update/ticket.c index 6e5f6d1d..a04a5214 100644 --- a/update/ticket.c +++ b/update/ticket.c @@ -1,94 +1,80 @@ -/* - * $Source$ - * $Header$ +/* $Id$ + * + * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology. + * For copying and distribution information, please see the file + * . */ -/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ -/* For copying and distribution information, please see the file */ -/* . */ - -#ifndef lint -static char *rcsid_ticket_c = "$Header$"; -#endif #include -#include -#include -#include +#include + #include + +#include #include + +#include #include -#include -#include -extern char *whoami; +RCSID("$Header$"); -/* too bad we can't set the pathname easily */ -static char *srvtab = KEYFILE; /* default == /etc/srvtab */ static char realm[REALM_SZ]; static char master[INST_SZ] = "sms"; static char service[ANAME_SZ] = "rcmd"; -C_Block session; +des_cblock session; +static int get_mr_tgt(void); -static init() +int get_mr_update_ticket(char *host, KTEXT ticket) { - static int initialized = 0; + int code, pass; + char phost[BUFSIZ]; + CREDENTIALS cr; - if (!initialized) { - if (krb_get_lrealm(realm, 1)) - strcpy(realm, KRB_REALM); - initialize_krb_error_table(); - initialized=1; - } -} + pass = 1; + if (krb_get_lrealm(realm, 1)) + strcpy(realm, KRB_REALM); + strcpy(phost, (char *)krb_get_phost(host)); - -int -get_mr_update_ticket(host, ticket) - char *host; - KTEXT ticket; -{ - register int code; - register int pass; - char phost[BUFSIZ]; - CREDENTIALS cr; - - pass = 1; - init(); - strcpy(phost, (char*)krb_get_phost(host)); - try_it: - code = krb_mk_req(ticket, service, phost, realm, (long)0); - if (code) { - if (pass == 1) { - /* maybe we're taking too long? */ - if ((code = get_mr_tgt()) != 0) { - com_err(whoami, code, " can't get Kerberos TGT"); - return(code); - } - pass++; - goto try_it; - } - com_err(whoami, code, "in krb_mk_req"); - } else { - code = krb_get_cred(service, phost, realm, &cr); - memcpy(session, cr.session, sizeof(session)); - } - return(code); +try_it: + code = krb_mk_req(ticket, service, phost, realm, (long)0); + if (code) + { + if (pass == 1) + { + /* maybe we're taking too long? */ + if ((code = get_mr_tgt())) + { + com_err(whoami, code, "can't get Kerberos TGT"); + return code; + } + pass++; + goto try_it; + } + code += ERROR_TABLE_BASE_krb; + com_err(whoami, code, "in krb_mk_req"); + } + else + { + code = krb_get_cred(service, phost, realm, &cr); + if (code) + code += ERROR_TABLE_BASE_krb; + memcpy(session, cr.session, sizeof(session)); + } + return code; } -int -get_mr_tgt() +static int get_mr_tgt(void) { - register int code; - char linst[INST_SZ], kinst[INST_SZ]; + int code; + char linst[INST_SZ], kinst[INST_SZ]; - init(); - linst[0] = '\0'; - strcpy(kinst, "krbtgt"); - code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, - DEFAULT_TKT_LIFE, srvtab); - if (!code) - return(0); - else - return(code + ERROR_TABLE_BASE_krb); + linst[0] = '\0'; + strcpy(kinst, "krbtgt"); + code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm, + DEFAULT_TKT_LIFE, KEYFILE); + if (!code) + return 0; + else + return code + ERROR_TABLE_BASE_krb; }