pipe passphrase to unlock key
Face
falazemi at gmail.com
Wed Jun 27 19:42:26 CEST 2012
Hell all,
I am trying to pipe my passphrase to unlock the key. my problem is
like this, when I use git
to sign a tag gnupg ask for the passphrase and i need to pipe the passphrase.
I try
echo "my long passphrase" | git tag -s 1.0.0.42 -m 'version 1.0.0.1'
however it did not work.
i also try writing a program to do the same thing
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int my_pipe[2];
void ErrorAndExit(char* message) {
fprintf(stderr, "%s\n", message);
exit(1);
}
void WriteToPipe(char* s) {
write(my_pipe[1], s, strlen(s));
}
int main(int argc, char* argv[]) {
int pid;
char* my_argv[]= {"/usr/bin/git",
"tag",
"-s",
"1.0.0.2",
"-m",
"'version 1.0.0.2'",
0
};
if (pipe(my_pipe) == -1) ErrorAndExit("pipe failed.");
pid=fork();
if (pid==-1) ErrorAndExit("fork failed.");
if (pid==0) {
/* son process */
close(0);
dup(my_pipe[0]);
close(my_pipe[0]);
close(my_pipe[1]);
execv(my_argv[0], my_argv);
ErrorAndExit("Program not found.");
}
/* father process */
WriteToPipe("My Really Really Really Really Long passphrase \n");
WriteToPipe("\n");
return 0;
}
The problem with this code it keep writing to the pipe and would not exit.
is there is any workaround for my problem ?
Any help would be much appreciated.
Sincerely,
falazemi
note: using pinentry-curses
More information about the Gnupg-users
mailing list