pipes cgi and gnupg

Brad Tilley byte8bits at gmail.com
Sat Dec 29 04:03:15 CET 2007


I can do this from a python cgi script from a browser:

os.system("gpg --version > gpg.out")

However, I cannot do this from a browser:

os.system("echo %s | gpg --batch --password-fd 0 -d %s > d.out"
%(pass, filename))

The output file is produced, but it's zero byte. I want the decrypted
file's content, but the pipe seems to mess things up. The script works
fine when executed from command line. The output file is produced as
expected. When executed by a browser, it does not work as expected...
only produces a zero byte output file. Any tips? I've googled a bit
and experimented for a few nights, still no go.

Thanks,
Brad

Here's the entire script:

#!/usr/local/bin/python

import cgi
import cgitb; cgitb.enable()
import os
import tempfile

print "Content-Type: text/html"
print
print "<TITLE>T</TITLE>"
print "<H1>H</H1>"

form = cgi.FieldStorage()
if not form.has_key("pass"):
    print "Enter password"

filename = "test.gpg"
pass = form.getvalue("pass").strip()
os.system("gpg --version > gpg.out")
os.system("echo %s | gpg --batch --password-fd 0 --decrypt %s > d.out"
%(pass,filename))



More information about the Gnupg-users mailing list