crypt: cannot generate key

David Elliott dce at Solbourne.COM
Fri May 19 00:51:30 AEST 1989


In article <8526 at ihlpf.ATT.COM> lukas at ihlpf.UUCP (Lukas,J.) writes:
>
>I am trying to use crypt(1). If I invoke
>	cat foo | crypt "abcde"
>under sh or ksh, it seems to work fine. However, if I extend the key
>by one character, and invoke
>	cat foo | crypt "abcdef"
>under sh, I get the message
>	crypt: cannot generate key
>(ksh works ok). Does anyone have an idea what the problem is? TIA

What year is it?  Did I just get thrown back five years?

The problem is that some versions of crypt are very naive about
doing a wait().  They just wait for the first child process that
dies, and if the input file is small enough, that process will
often be the cat.

You see, the shell forks a process to run the entire command
line.  The resulting process forks to run the cat, and execs
the crypt, so the cat process is a child of the process that
ends up running crypt.  Crypt forks and execs makekey, and
then waits for it.  Ksh process handling is slightly different,
though I don't know the details.

If the cat finishes before the makekey, there may be no data
ready to read from makekey, but crypt tries anyway and fails.

This was discussed about five years ago, and has been fixed in
a number of Unix variants.

-- 
David Elliott		dce at Solbourne.COM
			...!{boulder,nbires,sun}!stan!dce



More information about the Comp.unix.questions mailing list