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>
22 static char realm[REALM_SZ];
23 static char master[INST_SZ] = "sms";
24 static char service[ANAME_SZ] = "rcmd";
26 krb5_context context = NULL;
28 static int get_mr_tgt(void);
30 int get_mr_krb5_update_ticket(char *host, krb5_data auth)
32 krb5_auth_context auth_con = NULL;
33 krb5_ccache ccache = NULL;
36 code = krb5_init_context(&context);
40 code = krb5_auth_con_init(context, &auth_con);
44 krb5_init_ets(context);
46 code = krb5_cc_default(context, &ccache);
50 code = krb5_mk_req(context, &auth_con, NULL, "host", host, NULL, ccache,
55 krb5_cc_close(context, ccache);
57 krb5_auth_con_free(context, auth_con);
61 int get_mr_update_ticket(char *host, KTEXT ticket)
68 if (krb_get_lrealm(realm, 1))
69 strcpy(realm, KRB_REALM);
70 strcpy(phost, (char *)krb_get_phost(host));
73 code = krb_mk_req(ticket, service, phost, realm, (long)0);
78 /* maybe we're taking too long? */
79 if ((code = get_mr_tgt()))
81 com_err(whoami, code, "can't get Kerberos TGT");
87 code += ERROR_TABLE_BASE_krb;
88 com_err(whoami, code, "in krb_mk_req");
92 code = krb_get_cred(service, phost, realm, &cr);
94 code += ERROR_TABLE_BASE_krb;
95 memcpy(session, cr.session, sizeof(session));
100 static int get_mr_tgt(void)
103 char linst[INST_SZ], kinst[INST_SZ];
106 strcpy(kinst, "krbtgt");
107 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
108 DEFAULT_TKT_LIFE, KEYFILE);
112 return code + ERROR_TABLE_BASE_krb;