(parse_attributes): make empty string mean no attributes, specifying

the empty string at the command line should give you no attributes,
but just pressing return at the prompt gives you default attributes
(edit_entry): only pick up values from the default principal if they
aren't set in the principal being edited


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9473 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2001-01-11 23:07:29 +00:00
parent ba7854d948
commit 0fbfbb5860

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -103,9 +103,7 @@ parse_attributes (const char *resp, krb5_flags *attr, int *mask, int bit)
{ {
krb5_flags tmp = *attr; krb5_flags tmp = *attr;
if (resp[0] == '\0') if (str2attributes(resp, &tmp) == 0) {
return 0;
else if (str2attributes(resp, &tmp) == 0) {
*attr = tmp; *attr = tmp;
if (mask) if (mask)
*mask |= bit; *mask |= bit;
@@ -133,6 +131,8 @@ edit_attributes (const char *prompt, krb5_flags *attr, int *mask, int bit)
attributes2str(*attr, buf, sizeof(buf)); attributes2str(*attr, buf, sizeof(buf));
for (;;) { for (;;) {
get_response("Attributes", buf, resp, sizeof(resp)); get_response("Attributes", buf, resp, sizeof(resp));
if (resp[0] == '\0')
break;
if (parse_attributes (resp, attr, mask, bit) == 0) if (parse_attributes (resp, attr, mask, bit) == 0)
break; break;
} }
@@ -342,27 +342,37 @@ int
edit_entry(kadm5_principal_ent_t ent, int *mask, edit_entry(kadm5_principal_ent_t ent, int *mask,
kadm5_principal_ent_t default_ent, int default_mask) kadm5_principal_ent_t default_ent, int default_mask)
{ {
if (default_ent && (default_mask & KADM5_MAX_LIFE)) if (default_ent
&& (default_mask & KADM5_MAX_LIFE)
&& !(*mask & KADM5_MAX_LIFE))
ent->max_life = default_ent->max_life; ent->max_life = default_ent->max_life;
edit_deltat ("Max ticket life", &ent->max_life, mask, edit_deltat ("Max ticket life", &ent->max_life, mask,
KADM5_MAX_LIFE); KADM5_MAX_LIFE);
if (default_ent && (default_mask & KADM5_MAX_RLIFE)) if (default_ent
&& (default_mask & KADM5_MAX_RLIFE)
&& !(*mask & KADM5_MAX_RLIFE))
ent->max_renewable_life = default_ent->max_renewable_life; ent->max_renewable_life = default_ent->max_renewable_life;
edit_deltat ("Max renewable life", &ent->max_renewable_life, mask, edit_deltat ("Max renewable life", &ent->max_renewable_life, mask,
KADM5_MAX_RLIFE); KADM5_MAX_RLIFE);
if (default_ent && (default_mask & KADM5_PRINC_EXPIRE_TIME)) if (default_ent
&& (default_mask & KADM5_PRINC_EXPIRE_TIME)
&& !(*mask & KADM5_PRINC_EXPIRE_TIME))
ent->princ_expire_time = default_ent->princ_expire_time; ent->princ_expire_time = default_ent->princ_expire_time;
edit_timet ("Principal expiration time", &ent->princ_expire_time, mask, edit_timet ("Principal expiration time", &ent->princ_expire_time, mask,
KADM5_PRINC_EXPIRE_TIME); KADM5_PRINC_EXPIRE_TIME);
if (default_ent && (default_mask & KADM5_PW_EXPIRATION)) if (default_ent
&& (default_mask & KADM5_PW_EXPIRATION)
&& !(*mask & KADM5_PW_EXPIRATION))
ent->pw_expiration = default_ent->pw_expiration; ent->pw_expiration = default_ent->pw_expiration;
edit_timet ("Password expiration time", &ent->pw_expiration, mask, edit_timet ("Password expiration time", &ent->pw_expiration, mask,
KADM5_PW_EXPIRATION); KADM5_PW_EXPIRATION);
if (default_ent && (default_mask & KADM5_ATTRIBUTES)) if (default_ent
&& (default_mask & KADM5_ATTRIBUTES)
&& !(*mask & KADM5_ATTRIBUTES))
ent->attributes = default_ent->attributes & ~KRB5_KDB_DISALLOW_ALL_TIX; ent->attributes = default_ent->attributes & ~KRB5_KDB_DISALLOW_ALL_TIX;
edit_attributes ("Attributes", &ent->attributes, mask, edit_attributes ("Attributes", &ent->attributes, mask,
KADM5_ATTRIBUTES); KADM5_ATTRIBUTES);