convert to use slc; also add stash subcommand

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13970 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2004-06-21 19:19:45 +00:00
parent 3cc8ea1b60
commit d7f9fac88e
18 changed files with 646 additions and 608 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997-2002 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997-2004 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -197,84 +197,32 @@ out:
* the ank command
*/
static struct getargs args[] = {
{ "random-key", 'r', arg_flag, NULL, "set random key" },
{ "random-password", 0, arg_flag, NULL, "set random password" },
{ "password", 'p', arg_string, NULL, "princial's password" },
{ "key", 0, arg_string, NULL, "DES-key in hex" },
{ "max-ticket-life", 0, arg_string, NULL, "max ticket lifetime",
"lifetime"},
{ "max-renewable-life", 0, arg_string, NULL,
"max renewable lifetime", "lifetime" },
{ "attributes", 0, arg_string, NULL, "principal attributes",
"attributes"},
{ "expiration-time",0, arg_string, NULL, "expiration time",
"time"},
{ "pw-expiration-time", 0, arg_string, NULL,
"password expiration time", "time"},
{ "use-defaults", 0, arg_flag, NULL, "use default values" }
};
static int num_args = sizeof(args) / sizeof(args[0]);
static void
usage(void)
{
arg_printusage (args, num_args, "add", "principal...");
}
/*
* Parse arguments and add all the principals.
*/
int
add_new_key(int argc, char **argv)
add_new_key(struct add_options *opt, int argc, char **argv)
{
char *password = NULL;
char *key = NULL;
int random_key = 0;
int random_password = 0;
int optind = 0;
krb5_error_code ret;
char *max_ticket_life = NULL;
char *max_renewable_life = NULL;
char *attributes = NULL;
char *expiration = NULL;
char *pw_expiration = NULL;
int use_defaults = 0;
int i;
int num;
krb5_key_data key_data[3];
krb5_key_data *kdp = NULL;
args[0].value = &random_key;
args[1].value = &random_password;
args[2].value = &password;
args[3].value = &key;
args[4].value = &max_ticket_life;
args[5].value = &max_renewable_life;
args[6].value = &attributes;
args[7].value = &expiration;
args[8].value = &pw_expiration;
args[9].value = &use_defaults;
if(getarg(args, num_args, argc, argv, &optind)) {
usage ();
return 0;
}
if(optind == argc) {
usage ();
printf("foo\n");
return 0;
}
num = 0;
if (random_key)
if (opt->random_key_flag)
++num;
if (random_password)
if (opt->random_password_flag)
++num;
if (password)
if (opt->password_string)
++num;
if (key)
if (opt->key_string)
++num;
if (num > 1) {
@@ -283,26 +231,28 @@ add_new_key(int argc, char **argv)
return 0;
}
if (key) {
if (opt->key_string) {
const char *error;
if (parse_des_key (key, key_data, &error)) {
printf ("failed parsing key `%s': %s\n", key, error);
if (parse_des_key (opt->key_string, key_data, &error)) {
printf ("failed parsing key `%s': %s\n", opt->key_string, error);
return 0;
}
kdp = key_data;
}
for (i = optind; i < argc; ++i) {
ret = add_one_principal (argv[i], random_key, random_password,
use_defaults,
password,
ret = add_one_principal (argv[i],
opt->random_key_flag,
opt->random_password_flag,
opt->use_defaults_flag,
opt->password_string,
kdp,
max_ticket_life,
max_renewable_life,
attributes,
expiration,
pw_expiration);
opt->max_ticket_life_string,
opt->max_renewable_life_string,
opt->attributes_string,
opt->expiration_time_string,
opt->pw_expiration_time_string);
if (ret) {
krb5_warn (context, ret, "adding %s", argv[i]);
break;