/*
 * Check to see if user's ticket-granting-ticket is valid or not...
 *
 * I think this was written by Stan Zanarotti (srz@athena.mit.edu)
 */

#include <stdio.h>
#include <krb.h>
#include <des.h>

#ifndef SRV_FILE
#define SRV_FILE "/etc/srvtab"
#endif

#ifndef SERVICE
#define SERVICE "rcmd"
#endif

/* Returns 0 if user's ticket granting ticket is validated, or the
 * error returned from the function that found it invalid. */
ck_tkt()
{
	char	instance[INST_SZ];
	char	realm[REALM_SZ];
	char	service_key[8];
	Key_schedule key_s;
	CREDENTIALS	cr;
	AUTH_DAT	ad;
	KTEXT_ST	tkt;
	char	ret_sname[INST_SZ];
	char	ret_sinst[REALM_SZ];
	int	retval;
	
	gethostname(instance,sizeof(instance));
	krb_get_lrealm(realm,1);

	if (retval = krb_mk_req(&tkt,SERVICE,instance,realm,0))
	     return (retval);
	
	if (retval = krb_rd_req(&tkt,SERVICE,instance,0,&ad,SRV_FILE))
	     return (retval);

	return(0);
}
