Re: Checkpassword and FD3 - the problem

[email protected] (Paul Jarc) Thu, 10 Apr 2003 12:44:00 -0400
Newsgroups gmane.comp.djb.checkpassword
Organization What did you have in mind? A short, blunt, human pyramid?
Message-ID <[email protected]>
"Jim Ramsay" <[email protected]> wrote:
> - Fork.
> - In this child, create a pipe
> - Close FD's 1 and 2
> - Fork again, creating the grandchild
> - This strange pipe now lives in FD 1 and 2, leaving FD3 free for the
> grandchild to connect one end of that pipe to.
> - Of course close the ends of the pipe the child and grandchild won't be
> needing.
> - Exec the checkpassword program in the grandchild and have the child write
> the string into the pipe and wait for the grandchild to exit

After the grandchild execs checkpassword, checkpassword will exec the
next program - qmail-pop3d, or whatever.  That program needs the
original descriptors 1 and 2 to do its job.  You'll need to save and
restore both of those, which won't be any easier than saving and
restoring descriptor 3.

> This is almost as kludgey as using /bin/sh for redirection or wrapping
> python in some sort of environment where FD#3 is already open, but at least
> it can be done purely in python :)

My wrapper sh script could be rewritten in python easily enough.


paul