Relink executable when libraries change
authorTheodore Tso <tytso@mit.edu>
Thu, 29 Sep 1994 20:50:48 +0000 (20:50 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 29 Sep 1994 20:50:48 +0000 (20:50 +0000)
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
src/admin/edit/Makefile.in
src/admin/edit/dump.c
src/admin/edit/kdb5_edit.c

index f03ce143df819fc7d425219d8b2a033d2f4ab4ff..a371de063b85ef4e3fde7a2c6ca806af301e2141 100644 (file)
@@ -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:
index f3d735a74e02a285640722f2f01430ca3caf044b..76bbb4edfc76602e0f7b3543b307aa1537d153a6 100644 (file)
@@ -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)
index 5837d51d3e7fa7e0cb064d15588d64d22ac92d39..5cdf04e5c42fa0b645f9e6763f1661dc3cc31b0a 100644 (file)
@@ -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;
index e1131985223169a05541686c99a7bd068fea8ef0..3681ee92d20d9283646cacc57bc37d32f9af84d7 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <com_err.h>
 #include <stdio.h>
+#include <time.h>
 
 #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]);