Development problem with passphrase-fd

Brian Lee brian5555 at gmail.com
Wed Oct 31 18:15:57 CET 2007


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.  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.

Here is the code of my test program on Windows XP:
=================================================
#include "stdafx.h"
#include <stdio.h>
#include <atlstr.h>   
#include <TCHAR.H>

//-------------------------------------------------------------
HANDLE LaunchViaCreateProcess(LPCTSTR program, LPCTSTR sCommand)
{
	HANDLE hProcess = NULL;
	PROCESS_INFORMATION processInfo;
	ZeroMemory(&processInfo, sizeof(processInfo));
	STARTUPINFO startupInfo;
	ZeroMemory(&startupInfo, sizeof(startupInfo));
	startupInfo.cb = sizeof(startupInfo);

	if (CreateProcess(  (LPCTSTR)program,  
		              (LPTSTR)sCommand,
			NULL, NULL, FALSE, 0, NULL, NULL,	
			&startupInfo,	
			&processInfo))
	{	
		hProcess = processInfo.hProcess;
		printf("SUCCESS\n");
	}
	else
	{
		printf("ERROR = %d \n", GetLastError());
	}
	return hProcess;
}



//----------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
	HANDLE hProcess;
	LPTSTR sCommand;

	//sCommand = _tcsdup(TEXT("echo mypass| gpg --passphrase-fd 0 --output
testfile.txt --decrypt testfile.txt.gpg"));

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

	 hProcess = LaunchViaCreateProcess( NULL,  sCommand);   

     return 0;
}
=================================================
Thanks in advance.
Brian Lee
-- 
View this message in context: http://www.nabble.com/Development-problem-with-passphrase-fd-tf4726552.html#a13514234
Sent from the GnuPG - Dev mailing list archive at Nabble.com.




More information about the Gnupg-devel mailing list