From 348744ed602b849db90e4d87571c6f3fe2b25552 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 29 Sep 1994 20:50:48 +0000 Subject: [PATCH] Relink executable when libraries change Apply suggested change from Openvision so that principals with spaces in their names can be read in. Pass variable with correct type to ctime(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4383 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/edit/ChangeLog | 5 +++ src/admin/edit/Makefile.in | 2 + src/admin/edit/dump.c | 81 ++++++++++++++++++++++++++++++++------ src/admin/edit/kdb5_edit.c | 6 ++- 4 files changed, 79 insertions(+), 15 deletions(-) diff --git a/src/admin/edit/ChangeLog b/src/admin/edit/ChangeLog index f03ce143d..a371de063 100644 --- a/src/admin/edit/ChangeLog +++ b/src/admin/edit/ChangeLog @@ -1,5 +1,10 @@ Thu Sep 29 15:52:22 1994 Theodore Y. Ts'o (tytso@dcl) + * Makefile.in: Relink executable when libraries change. + + * kdb5_edit.c (show_principal): Pass variable with correct type to + ctime(). + * tcl_wrapper.c (doquit): ss_wrapper.c (main): kdb5_edit.c: diff --git a/src/admin/edit/Makefile.in b/src/admin/edit/Makefile.in index f3d735a74..76bbb4edf 100644 --- a/src/admin/edit/Makefile.in +++ b/src/admin/edit/Makefile.in @@ -6,10 +6,12 @@ COMERRLIB=$(BUILDTOP)/util/et/libcom_err.a SSLIB=$(BUILDTOP)/util/ss/libss.a DBMLIB= KDBLIB=$(TOPLIBD)/libkdb5.a +DEPKDBLIB=$(TOPLIBD)/libkdb5.a all:: KLIB = $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(ISODELIB) $(SSLIB) $(COMERRLIB) $(DBMLIB) +DEPKLIB = $(TOPLIBD)/libkrb5.a $(TOPLIBD)/libcrypto.a $(SSLIB) $(COMERRLIB) $(DBMLIB) DEPLIBS = $(DEPKDBLIB) $(DEPKLIB) diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c index 5837d51d3..5cdf04e5c 100644 --- a/src/admin/edit/dump.c +++ b/src/admin/edit/dump.c @@ -187,6 +187,51 @@ void update_ok_file (file_name) return; } + +/* + * Reads a name (actually, any string) of the specified length, + * containing any characters, and the character following the string. + * Returns a negative number if the specified number of characters + * can't be read or if the character following them isn't a tab. + * + * If successful, adds a null to the end of the string and returns the + * number of newlines read into it (usually 0). + * + * There must be enough space in the passed-in buffer for len + * characters followed by a null. + */ +int read_name(f, buf, len) + FILE *f; + char *buf; + int len; +{ + char *ptr; + int c; + int newlines = 0; + + for (ptr = buf; + (ptr - buf < len) && ((c = fgetc(f)) >= 0); + ptr++) { + *ptr = c; + if (c == '\n') + newlines++; + } + + if (ptr - buf < len) + return -1; + + if ((c = fgetc(f)) < 0) + return -1; + + if (c != '\t') + return -1; + + *ptr = '\0'; + + return newlines; +} + + void load_db(argc, argv) int argc; char **argv; @@ -198,6 +243,7 @@ void load_db(argc, argv) int salt_len, alt_salt_len; int i, one; char *name, *mod_name; + int name_ret; char *new_dbname; int ch; int load_error = 0; @@ -258,9 +304,9 @@ void load_db(argc, argv) load_error++; goto error_out; } + lineno++; for (;;) { int nitems; - unsigned int stop_loop = 0; lineno++; memset((char *)&entry, 0, sizeof(entry)); @@ -278,14 +324,12 @@ void load_db(argc, argv) com_err(argv[0], errno, "While allocating space for name"); load_error++; - stop_loop++; goto cleanup; } if (!(mod_name = malloc(mod_name_len+1))) { com_err(argv[0], errno, "While allocating space for mod_name"); load_error++; - stop_loop++; goto cleanup; } entry.key.length = key_len; @@ -295,7 +339,6 @@ void load_db(argc, argv) com_err(argv[0], errno, "While allocating space for the key"); load_error++; - stop_loop++; goto cleanup; } } @@ -306,7 +349,6 @@ void load_db(argc, argv) com_err(argv[0], errno, "While allocating space for alt_key"); load_error++; - stop_loop++; goto cleanup; } } @@ -316,7 +358,6 @@ void load_db(argc, argv) com_err(argv[0], errno, "While allocating space for the salt"); load_error++; - stop_loop++; goto cleanup; } } @@ -327,11 +368,16 @@ void load_db(argc, argv) com_err(argv[0], errno, "While allocating space for the alt_salt"); load_error++; - stop_loop++; goto cleanup; } } - if (fscanf(f, "%s\t%d\t", name, &tmp1) != 2) { + if ((name_ret = read_name(f, name, name_len)) < 0) { + fprintf(stderr, "Couldn't parse line #%d\n", lineno); + load_error++; + break; + } + lineno += name_ret; + if (fscanf(f, "%d\t", &tmp1) != 1) { fprintf(stderr, "Couldn't parse line #%d\n", lineno); load_error++; break; @@ -349,19 +395,28 @@ void load_db(argc, argv) } entry.key.contents[i] = tmp1; } - if (fscanf(f, - "\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%s\t%u\t%u\t%u\t", + if (fscanf(f, "\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t", &tmp1, &entry.max_life, &entry.max_renewable_life, &tmp2, &entry.expiration, &entry.pw_expiration, &entry.last_pwd_change, &entry.last_success, - &entry.last_failed, &entry.fail_auth_count, - mod_name, &entry.mod_date, - &entry.attributes, &stype) != 14) { + &entry.last_failed, &entry.fail_auth_count) != 10) { fprintf(stderr, "Couldn't parse line #%d\n", lineno); load_error++; break; } + if ((name_ret = read_name(f, mod_name, mod_name_len)) < 0) { + fprintf(stderr, "Couldn't parse line #%d\n", lineno); + load_error++; + break; + } + lineno += name_ret; + if (fscanf(f, "%u\t%u\t%u\t", + &entry.mod_date, &entry.attributes, &stype) != 3) { + fprintf(stderr, "Couldn't parse line #%d\n", lineno); + load_error++; + break; + } entry.kvno = tmp1; entry.mkvno = tmp2; entry.salt_type = stype; diff --git a/src/admin/edit/kdb5_edit.c b/src/admin/edit/kdb5_edit.c index e11319852..3681ee92d 100644 --- a/src/admin/edit/kdb5_edit.c +++ b/src/admin/edit/kdb5_edit.c @@ -35,6 +35,7 @@ #include #include +#include #include "kdb5_edit.h" @@ -1370,6 +1371,7 @@ void show_principal(argc, argv) krb5_error_code retval; char *pr_name = 0; char *pr_mod = 0; + time_t mod_date; if (argc < 2) { com_err(argv[0], 0, "Too few arguments"); @@ -1420,8 +1422,8 @@ void show_principal(argc, argv) printf("Name: %s\n", pr_name); printf("Salt: %d\n", entry.salt_type); printf("Alt salt: %d\n", entry.salt_type); -/* XXX - mod_date is a krb5_timestamp which is krb5_int32, but should be time_t! */ - printf("Last modified by %s on %s\n", pr_mod, ctime(&entry.mod_date)); + mod_date = (time_t) entry.mod_date; + printf("Last modified by %s on %s\n", pr_mod, ctime(&mod_date)); if (!nprincs) { com_err(argv[0], 0, "Principal '%s' does not exist", argv[1]); -- 2.26.2