X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=userdir_gpg.py;h=59e7400ae2d0d45f39f54d0faf8bd5cbde631003;hb=186f30d63f9631fbfbda0b56f59d4f0339f8a9d2;hp=3abc05cd30840d9638c15aea96f65b58b8225086;hpb=ae1e5a947fad4c2a450281a1a1d6ec3ca768101b;p=mirror%2Fuserdir-ldap.git diff --git a/userdir_gpg.py b/userdir_gpg.py index 3abc05c..59e7400 100644 --- a/userdir_gpg.py +++ b/userdir_gpg.py @@ -1,5 +1,19 @@ - #!/usr/bin/env python -# -*- mode: python -*- +# Copyright (c) 1999-2001 Jason Gunthorpe +# Copyright (c) 2005 Joey Schulze +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # GPG issues - # - gpgm with a status FD being fed keymaterial and other interesting @@ -13,13 +27,17 @@ # pgp2 encrypting mode. import string, mimetools, multifile, sys, StringIO, os, tempfile, re; -import rfc822, time, fcntl, FCNTL, anydbm +import rfc822, time, fcntl, anydbm # General GPG options GPGPath = "gpg" # "--load-extension","rsa", -GPGBasicOptions = ["--no-options","--batch", - "--no-default-keyring","--always-trust"]; +GPGBasicOptions = [ + "--no-options", + "--batch", + "--no-default-keyring", + "--secret-keyring", "/dev/null", + "--always-trust"]; GPGKeyRings = []; GPGSigOptions = ["--output","-"]; GPGSearchOptions = ["--dry-run","--with-colons","--fingerprint"]; @@ -116,9 +134,9 @@ def GetClearSig(Msg,Paranoid = 0): Output = "-----BEGIN PGP SIGNED MESSAGE-----\r\n"; # Semi-evil hack to get the proper hash type inserted in the message if Msg.getparam('micalg') != None: - Output = Output + "Hash: %s\r\n"%(string.upper(Msg.getparam('micalg')[4:])); + Output = Output + "Hash: MD5,SHA1,%s\r\n"%(string.upper(Msg.getparam('micalg')[4:])); Output = Output + "\r\n"; - Output = Output + string.replace(Signed.getvalue(),"\n---","\n- ---") + Signature; + Output = Output + string.replace(Signed.getvalue(),"\n-","\n- -") + Signature; return (Output,1); else: if Paranoid == 0: @@ -407,6 +425,11 @@ def GPGKeySearch(SearchCriteria): Owner = ""; KeyID = ""; Hits = {}; + + dir = os.path.expanduser("~/.gnupg") + if not os.path.isdir(dir): + os.mkdir(dir, 0700) + try: Strm = os.popen(string.join(Args," "),"r"); @@ -462,7 +485,7 @@ def TemplateSubst(Map,Template): class ReplayCache: def __init__(self,Database): self.Lock = open(Database + ".lock","w",0600); - fcntl.flock(self.Lock.fileno(),FCNTL.LOCK_EX); + fcntl.flock(self.Lock.fileno(),fcntl.LOCK_EX); self.DB = anydbm.open(Database,"c",0600); self.CleanCutOff = CleanCutOff; self.AgeCutOff = AgeCutOff;