Development problem with passphrase-fd

Marcus Brinkmann marcus.brinkmann at ruhr-uni-bochum.de
Thu Nov 1 13:38:36 CET 2007


At Wed, 31 Oct 2007 10:15:57 -0700 (PDT),
Brian Lee <brian5555 at gmail.com> wrote:
> I am working on an application that works by spawning GPG command line, using
> the passphrase-fd feature.  The problem is that these commands worked fine
> when I tested them in DOS command prompt, but did not work in my program
> using CreateProcess.

See below.

> I tried both the "echo passphrase" and the "redirect
> from passphrase file" approaches, but none of them worked.  I wonder if I
> could use CreateProcess, or there is a better way.  Any suggestions would be
> appreciated.

I would suggest to use the GPGME (GPG Made Easy) library, if you can.
It abstracts all this mess away for you.

> Here is the code of my test program on Windows XP:
> =================================================
>	if (CreateProcess(  (LPCTSTR)program,  
>		              (LPTSTR)sCommand,
>			NULL, NULL, FALSE, 0, NULL, NULL,	
>			&startupInfo,	
>			&processInfo))

Not sure how this works, but shouldn't you use TRUE instead of FALSE
to inherit the handles?  Also, don't you need to create pipes and put
them into startup information (STARTF_USESTDHANDLES)?  At least this
is how we do it, but I admit that my knowledge of the W32 interface is
incomplete.

> 	sCommand = _tcsdup(TEXT("gpg --batch --passphrase-fd 0 --output
> testfile.txt --decrypt testfile.txt.txt.gpg < mypass.txt"));

I believe you need to pass a system handle rather than a file
descriptor value.  I do not understand why it works for you at the
command prompt, though.  Also, I did not check your usage of CreateProcess

Thanks,
Marcus




More information about the Gnupg-devel mailing list