|
Packit Service |
99d1c0 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit Service |
99d1c0 |
/* tests/gssapi/ccrefresh.c - Get or set refresh time on a ccache */
|
|
Packit Service |
99d1c0 |
/*
|
|
Packit Service |
99d1c0 |
* Copyright (C) 2012 by the Massachusetts Institute of Technology.
|
|
Packit Service |
99d1c0 |
* All rights reserved.
|
|
Packit Service |
99d1c0 |
*
|
|
Packit Service |
99d1c0 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
99d1c0 |
* modification, are permitted provided that the following conditions
|
|
Packit Service |
99d1c0 |
* are met:
|
|
Packit Service |
99d1c0 |
*
|
|
Packit Service |
99d1c0 |
* * Redistributions of source code must retain the above copyright
|
|
Packit Service |
99d1c0 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
99d1c0 |
*
|
|
Packit Service |
99d1c0 |
* * Redistributions in binary form must reproduce the above copyright
|
|
Packit Service |
99d1c0 |
* notice, this list of conditions and the following disclaimer in
|
|
Packit Service |
99d1c0 |
* the documentation and/or other materials provided with the
|
|
Packit Service |
99d1c0 |
* distribution.
|
|
Packit Service |
99d1c0 |
*
|
|
Packit Service |
99d1c0 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit Service |
99d1c0 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit Service |
99d1c0 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
Packit Service |
99d1c0 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
Packit Service |
99d1c0 |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
Packit Service |
99d1c0 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
Packit Service |
99d1c0 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit Service |
99d1c0 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
Packit Service |
99d1c0 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
Packit Service |
99d1c0 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit Service |
99d1c0 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
Packit Service |
99d1c0 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
99d1c0 |
*/
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
/*
|
|
Packit Service |
99d1c0 |
* This program sets the refresh time of an existing ccache to 1, forcing a
|
|
Packit Service |
99d1c0 |
* refresh.
|
|
Packit Service |
99d1c0 |
*/
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
#include "k5-int.h"
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
static void
|
|
Packit Service |
99d1c0 |
check(krb5_error_code code)
|
|
Packit Service |
99d1c0 |
{
|
|
Packit Service |
99d1c0 |
if (code != 0) {
|
|
Packit Service |
99d1c0 |
com_err("ccrefresh", code, NULL);
|
|
Packit Service |
99d1c0 |
abort();
|
|
Packit Service |
99d1c0 |
}
|
|
Packit Service |
99d1c0 |
}
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
int
|
|
Packit Service |
99d1c0 |
main(int argc, char **argv)
|
|
Packit Service |
99d1c0 |
{
|
|
Packit Service |
99d1c0 |
const char *ccname, *value = NULL;
|
|
Packit Service |
99d1c0 |
krb5_context context;
|
|
Packit Service |
99d1c0 |
krb5_ccache ccache;
|
|
Packit Service |
99d1c0 |
krb5_data d;
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
if (argc != 2 && argc != 3) {
|
|
Packit Service |
99d1c0 |
fprintf(stderr, "Usage: %s ccname [value]\n", argv[0]);
|
|
Packit Service |
99d1c0 |
return 1;
|
|
Packit Service |
99d1c0 |
}
|
|
Packit Service |
99d1c0 |
ccname = argv[1];
|
|
Packit Service |
99d1c0 |
if (argc == 3)
|
|
Packit Service |
99d1c0 |
value = argv[2];
|
|
Packit Service |
99d1c0 |
|
|
Packit Service |
99d1c0 |
check(krb5_init_context(&context));
|
|
Packit Service |
99d1c0 |
check(krb5_cc_resolve(context, ccname, &ccache));
|
|
Packit Service |
99d1c0 |
if (value != NULL) {
|
|
Packit Service |
99d1c0 |
d = string2data((char *)value);
|
|
Packit Service |
99d1c0 |
check(krb5_cc_set_config(context, ccache, NULL,
|
|
Packit Service |
99d1c0 |
KRB5_CC_CONF_REFRESH_TIME, &d);;
|
|
Packit Service |
99d1c0 |
} else {
|
|
Packit Service |
99d1c0 |
check(krb5_cc_get_config(context, ccache, NULL,
|
|
Packit Service |
99d1c0 |
KRB5_CC_CONF_REFRESH_TIME, &d);;
|
|
Packit Service |
99d1c0 |
printf("%.*s\n", (int)d.length, d.data);
|
|
Packit Service |
99d1c0 |
krb5_free_data_contents(context, &d);
|
|
Packit Service |
99d1c0 |
}
|
|
Packit Service |
99d1c0 |
krb5_cc_close(context, ccache);
|
|
Packit Service |
99d1c0 |
krb5_free_context(context);
|
|
Packit Service |
99d1c0 |
return 0;
|
|
Packit Service |
99d1c0 |
}
|