From 4771917b69129c0225feea34165ca0071346d348 Mon Sep 17 00:00:00 2001 From: Bill Sommerfeld Date: Sat, 3 Feb 1990 10:40:28 +0000 Subject: Initial revision git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@245 dc483132-0cff-0310-8789-dd5450dbe970 --- src/clients/kdestroy/kdestroy.c | 79 +++++++++++++++++++++++++ src/clients/kinit/kinit.c | 127 ++++++++++++++++++++++++++++++++++++++++ src/clients/klist/klist.c | 70 ++++++++++++++++++++++ src/prototype/getopt.c | 29 +++++++++ 4 files changed, 305 insertions(+) create mode 100644 src/clients/kdestroy/kdestroy.c create mode 100644 src/clients/kinit/kinit.c create mode 100644 src/clients/klist/klist.c create mode 100644 src/prototype/getopt.c diff --git a/src/clients/kdestroy/kdestroy.c b/src/clients/kdestroy/kdestroy.c new file mode 100644 index 0000000000..3e9e801c2b --- /dev/null +++ b/src/clients/kdestroy/kdestroy.c @@ -0,0 +1,79 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * Destroy the contents of your credential cache. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_klist_c [] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include + +#include +#include + +extern int optind; +extern char *optarg; + +main(argc, argv) + int argc; + char **argv; +{ + int c; + krb5_ccache cache = NULL; + char *cache_name = NULL; + int code; + int errflg=0; + + initialize_krb5_error_table(); + + while ((c = getopt(argc, argv, "c:")) != EOF) { + switch (c) { + case 'c': + if (cache == NULL) { + cache_name = optarg; + + code = krb5_cc_resolve (cache_name, &cache); + if (code != 0) { + com_err (argv[0], code, "while resolving %s", cache_name); + errflg++; + } + } else { + fprintf(stderr, "Only one -c option allowed\n"); + errflg++; + } + break; + case '?': + default: + errflg++; + break; + } + } + + if (optind != argc) + errflg++; + + if (errflg) { + fprintf(stderr, "Usage: %s [ -c cache-name ]\n", argv[0]); + exit(2); + } + + if (cache == NULL) + cache = krb5_cc_default (); + + code = krb5_cc_destroy (cache); + if (code != 0) { + com_err (argv[0], code, "while destroying cache"); + fprintf(stderr, "Ticket cache \007NOT\007 destroyed!\n"); + exit (1); + } + exit (0); +} diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c new file mode 100644 index 0000000000..b9fb6d4755 --- /dev/null +++ b/src/clients/kinit/kinit.c @@ -0,0 +1,127 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * Initialize a credentials cache. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_kinit_c [] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include + +#include +#include + +#define KRB5_DEFAULT_FLAGS 0 +#define KRB5_DEFAULT_LIFE 60*60*8 /* 8 hours */ + +extern int optind; +extern char *optarg; + +krb5_parse_lifetime (time, len) + char *time; + long *len; +{ + *len = atoi (time) * 60 * 60; /* XXX stub version */ +} + + +main(argc, argv) + int argc; + char **argv; +{ + krb5_ccache cache = NULL; + char *cache_name = NULL; /* -f option */ + long lifetime = KRB5_DEFAULT_LIFE; /* -l option */ + int flags = KRB5_DEFAULT_FLAGS; + int option; + int errflg = 0; + krb5_address **my_addresses; + int code; + krb5_principal me; + + /* + * XXX init error tables here + */ + while ((option = getopt(argc, argv, "rpl:c:")) != EOF) { + switch (option) { + case 'r': + flags |= KDC_OPT_RENEWABLE; + break; + case 'p': + flags |= KDC_OPT_PROXIABLE; + break; + case 'l': + code = krb5_parse_lifetime(optarg, &lifetime); + if (code != 0) { + fprintf(stderr, "Bad lifetime value %s\n", optarg); + errflg++; + } + break; + case 'c': + if (cache == NULL) { + cache_name = optarg; + + code = krb5_cc_resolve (cache_name, &cache); + if (code != 0) { + com_err (argv[0], code, "resolving %s", cache_name); + errflg++; + } + } else { + fprintf(stderr, "Only one -c option allowed\n"); + errflg++; + } + break; + case '?': + default: + errflg++; + break; + } + } + if (optind != argc-1) + errflg++; + + if (errflg) { + fprintf(stderr, "Usage: %s [ -rp ] [ -l lifetime ] [ -c cachename ] principal", argv[0]); + exit(2); + } + if (cache == NULL) + cache = krb5_cc_default(); + + krb5_parse_name (argv[optind], &me); + + code = krb5_cc_initialize (cache, me); + if (code != 0) { + com_err (argv[0], code, "when initializing cache %s", + cache_name?cache_name:""); + exit(1); + } + + code = krb5_os_localaddr(&my_addresses); + if (code != 0) { + com_err (argv[0], code, "when getting my address"); + exit(1); + } +#ifdef notyet + code = krb5_get_in_tkt_with_password + (flags, my_addresses, <<>>, + <<>>, + <<>>, + ccache, + my_creds, + <<>>); + if (code != 0) { + com_err (argv[0], code, "getting initial credentials"); + exit(1); + } +#endif + exit(0); +} diff --git a/src/clients/klist/klist.c b/src/clients/klist/klist.c new file mode 100644 index 0000000000..0e96b3554a --- /dev/null +++ b/src/clients/klist/klist.c @@ -0,0 +1,70 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * List out the contents of your credential cache. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_klist_c [] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include + +#include +#include + +extern int optind; +extern char *optarg; + +main(argc, argv) + int argc; + char **argv; +{ + int c; + int i; + int errflg = 0; + int code; + krb5_ccache cache = NULL; + krb5_cc_cursor cur; + char *cache_name; + + initialize_krb5_error_table(); + + while ((c = getopt(argc, argv, "c:")) != EOF) { + switch (c) { + case 'c': + if (cache == NULL) { + cache_name = optarg; + + code = krb5_cc_resolve (cache_name, &cache); + if (code != 0) { + com_err(argv[0], code, "while resolving %s", cache_name); + errflg++; + } + } else { + fprintf(stderr, "Only one -c option allowed\n"); + errflg++; + } + break; + case '?': + default: + errflg++; + break; + } + } + + if (optind != argc) + errflg++; + + if (errflg) { + fprintf(stderr, "Usage: %s [ -c cache ]\n", argv[0]); + exit(2); + } +} diff --git a/src/prototype/getopt.c b/src/prototype/getopt.c new file mode 100644 index 0000000000..66cbad5d43 --- /dev/null +++ b/src/prototype/getopt.c @@ -0,0 +1,29 @@ +extern int optind; +extern char *optarg; + +main(argc, argv) + int argc; + char **argv; +{ + int c; + int errflg = 0; + + <<>>; + + while ((c = getopt(argc, argv, "<<<>>>")) != EOF) { + switch (c) { + <<>>; + case '?': + default: + errflg++; + break; + } + } + if (errflg) { + fprintf(stderr, "Usage: %s <<>>", argv[0]); + exit(2); + } + for (; optind < argc; optind++) { + <<>>; + } +} -- cgit