summaryrefslogtreecommitdiffstats
path: root/src/admin
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1990-11-02 10:39:17 +0000
committerTheodore Tso <tytso@mit.edu>1990-11-02 10:39:17 +0000
commitb3de04b931228846013136a7473da2212a99cb1d (patch)
tree2ba4794900fa7f8adcc9cf8844ee08803e24769d /src/admin
parent286c468cabf65ad346b92d2c3735f28b111806dd (diff)
downloadkrb5-b3de04b931228846013136a7473da2212a99cb1d.tar.gz
krb5-b3de04b931228846013136a7473da2212a99cb1d.tar.xz
krb5-b3de04b931228846013136a7473da2212a99cb1d.zip
Initial revision
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1403 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/admin')
-rw-r--r--src/admin/edit/dump.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c
new file mode 100644
index 000000000..d4c56f1a8
--- /dev/null
+++ b/src/admin/edit/dump.c
@@ -0,0 +1,117 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ * Dump a KDC database
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_kdb_edit_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/kdb.h>
+#include <krb5/kdb_dbm.h>
+#include <krb5/libos-proto.h>
+#include <krb5/asn1.h>
+#include <krb5/config.h>
+#include <krb5/sysincl.h> /* for MAXPATHLEN */
+#include <krb5/ext-proto.h>
+#include <krb5/func-proto.h>
+
+#include <com_err.h>
+#include <ss/ss.h>
+#include <stdio.h>
+
+
+#define REALM_SEP '@'
+#define REALM_SEP_STR "@"
+
+struct mblock {
+ krb5_deltat max_life;
+ krb5_deltat max_rlife;
+ krb5_timestamp expiration;
+ krb5_flags flags;
+ krb5_kvno mkvno;
+};
+
+struct dump_record {
+ char *comerr_name;
+ FILE *f;
+};
+
+krb5_error_code
+dump_iterator(ptr, entry)
+krb5_pointer ptr;
+krb5_db_entry *entry;
+{
+ krb5_error_code retval;
+ struct dump_record *arg = (struct dump_record *) entry;
+ char *name;
+
+ if (retval = krb5_unparse_name(entry->principal, &name)) {
+ com_err(arg->comerr_name, retval, "while unparsing principal");
+ return retval;
+ }
+ printf("entry: %s\n", name);
+ free(name);
+ return 0;
+}
+/*ARGSUSED*/
+
+void dump_db(argc, argv)
+ int argc;
+ char **argv;
+{
+ FILE *f;
+ struct dump_record arg;
+
+ if (argc != 2) {
+ com_err(argv[0], 0, "Usage: %s filename", argv[0]);
+ return;
+ }
+ if (!(f = fopen(argv[1], "w"))) {
+ com_err(argv[0], errno,
+ "While opening file %s for writing", argv[1]);
+ return;
+ }
+ arg.comerr_name = argv[0];
+ arg.f = f;
+ (void) krb5_db_iterate(dump_iterator, &arg);
+}
+
+
+void update_ok_file (file_name)
+ char *file_name;
+{
+ /* handle slave locking/failure stuff */
+ char *file_ok;
+ int fd;
+ static char ok[]=".dump_ok";
+
+ if ((file_ok = (char *)malloc(strlen(file_name) + strlen(ok) + 1))
+ == NULL) {
+ fprintf(stderr, "kdb_util: out of memory.\n");
+ (void) fflush (stderr);
+ perror ("malloc");
+ exit (1);
+ }
+ strcpy(file_ok, file_name);
+ strcat(file_ok, ok);
+ if ((fd = open(file_ok, O_WRONLY|O_CREAT|O_TRUNC, 0400)) < 0) {
+ fprintf(stderr, "Error creating 'ok' file, '%s'", file_ok);
+ perror("");
+ (void) fflush (stderr);
+ exit (1);
+ }
+ free(file_ok);
+ close(fd);
+ return;
+}