|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
/* tests/plugorder.c - Test harness to display the order of loaded plugins */
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright (C) 2013 by the Massachusetts Institute of Technology.
|
|
Packit |
fd8b60 |
* All rights reserved.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
fd8b60 |
* modification, are permitted provided that the following conditions
|
|
Packit |
fd8b60 |
* are met:
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* * Redistributions of source code must retain the above copyright
|
|
Packit |
fd8b60 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
fd8b60 |
* notice, this list of conditions and the following disclaimer in
|
|
Packit |
fd8b60 |
* the documentation and/or other materials provided with the
|
|
Packit |
fd8b60 |
* distribution.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
fd8b60 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
fd8b60 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
Packit |
fd8b60 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
Packit |
fd8b60 |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
Packit |
fd8b60 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
Packit |
fd8b60 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
fd8b60 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit |
fd8b60 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
Packit |
fd8b60 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
fd8b60 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
Packit |
fd8b60 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* This file registers a few dummy built-in pwqual modules, then prints out the
|
|
Packit |
fd8b60 |
* order of pwqual modules returned by k5_plugin_load_all. The choice of the
|
|
Packit |
fd8b60 |
* pwqual interface is mostly arbitrary; it is an interface which libkrb5
|
|
Packit |
fd8b60 |
* itself doesn't use, for which we have a test module.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include "k5-int.h"
|
|
Packit |
fd8b60 |
#include <krb5/pwqual_plugin.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static krb5_context ctx;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static void
|
|
Packit |
fd8b60 |
check(krb5_error_code code)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
const char *errmsg;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
if (code) {
|
|
Packit |
fd8b60 |
errmsg = krb5_get_error_message(ctx, code);
|
|
Packit |
fd8b60 |
fprintf(stderr, "%s\n", errmsg);
|
|
Packit |
fd8b60 |
krb5_free_error_message(ctx, errmsg);
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static krb5_error_code
|
|
Packit |
fd8b60 |
blt1(krb5_context context, int maj_ver, int min_ver, krb5_plugin_vtable vtable)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
((krb5_pwqual_vtable)vtable)->name = "blt1";
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static krb5_error_code
|
|
Packit |
fd8b60 |
blt2(krb5_context context, int maj_ver, int min_ver, krb5_plugin_vtable vtable)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
((krb5_pwqual_vtable)vtable)->name = "blt2";
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
static krb5_error_code
|
|
Packit |
fd8b60 |
blt3(krb5_context context, int maj_ver, int min_ver, krb5_plugin_vtable vtable)
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
((krb5_pwqual_vtable)vtable)->name = "blt3";
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
int
|
|
Packit |
fd8b60 |
main()
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
krb5_plugin_initvt_fn *modules = NULL, *mod;
|
|
Packit |
fd8b60 |
struct krb5_pwqual_vtable_st vt;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
check(krb5_init_context(&ctx));
|
|
Packit |
fd8b60 |
check(k5_plugin_register(ctx, PLUGIN_INTERFACE_PWQUAL, "blt1", blt1));
|
|
Packit |
fd8b60 |
check(k5_plugin_register(ctx, PLUGIN_INTERFACE_PWQUAL, "blt2", blt2));
|
|
Packit |
fd8b60 |
check(k5_plugin_register(ctx, PLUGIN_INTERFACE_PWQUAL, "blt3", blt3));
|
|
Packit |
fd8b60 |
check(k5_plugin_load_all(ctx, PLUGIN_INTERFACE_PWQUAL, &modules));
|
|
Packit |
fd8b60 |
for (mod = modules; *mod != NULL; mod++) {
|
|
Packit |
fd8b60 |
check((*mod)(ctx, 1, 1, (krb5_plugin_vtable)&vt));
|
|
Packit |
fd8b60 |
printf("%s\n", vt.name);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
k5_plugin_free_modules(ctx, modules);
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|