use new krb5_config_get-functions

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2998 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1997-08-15 07:03:08 +00:00
parent 57e9268ff5
commit 9954fc4d14

View File

@@ -40,39 +40,44 @@
RCSID("$Id$"); RCSID("$Id$");
static const char * static int
get_config_string (krb5_context context, get_config_time (krb5_context context,
char *realm, char *realm,
char *name, char *name,
const char *def) int def)
{ {
const char *ret; int ret;
ret = krb5_config_get_string (context->cf, ret = krb5_config_get_time (context->cf,
"libdefaults", "realms",
realm, realm,
name, name,
NULL); NULL);
if (ret) if (ret >= 0)
return ret; return ret;
ret = krb5_config_get_string (context->cf, ret = krb5_config_get_time (context->cf,
"libdefaults", "libdefaults",
name, name,
NULL); NULL);
if (ret) if (ret >= 0)
return ret; return ret;
return def; return def;
} }
static int static krb5_boolean
ison (const char *s) get_config_bool (krb5_context context,
char *realm,
char *name)
{ {
return strcasecmp (s, "y") == 0 return krb5_config_get_bool (context->cf,
|| strcasecmp (s, "yes") == 0 "realms",
|| strcasecmp (s, "t") == 0 realm,
|| strcasecmp (s, "true") == 0 name,
|| strcasecmp (s, "1") == 0 NULL)
|| strcasecmp (s, "on") == 0; || krb5_config_get_bool (context->cf,
"libdefaults",
name,
NULL);
} }
static krb5_error_code static krb5_error_code
@@ -109,22 +114,20 @@ init_cred (krb5_context context,
if (options->flags & KRB5_GET_INIT_CREDS_OPT_TKT_LIFE) if (options->flags & KRB5_GET_INIT_CREDS_OPT_TKT_LIFE)
tmp = options->tkt_life; tmp = options->tkt_life;
else else
tmp = parse_time(get_config_string (context, tmp = get_config_time (context,
*client_realm, *client_realm,
"ticket_lifetime", "ticket_lifetime",
"10h"), 10 * 60 * 60);
NULL);
cred->times.endtime = now + tmp; cred->times.endtime = now + tmp;
tmp = 0; tmp = 0;
if (options->flags & KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE) if (options->flags & KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE)
tmp = options->renew_life; tmp = options->renew_life;
else else
tmp = parse_time(get_config_string (context, tmp = get_config_time (context,
*client_realm, *client_realm,
"renew_lifetime", "renew_lifetime",
"0"), 0);
NULL);
if (tmp) if (tmp)
cred->times.renew_till = now + tmp; cred->times.renew_till = now + tmp;
@@ -168,11 +171,10 @@ print_expire (krb5_context context,
krb5_timeofday (context, &sec); krb5_timeofday (context, &sec);
t = sec + parse_time(get_config_string (context, t = sec + get_config_time (context,
*realm, *realm,
"warn_pwexpire", "warn_pwexpire",
"1 week"), 7 * 24 * 60 * 60);
NULL);
for (i = 0; i < lr->len; ++i) { for (i = 0; i < lr->len; ++i) {
if (lr->val[i].lr_type == 6 if (lr->val[i].lr_type == 6
@@ -226,18 +228,16 @@ get_init_creds_common(krb5_context context,
if (options->flags & KRB5_GET_INIT_CREDS_OPT_FORWARDABLE) if (options->flags & KRB5_GET_INIT_CREDS_OPT_FORWARDABLE)
flags->b.forwardable = 1; flags->b.forwardable = 1;
else else
flags->b.forwardable = ison(get_config_string (context, flags->b.forwardable = get_config_bool (context,
*client_realm, *client_realm,
"forwardable", "forwardable");
"no"));
if (options->flags & KRB5_GET_INIT_CREDS_OPT_PROXIABLE) if (options->flags & KRB5_GET_INIT_CREDS_OPT_PROXIABLE)
flags->b.proxiable = 1; flags->b.proxiable = 1;
else else
flags->b.proxiable = ison(get_config_string (context, flags->b.proxiable = get_config_bool (context,
*client_realm, *client_realm,
"proxiable", "proxiable");
"no"));
if (cred->times.renew_till) if (cred->times.renew_till)
flags->b.renewable = 1; flags->b.renewable = 1;