Ejemplo n.º 1
0
static int
check_for_tgt(krb5_context context, krb5_ccache ccache,
	      krb5_principal principal)
{
	krb5_error_code ret;
	krb5_creds creds;
	krb5_cc_cursor cur;
	int found = 0;

	ret = krb5_cc_start_seq_get(context, ccache, &cur);
	if (ret) 
		return 0;

	while (!found &&
		(ret = krb5_cc_next_cred(context, ccache, &cur, &creds)) == 0) {
		if (creds.server->length == 2 &&
				data_is_equal(creds.server->realm,
					      principal->realm) &&
				creds.server->data[0].length == 6 &&
				memcmp(creds.server->data[0].data,
						"krbtgt", 6) == 0 &&
				data_is_equal(creds.server->data[1],
					      principal->realm) &&
				creds.times.endtime > time(NULL))
			found = 1;
		krb5_free_cred_contents(context, &creds);
	}
	krb5_cc_end_seq_get(context, ccache, &cur);

	return found;
}
Ejemplo n.º 2
0
bool list_is_equal(list_t list, list_t other) {
	bool result = true;
	
	while(result && list!=NULL && other!=NULL) {
		if(!index_is_equal(pair_fst(list->elem),pair_fst(other->elem))) {
			result = false;
		}
		if(!data_is_equal(pair_snd(list->elem),pair_snd(other->elem))) {
			result = false;
		}
		list = list->next;
		other = other->next;
	}
	
	return result && list == NULL && other == NULL;
}