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 code = krb5_cc_default(context, &ccache);
48 code = krb5_mk_req(context, &auth_con, 0, "host", host, NULL, ccache,
53 krb5_cc_close(context, ccache);
55 krb5_auth_con_free(context, auth_con);
59 int get_mr_update_ticket(char *host, KTEXT ticket)
66 if (krb_get_lrealm(realm, 1))
67 strcpy(realm, KRB_REALM);
68 strcpy(phost, (char *)krb_get_phost(host));
71 code = krb_mk_req(ticket, service, phost, realm, (long)0);
76 /* maybe we're taking too long? */
77 if ((code = get_mr_tgt()))
79 com_err(whoami, code, "can't get Kerberos TGT");
85 code += ERROR_TABLE_BASE_krb;
86 com_err(whoami, code, "in krb_mk_req");
90 code = krb_get_cred(service, phost, realm, &cr);
92 code += ERROR_TABLE_BASE_krb;
93 memcpy(session, cr.session, sizeof(session));
98 static int get_mr_tgt(void)
101 char linst[INST_SZ], kinst[INST_SZ];
104 strcpy(kinst, "krbtgt");
105 code = krb_get_svc_in_tkt(master, linst, realm, kinst, realm,
106 DEFAULT_TKT_LIFE, KEYFILE);
110 return code + ERROR_TABLE_BASE_krb;