summaryrefslogtreecommitdiff
path: root/kerberosIV/kstash
diff options
context:
space:
mode:
Diffstat (limited to 'kerberosIV/kstash')
-rw-r--r--kerberosIV/kstash/Makefile9
-rw-r--r--kerberosIV/kstash/kstash.840
-rw-r--r--kerberosIV/kstash/kstash.c73
3 files changed, 122 insertions, 0 deletions
diff --git a/kerberosIV/kstash/Makefile b/kerberosIV/kstash/Makefile
new file mode 100644
index 00000000000..da8233be4bc
--- /dev/null
+++ b/kerberosIV/kstash/Makefile
@@ -0,0 +1,9 @@
+# from @(#)Makefile 8.1 (Berkeley) 6/1/93
+# $Id: Makefile,v 1.1 1995/12/14 06:52:41 tholo Exp $
+
+PROG= kstash
+DPADD= ${LIBKDB} ${LIBKRB} ${LIBDES}
+LDADD= -lkdb -lkrb -ldes
+MAN= kstash.8
+
+.include <bsd.prog.mk>
diff --git a/kerberosIV/kstash/kstash.8 b/kerberosIV/kstash/kstash.8
new file mode 100644
index 00000000000..f7a660dd0fd
--- /dev/null
+++ b/kerberosIV/kstash/kstash.8
@@ -0,0 +1,40 @@
+.\" Copyright 1989 by the Massachusetts Institute of Technology.
+.\"
+.\" For copying and distribution information,
+.\" please see the file <mit-copyright.h>.
+.\"
+.\" $Id: kstash.8,v 1.1 1995/12/14 06:52:41 tholo Exp $
+.TH KSTASH 8 "Kerberos Version 4.0" "MIT Project Athena"
+.SH NAME
+kstash \- stash Kerberos key distribution center database master key
+.SH SYNOPSIS
+kstash
+.SH DESCRIPTION
+.I kstash
+saves the Kerberos key distribution center (KDC) database master key in
+the master key cache file.
+.PP
+The user is prompted to enter the key, to verify the authenticity of the
+key and the authorization to store the key in the file.
+.SH DIAGNOSTICS
+.TP 20n
+"verify_master_key: Invalid master key, does not match database."
+The master key string entered was incorrect.
+.TP
+"kstash: Unable to open master key file"
+The attempt to open the cache file for writing failed (probably due to a
+system or access permission error).
+.TP
+"kstash: Write I/O error on master key file"
+The
+.BR write (2)
+system call returned an error while
+.I kstash
+was attempting to write the key to the file.
+.SH FILES
+.TP 20n
+/kerberos/principal.pag, /kerberos/principal.dir
+DBM files containing database
+.TP
+/.k
+Master key cache file.
diff --git a/kerberosIV/kstash/kstash.c b/kerberosIV/kstash/kstash.c
new file mode 100644
index 00000000000..492619ac23d
--- /dev/null
+++ b/kerberosIV/kstash/kstash.c
@@ -0,0 +1,73 @@
+/* $Id: kstash.c,v 1.1 1995/12/14 06:52:41 tholo Exp $ */
+
+/*-
+ * Copyright 1987, 1988 by the Student Information Processing Board
+ * of the Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * M.I.T. and the M.I.T. S.I.P.B. make no representations about
+ * the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ */
+
+#include <adm_locl.h>
+
+/* change this later, but krblib_dbm needs it for now */
+char *progname;
+
+static des_cblock master_key;
+static des_key_schedule master_key_schedule;
+static int kfile;
+
+static void
+clear_secrets(void)
+{
+ bzero(master_key_schedule, sizeof(master_key_schedule));
+ bzero(master_key, sizeof(master_key));
+}
+
+int
+main(int argc, char **argv)
+{
+ long n;
+ if ((n = kerb_init())) {
+ fprintf(stderr, "Kerberos db and cache init failed = %ld\n", n);
+ exit(1);
+ }
+
+ if (kdb_get_master_key (TRUE, &master_key, master_key_schedule) != 0) {
+ fprintf (stderr, "%s: Couldn't read master key.\n", argv[0]);
+ fflush (stderr);
+ clear_secrets();
+ exit (-1);
+ }
+
+ if (kdb_verify_master_key (&master_key, master_key_schedule, stderr) < 0) {
+ clear_secrets();
+ exit (-1);
+ }
+
+ kfile = open(MKEYFILE, O_TRUNC | O_RDWR | O_CREAT, 0600);
+ if (kfile < 0) {
+ clear_secrets();
+ fprintf(stderr, "\n\07\07%s: Unable to open master key file\n",
+ argv[0]);
+ exit(1);
+ }
+ if (write(kfile, (char *) master_key, 8) < 0) {
+ clear_secrets();
+ fprintf(stderr, "\n%s: Write I/O error on master key file\n",
+ argv[0]);
+ exit(1);
+ }
+ (void) close(kfile);
+ clear_secrets();
+ exit(0);
+}