add a --use-defaults option to just use default values without questions

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10459 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2001-08-10 08:08:22 +00:00
parent a93665b3fd
commit bd603d56fa

View File

@@ -67,6 +67,7 @@ static krb5_error_code
add_one_principal (const char *name, add_one_principal (const char *name,
int rand_key, int rand_key,
int rand_password, int rand_password,
int use_defaults,
char *password, char *password,
krb5_key_data *key_data, krb5_key_data *key_data,
const char *max_ticket_life, const char *max_ticket_life,
@@ -108,7 +109,10 @@ add_one_principal (const char *name,
KADM5_PRINC_EXPIRE_TIME | KADM5_PW_EXPIRATION; KADM5_PRINC_EXPIRE_TIME | KADM5_PW_EXPIRATION;
} }
edit_entry(&princ, &mask, default_ent, default_mask); if(use_defaults)
set_defaults(&princ, &mask, default_ent, default_mask);
else
edit_entry(&princ, &mask, default_ent, default_mask);
if(rand_key || key_data) { if(rand_key || key_data) {
princ.attributes |= KRB5_KDB_DISALLOW_ALL_TIX; princ.attributes |= KRB5_KDB_DISALLOW_ALL_TIX;
mask |= KADM5_ATTRIBUTES; mask |= KADM5_ATTRIBUTES;
@@ -200,10 +204,11 @@ static struct getargs args[] = {
"max renewable lifetime", "lifetime" }, "max renewable lifetime", "lifetime" },
{ "attributes", 0, arg_string, NULL, "principal attributes", { "attributes", 0, arg_string, NULL, "principal attributes",
"attributes"}, "attributes"},
{ "expiration-time",0, arg_string, NULL, "Expiration time", { "expiration-time",0, arg_string, NULL, "expiration time",
"time"}, "time"},
{ "pw-expiration-time", 0, arg_string, NULL, { "pw-expiration-time", 0, arg_string, NULL,
"Password expiration time", "time"} "password expiration time", "time"},
{ "use-defaults", 0, arg_flag, NULL, "use default values" }
}; };
static int num_args = sizeof(args) / sizeof(args[0]); static int num_args = sizeof(args) / sizeof(args[0]);
@@ -232,6 +237,7 @@ add_new_key(int argc, char **argv)
char *attributes = NULL; char *attributes = NULL;
char *expiration = NULL; char *expiration = NULL;
char *pw_expiration = NULL; char *pw_expiration = NULL;
int use_defaults = 0;
int i; int i;
int num; int num;
krb5_key_data key_data[3]; krb5_key_data key_data[3];
@@ -246,6 +252,7 @@ add_new_key(int argc, char **argv)
args[6].value = &attributes; args[6].value = &attributes;
args[7].value = &expiration; args[7].value = &expiration;
args[8].value = &pw_expiration; args[8].value = &pw_expiration;
args[9].value = &use_defaults;
if(getarg(args, num_args, argc, argv, &optind)) { if(getarg(args, num_args, argc, argv, &optind)) {
usage (); usage ();
@@ -284,6 +291,7 @@ add_new_key(int argc, char **argv)
for (i = optind; i < argc; ++i) { for (i = optind; i < argc; ++i) {
ret = add_one_principal (argv[i], random_key, random_password, ret = add_one_principal (argv[i], random_key, random_password,
use_defaults,
password, password,
kdp, kdp,
max_ticket_life, max_ticket_life,