summaryrefslogtreecommitdiffstats
path: root/usr.bin/enigma/enigma.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-10-09 10:00:53 +0000
committertjr <tjr@FreeBSD.org>2003-10-09 10:00:53 +0000
commit10449fdca76a16b29ed4dd12f46bee8f7ba14154 (patch)
tree50d18f2dbd5d8a67c125282f4911c2e1325eb804 /usr.bin/enigma/enigma.c
parentf280804c96e4a256b74f1d1215b471b6d388072a (diff)
downloadFreeBSD-src-10449fdca76a16b29ed4dd12f46bee8f7ba14154.zip
FreeBSD-src-10449fdca76a16b29ed4dd12f46bee8f7ba14154.tar.gz
Call crypt() directly instead of taking a detour through makekey.
Diffstat (limited to 'usr.bin/enigma/enigma.c')
-rw-r--r--usr.bin/enigma/enigma.c38
1 files changed, 4 insertions, 34 deletions
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;
OpenPOWER on IntegriCloud