diff options
author | tjr <tjr@FreeBSD.org> | 2003-10-09 10:00:53 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2003-10-09 10:00:53 +0000 |
commit | 10449fdca76a16b29ed4dd12f46bee8f7ba14154 (patch) | |
tree | 50d18f2dbd5d8a67c125282f4911c2e1325eb804 /usr.bin/enigma | |
parent | f280804c96e4a256b74f1d1215b471b6d388072a (diff) | |
download | FreeBSD-src-10449fdca76a16b29ed4dd12f46bee8f7ba14154.zip FreeBSD-src-10449fdca76a16b29ed4dd12f46bee8f7ba14154.tar.gz |
Call crypt() directly instead of taking a detour through makekey.
Diffstat (limited to 'usr.bin/enigma')
-rw-r--r-- | usr.bin/enigma/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/enigma/enigma.c | 38 |
2 files changed, 7 insertions, 34 deletions
diff --git a/usr.bin/enigma/Makefile b/usr.bin/enigma/Makefile index 878b4d1..800aa42 100644 --- a/usr.bin/enigma/Makefile +++ b/usr.bin/enigma/Makefile @@ -5,4 +5,7 @@ PROG= enigma LINKS= ${BINDIR}/enigma ${BINDIR}/crypt MLINKS= enigma.1 crypt.1 +DPADD+= ${LIBCRYPT} +LDADD+= -lcrypt + .include <bsd.prog.mk> diff --git a/usr.bin/enigma/enigma.c b/usr.bin/enigma/enigma.c index 1b0f077..25bb456 100644 --- a/usr.bin/enigma/enigma.c +++ b/usr.bin/enigma/enigma.c @@ -14,7 +14,6 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> -#include <sys/wait.h> #include <stdio.h> #include <stdlib.h> @@ -38,42 +37,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); - } + strlcpy(salt, pw, sizeof(salt)); + memcpy(buf, crypt(pw, salt), sizeof(buf)); seed = 123; for (i=0; i<13; i++) seed = seed*buf[i] + i; |