From 235e3da1a564427dd73180904e973ecc75cb31a0 Mon Sep 17 00:00:00 2001 From: David Rhodus Date: Tue, 4 Nov 2003 16:36:35 +0000 Subject: [PATCH] * Call crypt() directly instread of taking a detour through makekey. Note: This should have been the last user of makekey. Makekey perhaps should be depreciated. Obtained from: The FreeBSD project --- usr.bin/enigma/Makefile | 5 ++++- usr.bin/enigma/enigma.c | 39 +++++---------------------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/usr.bin/enigma/Makefile b/usr.bin/enigma/Makefile index 5fd4521479..f73d75d270 100644 --- a/usr.bin/enigma/Makefile +++ b/usr.bin/enigma/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/usr.bin/enigma/Makefile,v 1.3.6.3 2001/07/30 09:59:16 dd Exp $ -# $DragonFly: src/usr.bin/enigma/Makefile,v 1.2 2003/06/17 04:29:26 dillon Exp $ +# $DragonFly: src/usr.bin/enigma/Makefile,v 1.3 2003/11/04 16:36:35 drhodus Exp $ PROG= enigma WARNS?= 2 @@ -7,4 +7,7 @@ WARNS?= 2 LINKS= ${BINDIR}/enigma ${BINDIR}/crypt MLINKS= enigma.1 crypt.1 +DPADD+= ${LIBCRYPT} +LDADD+= -lcrypt + .include diff --git a/usr.bin/enigma/enigma.c b/usr.bin/enigma/enigma.c index 3f16931f4b..724ebac9a9 100644 --- a/usr.bin/enigma/enigma.c +++ b/usr.bin/enigma/enigma.c @@ -10,7 +10,7 @@ * Upgraded to function properly on 64-bit machines. * * $FreeBSD: src/usr.bin/enigma/enigma.c,v 1.2.6.3 2001/08/01 23:51:34 obrien Exp $ - * $DragonFly: src/usr.bin/enigma/enigma.c,v 1.3 2003/10/04 20:36:43 hmp Exp $ + * $DragonFly: src/usr.bin/enigma/enigma.c,v 1.4 2003/11/04 16:36:35 drhodus Exp $ */ #include @@ -39,42 +39,13 @@ void setup(char *); void setup(char *pw) { - int ic, i, k, temp, pf[2], pid; + int ic, i, k, temp; + char salt[3]; unsigned rnd; long seed; - strncpy(buf, pw, 8); - while (*pw) - *pw++ = '\0'; - buf[8] = buf[0]; - buf[9] = buf[1]; - pipe(pf); - if ((pid=fork())==0) { - close(0); - close(1); - dup(pf[0]); - dup(pf[1]); - execlp("makekey", "-", (char *)0); - execl("/usr/libexec/makekey", "-", (char *)0); /* BSDI */ - execl("/usr/lib/makekey", "-", (char *)0); - execl("/usr/bin/makekey", "-", (char *)0); /* IBM */ - execl("/lib/makekey", "-", (char *)0); - perror("makekey"); - fprintf(stderr, "enigma: cannot execute 'makekey', aborting\n"); - exit(1); - } - write(pf[1], buf, 10); - close(pf[1]); - i=wait((int *)NULL); - if (i<0) perror("enigma: wait"); - if (i!=pid) { - fprintf(stderr, "enigma: expected pid %d, got pid %d\n", pid, i); - exit(1); - } - if ((i=read(pf[0], buf, 13)) != 13) { - fprintf(stderr, "enigma: cannot generate key, read %d\n",i); - exit(1); - } + strncpy(salt, pw, sizeof(salt)); + memcpy(buf, crypt(pw, salt), sizeof(buf)); seed = 123; for (i=0; i<13; i++) seed = seed*buf[i] + i; -- 2.41.0