client-tools crash with heimdal and expired accounts

Love lha at stacken.kth.se
Fri Nov 12 01:28:38 GMT 2004


Skipped content of type multipart/signed-------------- next part --------------
#include <krb5.h>

static krb5_error_code 
kerb_prompter(krb5_context ctx, void *data,
	      const char *name,
	      const char *banner,
	      int num_prompts,
	      krb5_prompt prompts[])
{
    if (num_prompts == 0) return 0;

    memset(prompts[0].reply->data, 0, prompts[0].reply->length);
    if (prompts[0].reply->length > 0) {
	if (data) {
	    strncpy(prompts[0].reply->data, data, prompts[0].reply->length-1);
	    prompts[0].reply->length = strlen(prompts[0].reply->data);
	} else {
	    prompts[0].reply->length = 0;
	}
    }
    return 0;
}


int
main(int argc, char **argv)
{
    krb5_error_code ret;
    krb5_creds creds;
    krb5_context context;
    krb5_get_init_creds_opt opt;
    const char *password = argv[1];
    krb5_principal client;

    memset(&creds, 0, sizeof(creds));
    krb5_init_context(&context);
    krb5_get_init_creds_opt_init(&opt);

    ret = krb5_parse_name(context, "lha at SU.SE", &client);
    if (ret)
	krb5_err(context, 1, ret, "parse_name");

    ret = krb5_get_init_creds_password(context, &creds, client,
				       password, kerb_prompter, NULL,
				       0, "kadmin/changepw", &opt);
    if (ret)
	krb5_err(context, 1, ret, "init_creds");

    return 0;
}


More information about the samba-technical mailing list