diff options
Diffstat (limited to 'crypto/heimdal/kadmin/kadmin.c')
-rw-r--r-- | crypto/heimdal/kadmin/kadmin.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/crypto/heimdal/kadmin/kadmin.c b/crypto/heimdal/kadmin/kadmin.c index 6d29d63..5a21ffb 100644 --- a/crypto/heimdal/kadmin/kadmin.c +++ b/crypto/heimdal/kadmin/kadmin.c @@ -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). * All rights reserved. * @@ -34,7 +34,7 @@ #include "kadmin_locl.h" #include <sl.h> -RCSID("$Id: kadmin.c,v 1.27 2000/01/31 23:51:52 assar Exp $"); +RCSID("$Id: kadmin.c,v 1.34 2001/01/26 22:20:52 joda Exp $"); static char *config_file; static char *keyfile; @@ -141,6 +141,7 @@ static SL_cmd commands[] = { "privileges", get_privs, "privileges", "Shows which kinds of operations you are allowed to perform." }, + { "privs" }, { "list", list_princs, "list expression...", "Lists principals in a terse format. The same as `get -t'." @@ -148,16 +149,19 @@ static SL_cmd commands[] = { { "help", help, "help"}, { "?"}, { "exit", exit_kadmin, "exit"}, + { "quit" }, { NULL} }; krb5_context context; void *kadm_handle; +static SL_cmd *actual_cmds; + int help(int argc, char **argv) { - sl_help(commands, argc, argv); + sl_help(actual_cmds, argc, argv); return 0; } @@ -181,6 +185,24 @@ get_privs(int argc, char **argv) char str[128]; kadm5_ret_t ret; + int help_flag = 0; + struct getargs args[] = { + { "help", 'h', arg_flag, NULL } + }; + int num_args = sizeof(args) / sizeof(args[0]); + int optind = 0; + + args[0].value = &help_flag; + + if(getarg(args, num_args, argc, argv, &optind)) { + arg_printusage (args, num_args, "privileges", NULL); + return 0; + } + if(help_flag) { + arg_printusage (args, num_args, "privileges", NULL); + return 0; + } + ret = kadm5_get_privs(kadm_handle, &privs); if(ret) krb5_warn(context, ret, "kadm5_get_privs"); @@ -199,14 +221,15 @@ main(int argc, char **argv) kadm5_config_params conf; int optind = 0; int e; - SL_cmd *cmd; set_progname(argv[0]); - krb5_init_context(&context); + ret = krb5_init_context(&context); + if (ret) + errx (1, "krb5_init_context failed: %d", ret); while((e = getarg(args, num_args, argc, argv, &optind))) - warnx("error at argument `%s'", argv[optind]); + errx(1, "error at argument `%s'", argv[optind]); if (help_flag) usage (0); @@ -254,7 +277,7 @@ main(int argc, char **argv) KADM5_ADMIN_SERVICE, &conf, 0, 0, &kadm_handle); - cmd = commands; + actual_cmds = commands; } else { ret = kadm5_c_init_with_password_ctx(context, client_name, @@ -262,17 +285,23 @@ main(int argc, char **argv) KADM5_ADMIN_SERVICE, &conf, 0, 0, &kadm_handle); - cmd = commands + 4; /* XXX */ + actual_cmds = commands + 4; /* XXX */ } if(ret) krb5_err(context, 1, ret, "kadm5_init_with_password"); + + signal(SIGINT, SIG_IGN); /* ignore signals for now, the sl command + parser will handle SIGINT its own way; + we should really take care of this in + each function, f.i `get' might be + interruptable, but not `create' */ if (argc != 0) { - ret = sl_command (cmd, argc, argv); + ret = sl_command (actual_cmds, argc, argv); if(ret == -1) krb5_warnx (context, "unrecognized command: %s", argv[0]); } else - ret = sl_loop (cmd, "kadmin> ") != 0; + ret = sl_loop (actual_cmds, "kadmin> ") != 0; kadm5_destroy(kadm_handle); krb5_config_file_free (context, cf); |