summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Sommerfeld <wesommer@mit.edu>1990-02-03 10:40:28 +0000
committerBill Sommerfeld <wesommer@mit.edu>1990-02-03 10:40:28 +0000
commit4771917b69129c0225feea34165ca0071346d348 (patch)
tree630c5decbd87f9dbda8e8f06a12960ce0d9561b7
parent85448fb04aa22411ce6276ca3b2cbe7795bf91be (diff)
downloadkrb5-4771917b69129c0225feea34165ca0071346d348.tar.gz
krb5-4771917b69129c0225feea34165ca0071346d348.tar.xz
krb5-4771917b69129c0225feea34165ca0071346d348.zip
Initial revision
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@245 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/clients/kdestroy/kdestroy.c79
-rw-r--r--src/clients/kinit/kinit.c127
-rw-r--r--src/clients/klist/klist.c70
-rw-r--r--src/prototype/getopt.c29
4 files changed, 305 insertions, 0 deletions
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
+ * <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
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
+ * <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
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
+ * <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
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;
+
+ <<<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>>>;
+ }
+}