Пример #1
0
krb5_error_code KRB5_CALLCONV sss_krb5_get_init_creds_opt_set_expire_callback(
                                                   krb5_context context,
                                                   krb5_get_init_creds_opt *opt,
                                                   krb5_expire_callback_func cb,
                                                   void *data)
{
#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_EXPIRE_CALLBACK
    return krb5_get_init_creds_opt_set_expire_callback(context, opt, cb, data);
#else
    DEBUG(5, ("krb5_get_init_creds_opt_set_expire_callback not available.\n"));
    return 0;
#endif
}
Пример #2
0
int
main(int argc, char **argv)
{
    krb5_context ctx;
    krb5_get_init_creds_opt *opt;
    char *user, *password, *service = NULL;
    krb5_boolean use_cb;
    krb5_principal client;
    krb5_creds creds;

    if (argc < 4) {
	fprintf(stderr, "Usage: %s username password {1|0} [service]\n",
		argv[0]);
	return 1;
    }
    user = argv[1];
    password = argv[2];
    use_cb = atoi(argv[3]);
    if (argc >= 5)
	service = argv[4];

    assert(krb5_init_context(&ctx) == 0);
    assert(krb5_get_init_creds_opt_alloc(ctx, &opt) == 0);
    if (use_cb) {
	assert(krb5_get_init_creds_opt_set_expire_callback(ctx, opt, expire_cb,
							   &exp_dummy) == 0);
    }
    assert(krb5_parse_name(ctx, user, &client) == 0);
    assert(krb5_get_init_creds_password(ctx, &creds, client, password,
					prompter_cb, &prompt_dummy, 0, service,
					opt) == 0);
    krb5_get_init_creds_opt_free(ctx, opt);
    krb5_free_principal(ctx, client);
    krb5_free_cred_contents(ctx, &creds);
    return 0;
}