using --status-fd

Sven-S. Porst ssssp@gmx.net
Mon Jan 21 17:10:01 2002


>gpg -a -r foo --status-fd=2 --command-fd=0 --output - --
>Now gpg reads from stdin and writes to stdout the used FD's
>are (stdin=0, stdout=1, stderr=2)
>
>[GNUPG:] BEGIN_ENCRYPTION
>>> data from stdin
><< armored ciphertext
>[GNUPG:] END_ENCRYPTION

This works in your example, but what to do in the following case

[dhcp97:~] ssp% gpg --status-fd=2 --command-fd=0 --encrypt -r foo --armor
--sign --
[GNUPG:] USERID_HINT 93D72D600085ABA3 Sven-S. Porst <S.Porst@web.de>
[GNUPG:] NEED_PASSPHRASE 93D72D600085ABA3 93D72D600085ABA3 17 0
[GNUPG:] GET_HIDDEN passphrase.enter
>> passphrase
[GNUPG:] GOT_IT
[GNUPG:] GOOD_PASSPHRASE                                  
[GNUPG:] GET_BOOL untrusted_key.override
Y
[GNUPG:] GOT_IT
>> message from stdin
<< gpg output

So in this case I have to write the message after GOT_IT which of course
doesn't appear necessarily as the key might be trusted in which case I
would have to write out the message after GOOD_PASSPHRASE. It seems to me
that there is no definite command sent at the time at which entering the
message is required. So I fear this may be the wrong way to do it. In
particular I haven't yet managed to use anything but stdin as my --
command-fd (probably due to my lack of knowledge on these things) in
which case I could perhaps write my message to stdin right away and deal
with the --command-fd input separately.

>BTW, GPGME might be a good solution for your problem.

I had a look at it a while ago and tried it out. Somehow it needed about
10 seconds just to give me information on the keys in my moderately small
keyrings - so I decided not to use it, particularly as I wanted to learn
how to interactively use command line tools from a program anyway.

Cheers

            Sven

-- 
Sven-S. Porst . PGP: 0x0085ABA3 . http://homepage.mac.com/ssp
           When you find yourself on the side of the majority, 
                                         it is time to reform.
                                                -- Mark Twain