|
Packit Service |
3749ba |
/*
|
|
Packit Service |
3749ba |
* Copyright (c) 2012 Red Hat Inc
|
|
Packit Service |
3749ba |
*
|
|
Packit Service |
3749ba |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
3749ba |
* modification, are permitted provided that the following conditions
|
|
Packit Service |
3749ba |
* are met:
|
|
Packit Service |
3749ba |
*
|
|
Packit Service |
3749ba |
* * Redistributions of source code must retain the above
|
|
Packit Service |
3749ba |
* copyright notice, this list of conditions and the
|
|
Packit Service |
3749ba |
* following disclaimer.
|
|
Packit Service |
3749ba |
* * Redistributions in binary form must reproduce the
|
|
Packit Service |
3749ba |
* above copyright notice, this list of conditions and
|
|
Packit Service |
3749ba |
* the following disclaimer in the documentation and/or
|
|
Packit Service |
3749ba |
* other materials provided with the distribution.
|
|
Packit Service |
3749ba |
* * The names of contributors to this software may not be
|
|
Packit Service |
3749ba |
* used to endorse or promote products derived from this
|
|
Packit Service |
3749ba |
* software without specific prior written permission.
|
|
Packit Service |
3749ba |
*
|
|
Packit Service |
3749ba |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit Service |
3749ba |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit Service |
3749ba |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
Packit Service |
3749ba |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
Packit Service |
3749ba |
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
Packit Service |
3749ba |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
Packit Service |
3749ba |
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
Packit Service |
3749ba |
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
Packit Service |
3749ba |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit Service |
3749ba |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
Packit Service |
3749ba |
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
Packit Service |
3749ba |
* DAMAGE.
|
|
Packit Service |
3749ba |
*
|
|
Packit Service |
3749ba |
* Author: Stef Walter <stefw@redhat.com>
|
|
Packit Service |
3749ba |
*/
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
#include "config.h"
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
#include <assert.h>
|
|
Packit Service |
3749ba |
#include <stdio.h>
|
|
Packit Service |
3749ba |
#include <stdlib.h>
|
|
Packit Service |
3749ba |
#include <string.h>
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
#include "compat.h"
|
|
Packit Service |
3749ba |
#include "p11-kit.h"
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
int
|
|
Packit Service |
3749ba |
main (void)
|
|
Packit Service |
3749ba |
{
|
|
Packit Service |
3749ba |
CK_FUNCTION_LIST **modules;
|
|
Packit Service |
3749ba |
CK_FUNCTION_LIST *module;
|
|
Packit Service |
3749ba |
char *field;
|
|
Packit Service |
3749ba |
char *name;
|
|
Packit Service |
3749ba |
int ret;
|
|
Packit Service |
3749ba |
int i;
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
/*
|
|
Packit Service |
3749ba |
* Use 'chmod ug+s frob-setuid' to change this program
|
|
Packit Service |
3749ba |
* and test the output with/without setuid or setgid.
|
|
Packit Service |
3749ba |
*/
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
putenv ("P11_KIT_STRICT=1");
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
modules = p11_kit_modules_load_and_initialize (0);
|
|
Packit Service |
3749ba |
assert (modules != NULL);
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
/* This is a system configured module */
|
|
Packit Service |
3749ba |
module = p11_kit_module_for_name (modules, "one");
|
|
Packit Service |
3749ba |
assert (module != NULL);
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
field = p11_kit_config_option (module, "setting");
|
|
Packit Service |
3749ba |
printf ("'setting' on module 'one': %s\n", field ? field : "(null)");
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
assert (field != NULL);
|
|
Packit Service |
3749ba |
if (getauxval (AT_SECURE))
|
|
Packit Service |
3749ba |
assert (strcmp (field, "system1") == 0);
|
|
Packit Service |
3749ba |
else
|
|
Packit Service |
3749ba |
assert (strcmp (field, "user1") == 0);
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
free (field);
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
for (i = 0; modules[i] != NULL; i++) {
|
|
Packit Service |
3749ba |
name = p11_kit_module_get_name (modules[i]);
|
|
Packit Service |
3749ba |
printf ("%s\n", name);
|
|
Packit Service |
3749ba |
free (name);
|
|
Packit Service |
3749ba |
}
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
field = p11_kit_config_option (module, "number");
|
|
Packit Service |
3749ba |
printf ("'number' on module 'one': %s\n", field ? field : "(null)");
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
ret = atoi (field ? field : "0");
|
|
Packit Service |
3749ba |
assert (ret != 0);
|
|
Packit Service |
3749ba |
free (field);
|
|
Packit Service |
3749ba |
|
|
Packit Service |
3749ba |
p11_kit_modules_finalize_and_release (modules);
|
|
Packit Service |
3749ba |
return ret;
|
|
Packit Service |
3749ba |
}
|