|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Development problem with passphrase-fdI 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 |
|
|
Re: Development problem with passphrase-fdAt Wed, 31 Oct 2007 10:15:57 -0700 (PDT),
Brian Lee <brian5555@...> 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 _______________________________________________ Gnupg-devel mailing list Gnupg-devel@... http://lists.gnupg.org/mailman/listinfo/gnupg-devel |
| Free Forum Powered by Nabble | Forum Help |