Re: Checkpassword and FD3 - the problem

Felix von Leitner <[email protected]> Thu, 10 Apr 2003 00:27:56 +0200
Newsgroups gmane.comp.djb.checkpassword
Message-ID <[email protected]>
Thus spake Jim Ramsay ([email protected]):
> Systems which use uthread as the threading implementation take up file
> descriptors 3 and 4 with a pipe apparently used to do signalling between
> threads?

> I don't really know what it's for - I just know that my python program
> (python uses pthreads and thus uthread) cannot close or dup2 FD3, so that it
> is very difficult to use checkpassword directly.

How so?

If you call checkpassword, these internal file descriptors should be set
close-on-exec.  If they aren't, that's a bug in the threading library,
please report it to the authors.

You could also try setting the flag yourself.  I don't know how it's
done in python, but in C it's

  fcntl(fd,F_SETFD,FD_CLOEXEC);

If you are called by checkpassword, file descriptor 3 will already be
open for you, so pipe() from uthread will get descriptors 4 and 5
instead of 3 and 4, thus causing no problem.

> Why is the checkpassword interface so married to FD#3?  Why not stdin?

Because it is a bug if you call checkpassword with any files open.

Felix