Initial revision
authorBill Sommerfeld <wesommer@mit.edu>
Sat, 3 Feb 1990 10:40:28 +0000 (10:40 +0000)
committerBill Sommerfeld <wesommer@mit.edu>
Sat, 3 Feb 1990 10:40:28 +0000 (10:40 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@245 dc483132-0cff-0310-8789-dd5450dbe970

src/clients/kdestroy/kdestroy.c [new file with mode: 0644]
src/clients/kinit/kinit.c [new file with mode: 0644]
src/clients/klist/klist.c [new file with mode: 0644]
src/prototype/getopt.c [new file with mode: 0644]

diff --git a/src/clients/kdestroy/kdestroy.c b/src/clients/kdestroy/kdestroy.c
new file mode 100644 (file)
index 0000000..3e9e801
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * Destroy the contents of your credential cache.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_klist_c [] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <stdio.h>
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+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 (file)
index 0000000..b9fb6d4
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * Initialize a credentials cache.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_kinit_c [] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <stdio.h>
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+#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, <<<enctype>>>,
+        <<<keytype>>>,
+        <<<char *>>>,
+        ccache,
+        my_creds,
+        <<<int>>>);
+    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 (file)
index 0000000..0e96b35
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * List out the contents of your credential cache.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_klist_c [] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <stdio.h>
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+
+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 (file)
index 0000000..66cbad5
--- /dev/null
@@ -0,0 +1,29 @@
+extern int optind;
+extern char *optarg;
+
+main(argc, argv)
+    int argc;
+    char **argv;
+{
+    int c;
+    int errflg = 0;
+    
+    <<<other globals here>>>;
+       
+    while ((c = getopt(argc, argv, "<<<>>>")) != EOF) {
+       switch (c) {
+           <<<add cases for arguments here>>>;
+       case '?':
+       default:
+           errflg++;
+           break;
+       }
+    }
+    if (errflg) {
+       fprintf(stderr, "Usage: %s <<<args>>>", argv[0]);
+       exit(2);
+    }
+    for (; optind < argc; optind++) {
+       <<<process arg optind>>>;
+    }
+}