Read the V4 Kerberos master key from /.k. Only prompt the user for the
authorRichard Basch <probe@mit.edu>
Tue, 24 Oct 1995 01:18:15 +0000 (01:18 +0000)
committerRichard Basch <probe@mit.edu>
Tue, 24 Oct 1995 01:18:15 +0000 (01:18 +0000)
V4 master key if the command-line option so indicates, or the key cannot
be read from /.k.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6989 dc483132-0cff-0310-8789-dd5450dbe970

src/admin/edit/loadv4.c

index d2d063a1d7bb13fb058b6cbffc18813c81032680..1d9def17743e1f9e2d8fca32a13320f1ff930f2d 100644 (file)
@@ -37,6 +37,8 @@ static C_Block master_key;
 static Key_schedule master_key_schedule;
 static long master_key_version;
 
+static char *v4_mkeyfile = "/.k";
+
 #include "k5-int.h"
 #include "com_err.h"
 #include "adm.h"
@@ -434,8 +436,21 @@ char *pname, *name;
 int manual;
 char *dumpfile;
 {
-    des_read_password(master_key, "Kerberos master key: ", 1);
-    printf("\n");
+    int fd;
+    int ok = 0;
+
+    if (!manual) {
+       fd = open(v4_mkeyfile, O_RDONLY, 0600);
+       if (fd >= 0) {
+           if (read(fd, master_key, sizeof(master_key)) == sizeof(master_key))
+               ok = 1;
+           close(fd);
+       }
+    }
+    if (!ok) {
+       des_read_password(master_key, "V4 Kerberos master key: ", 0);
+       printf("\n");
+    }
     key_sched(master_key, master_key_schedule);
     return 0;
 }