diff --git a/kuser/Makefile.am b/kuser/Makefile.am index d21a92f9e..043f33caa 100644 --- a/kuser/Makefile.am +++ b/kuser/Makefile.am @@ -15,10 +15,10 @@ man_MANS = \ kgetcred.1 \ kimpersonate.8 -bin_PROGRAMS = kinit klist kdestroy kgetcred kswitch +bin_PROGRAMS = kinit kdestroy kgetcred kswitch kcc libexec_PROGRAMS = kdigest kimpersonate -noinst_PROGRAMS = kcc kverify kdecode_ticket generate-requests copy_cred_cache +noinst_PROGRAMS = kverify kdecode_ticket generate-requests copy_cred_cache kinit_LDADD = \ $(LIB_kafs) \ @@ -31,8 +31,6 @@ kinit_LDADD = \ kdestroy_LDADD = $(kinit_LDADD) -klist_LDADD = $(kinit_LDADD) - kimpersonate_LDADD = $(kinit_LDADD) kswitch_LDADD = $(kinit_LDADD) $(LIB_readline) @@ -41,7 +39,7 @@ kcc_LDADD = \ $(top_builddir)/lib/sl/libsl.la \ $(kinit_LDADD) -dist_kcc_SOURCES = kcc.c +dist_kcc_SOURCES = kcc.c klist.c nodist_kcc_SOURCES = kcc-commands.c $(kcc_OBJECTS): kcc-commands.h @@ -78,3 +76,7 @@ LDADD = \ EXTRA_DIST = $(man_MANS) \ kuser_locl.h kcc-commands.in kdigest-commands.in copy_cred_cache.1 +# make sure install-exec-hook doesn't have any commands in Makefile.am.common +install-exec-hook: + (cd $(DESTDIR)$(bindir) && rm -f klist && $(LN_S) kcc klist) + diff --git a/kuser/kcc-commands.in b/kuser/kcc-commands.in index e8736a3f4..5e2b3e2c6 100644 --- a/kuser/kcc-commands.in +++ b/kuser/kcc-commands.in @@ -41,6 +41,69 @@ command = { type = "string" help = "credential cache to list" } + option = { + name = "flags" + short = "f" + type = "flag" + help = "list flags" + } + option = { + long = "test" + short = "t" + type = "flag" + help = "test for having tickets" + } + option = { + name = "s" + short = "s" + type = "flag" + } + option = { + long = "tokens" + short = "T" + type = "flag" + help = "display AFS tokens" + } + option = { + long = "v5" + short = "5" + type = "flag" + default = "1" + help = "display v5 credential tokens" + } + option = { + long = "all-content" + short = "A" + type = "flag" + help = "List all caches with their content" + } + option = { + long = "list-all" + short = "l" + type = "flag" + help = "List all caches" + } + option = { + long = "verbose" + short = "v" + type = "flag" + help = "Verbose output" + } + option = { + name = "a" + short = "a" + type = "flag" + } + option = { + name = "n" + short = "n" + type = "flag" + } + option = { + long = "hidden" + type = "flag" + help = "Verbose output" + } } command = { name = "kgetcred" diff --git a/kuser/kcc.c b/kuser/kcc.c index cbf4246b1..fde4d4c10 100644 --- a/kuser/kcc.c +++ b/kuser/kcc.c @@ -63,12 +63,6 @@ help(void *opt, int argc, char **argv) return 0; } -int -klist(struct klist_options *opt, int argc, char **argv) -{ - return 0; -} - int kgetcred(struct kgetcred_options *opt, int argc, char **argv) { @@ -115,8 +109,8 @@ main(int argc, char **argv) setprogname (argv[0]); setlocale (LC_ALL, ""); - bindtextdomain ("heimdal_kcc", HEIMDAL_LOCALEDIR); - textdomain("heimdal_kcc"); + bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR); + textdomain("heimdal_kuser"); ret = krb5_init_context(&kcc_context); if (ret == KRB5_CONFIG_BADFORMAT) @@ -147,7 +141,7 @@ main(int argc, char **argv) } } else { - argv[0] = getprogname(); + argv[0] = rk_UNCONST(getprogname()); } argc -= optidx; diff --git a/kuser/klist.c b/kuser/klist.c index 3e76c4a5a..aef1cf9b2 100644 --- a/kuser/klist.c +++ b/kuser/klist.c @@ -36,6 +36,7 @@ #include "kuser_locl.h" #include "rtbl.h" #include "parse_units.h" +#include "kcc-commands.h" static char* printable_time(time_t t) @@ -559,147 +560,69 @@ list_caches(krb5_context context) * */ -static int version_flag = 0; -static int help_flag = 0; -static int do_verbose = 0; -static int do_list_caches = 0; -static int do_all_content = 0; -static int do_test = 0; -#ifndef NO_AFS -static int do_tokens = 0; -#endif -static int do_v5 = 1; -static char *cred_cache; -static int do_flags = 0; -static int do_hidden = 0; - -static struct getargs args[] = { - { NULL, 'f', arg_flag, &do_flags }, - { "cache", 'c', arg_string, &cred_cache, - NP_("credentials cache to list", ""), "cache" }, - { "test", 't', arg_flag, &do_test, - NP_("test for having tickets", ""), NULL }, - { NULL, 's', arg_flag, &do_test }, -#ifndef NO_AFS - { "tokens", 'T', arg_flag, &do_tokens, - NP_("display AFS tokens", ""), NULL }, -#endif - { "v5", '5', arg_flag, &do_v5, - NP_("display v5 cred cache", ""), NULL}, - { "all-content", 'A', arg_flag, &do_all_content, - NP_("all caches with their content", ""), NULL }, - { "list-caches", 'l', arg_flag, &do_list_caches, - NP_("list all caches", ""), NULL }, - { "verbose", 'v', arg_flag, &do_verbose, - NP_("verbose output", ""), NULL }, - { "hidden", 0, arg_flag, &do_hidden, - NP_("display hidden credentials", ""), NULL }, - { NULL, 'a', arg_flag, &do_verbose }, - { NULL, 'n', arg_flag, &do_verbose }, - { "version", 0, arg_flag, &version_flag, - NP_("print version", ""), NULL }, - { "help", 0, arg_flag, &help_flag, - NULL, NULL} -}; - -static void -usage (int ret) -{ - arg_printusage_i18n (args, - sizeof(args)/sizeof(*args), - N_("Usage: ", ""), - NULL, - "", - getarg_i18n); - exit (ret); -} - int -main (int argc, char **argv) +klist(struct klist_options *opt, int argc, char **argv) { - krb5_context context; krb5_error_code ret; - int optidx = 0; int exit_status = 0; - setprogname (argv[0]); + int do_verbose = + opt->verbose_flag || + opt->a_flag || + opt->n_flag; + int do_test = + opt->test_flag || + opt->s_flag; - setlocale (LC_ALL, ""); - bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR); - textdomain("heimdal_kuser"); - - if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx)) - usage(1); - - if (help_flag) - usage (0); - - if(version_flag){ - print_version(NULL); - exit(0); - } - - argc -= optidx; - - if (argc != 0) - usage (1); - - ret = krb5_init_context (&context); - if (ret) - errx (1, "krb5_init_context failed: %d", ret); - - - if (do_list_caches) { - exit_status = list_caches(context); + if (opt->list_all_flag) { + exit_status = list_caches(kcc_context); return exit_status; } - if (do_v5) { + if (opt->v5_flag) { krb5_ccache id; - if (do_all_content) { + if (opt->all_content_flag) { krb5_cc_cache_cursor cursor; - ret = krb5_cc_cache_get_first (context, NULL, &cursor); + ret = krb5_cc_cache_get_first(kcc_context, NULL, &cursor); if (ret) - krb5_err (context, 1, ret, "krb5_cc_cache_get_first"); + krb5_err(kcc_context, 1, ret, "krb5_cc_cache_get_first"); - while (krb5_cc_cache_next (context, cursor, &id) == 0) { - exit_status |= display_v5_ccache(context, id, do_test, - do_verbose, do_flags, - do_hidden); + while (krb5_cc_cache_next(kcc_context, cursor, &id) == 0) { + exit_status |= display_v5_ccache(kcc_context, id, do_test, + do_verbose, opt->flags_flag, + opt->hidden_flag); printf("\n\n"); } - krb5_cc_cache_end_seq_get(context, cursor); + krb5_cc_cache_end_seq_get(kcc_context, cursor); } else { - if(cred_cache) { - ret = krb5_cc_resolve(context, cred_cache, &id); + if(opt->cache_string) { + ret = krb5_cc_resolve(kcc_context, opt->cache_string, &id); if (ret) - krb5_err (context, 1, ret, "%s", cred_cache); + krb5_err(kcc_context, 1, ret, "%s", opt->cache_string); } else { - ret = krb5_cc_default (context, &id); + ret = krb5_cc_default(kcc_context, &id); if (ret) - krb5_err (context, 1, ret, "krb5_cc_resolve"); + krb5_err(kcc_context, 1, ret, "krb5_cc_resolve"); } - exit_status = display_v5_ccache(context, id, do_test, - do_verbose, do_flags, - do_hidden); + exit_status = display_v5_ccache(kcc_context, id, do_test, + do_verbose, opt->flags_flag, + opt->hidden_flag); } } if (!do_test) { #ifndef NO_AFS - if (do_tokens && k_hasafs ()) { - if (do_v5) - printf ("\n"); - display_tokens (do_verbose); + if (opt->tokens_flag && k_hasafs()) { + if (opt->v5_flag) + printf("\n"); + display_tokens(opt->verbose_flag); } #endif } - krb5_free_context(context); - return exit_status; } diff --git a/kuser/kuser_locl.h b/kuser/kuser_locl.h index ead88e606..82e6eb2e2 100644 --- a/kuser/kuser_locl.h +++ b/kuser/kuser_locl.h @@ -103,5 +103,6 @@ #define textdomain(package) #endif +extern krb5_context kcc_context; #endif /* __KUSER_LOCL_H__ */