summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-02 18:11:31 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-02 18:11:31 +0000
commit3775db429fa3cba90d9fe53b14134ad91b224af9 (patch)
tree6ce977890c2555c9216415ecfd87b8ab205b731d /usr.bin
parentdd10b1218482d80706c1df2dd7dce7d235d7e074 (diff)
When changing hash algorithms comment out the old entry so we
don't overflow the old fixed length record.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/skeyinit/skeyinit.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c
index 421c97a7a1c..3f7cf4944a3 100644
--- a/usr.bin/skeyinit/skeyinit.c
+++ b/usr.bin/skeyinit/skeyinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeyinit.c,v 1.12 1996/10/02 03:49:34 millert Exp $ */
+/* $OpenBSD: skeyinit.c,v 1.13 1996/10/02 18:11:30 millert Exp $ */
/* $NetBSD: skeyinit.c,v 1.6 1995/06/05 19:50:48 pk Exp $ */
/* S/KEY v1.1b (skeyinit.c)
@@ -172,8 +172,11 @@ main(argc, argv)
n = 99;
/* Set hash type if asked to */
- if (ht)
- skey_set_algorithm(ht);
+ if (ht) {
+ /* Need to zero out old key when changing algorithm */
+ if (strcmp(ht, skey_get_algorithm()) && skey_set_algorithm(ht))
+ zerokey = 1;
+ }
if (!defaultsetup) {
(void)printf("You need the 6 english words generated from the \"skey\" command.\n");
@@ -283,11 +286,19 @@ main(argc, argv)
if ((skey.val = (char *)malloc(16 + 1)) == NULL)
err(1, "Can't allocate memory");
+ /* Zero out old key if necesary (entry would change size) */
+ if (zerokey) {
+ (void)skeyzero(&skey, pp->pw_name);
+ /* Re-open keys file and seek to the end */
+ if (skeylookup(&skey, pp->pw_name) == -1)
+ err(1, "cannot open database");
+ }
+
btoa8(skey.val, key);
/* Don't save algorithm type for md4 (keep record length same) */
if (strcmp(skey_get_algorithm(), "md4") == 0)
- (void)fprintf(skey.keyfile, "%s s %04d %-16s %s %-21s\n",
+ (void)fprintf(skey.keyfile, "%s %04d %-16s %s %-21s\n",
pp->pw_name, n, seed, skey.val, tbuf);
else
(void)fprintf(skey.keyfile, "%s %s %04d %-16s %s %-21s\n",