3 * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
27 static char realm[REALM_SZ];
28 static char master[INST_SZ] = "sms";
29 static char service[ANAME_SZ] = "rcmd";
32 krb5_context context = NULL;
35 static int get_mr_tgt(void);
38 int get_mr_krb5_update_ticket(char *host, krb5_data auth)
40 krb5_auth_context auth_con = NULL;
41 krb5_ccache ccache = NULL;
44 code = krb5_init_context(&context);
48 code = krb5_auth_con_init(context, &auth_con);
52 code = krb5_cc_default(context, &ccache);
56 code = krb5_mk_req(context, &auth_con, 0, "host", host, NULL, ccache,
61 krb5_cc_close(context, ccache);
63 krb5_auth_con_free(context, auth_con);
67 int get_mr_update_ticket(char *host, KTEXT ticket)
75 if (krb_get_lrealm(realm, 1))
76 strcpy(realm, KRB_REALM);
77 strcpy(phost, (char *)krb_get_phost(host));
80 code = krb_mk_req(ticket, service, phost, realm, (long)0);
85 /* maybe we're taking too long? */
86 if ((code = get_mr_tgt()))
88 com_err(whoami, code, "can't get Kerberos TGT");
94 code += ERROR_TABLE_BASE_krb;
95 com_err(whoami, code, "in krb_mk_req");
99 code = krb_get_cred(service, phost, realm, &cr);
101 code += ERROR_TABLE_BASE_krb;
102 memcpy(session, cr.session, sizeof(session));
111 static int get_mr_tgt(void)
114 char linst[INST_SZ], kinst[INST_SZ];
117 strcpy(kinst, "krbtgt");
118 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
119 DEFAULT_TKT_LIFE, KEYFILE);
123 return code + ERROR_TABLE_BASE_krb;