Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions libpius/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,22 @@ def get_uids(self, key):
# For the normal case (have email), we'll be storing each email
# twice but that's OK since it means that email is *always* a valid
# email or None and id is *always* a valid identifier
match = re.search(".* <(.*)>", uid)
match = re.search("^.* <(.*)>$", uid)
if match:
email = match.group(1)
PiusUtil.debug("got email %s" % email)
filename = re.sub("@", "_at_", email)
filename = "%s__%s" % (key, filename)
uid = email
# It is possible for the UID to be JUST a raw email address, so
# if that appears to be the case, use that
elif re.match(
"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$", uid
):
email = uid
PiusUtil.debug("got email %s" % email)
filename = re.sub("@", "_at_", email)
filename = "%s__%s" % (key, filename)
else:
# but if it doesn't have an email, do the right thing
email = None
Expand Down Expand Up @@ -442,7 +451,7 @@ def encrypt_signed_uid(self, key, filename):

def _run_and_check_status(self, cmd, shell=False):
"""Helper function for running a gpg call that requires no input
but that we want to make sure succeeded."""
but that we want to make sure succeeded."""
PiusUtil.logcmd(cmd)
gpg = subprocess.Popen(
cmd,
Expand Down Expand Up @@ -495,7 +504,7 @@ def clean_clean_key(self, key):

def import_clean_key(self, key):
"""Import the clean key we exported in export_clean_key() to our temp
keyring."""
keyring."""
# Import the export of our public key and the given public key
for x in [self.signer, key]:
PiusUtil.debug("importing %s" % x)
Expand Down Expand Up @@ -690,7 +699,7 @@ def sign_all_uids(self, key, level):
uids = self.get_uids(key)
print(
" There %s %s UID%s on this key to sign"
% (["is", "are"][len(uids) != 1], len(uids), "s"[len(uids) == 1:])
% (["is", "are"][len(uids) != 1], len(uids), "s"[len(uids) == 1 :])
)

# From the user key ring make a clean copy
Expand Down Expand Up @@ -812,7 +821,7 @@ def import_unsigned_keys(self):
def encrypt_and_sign_file(self, infile, outfile, keyid):
"""Encrypt and sign a file.

Used for PGP/Mime email generation."""
Used for PGP/Mime email generation."""
cmd = (
[self.gpg]
+ GPG_BASE_OPTS
Expand Down
3 changes: 2 additions & 1 deletion libpius/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def debug(line):
print("DEBUG:", line)

def logcmd(cmd):
PiusUtil.debug("Running: %s" % " ".join(cmd))
outcmd = " ".join(cmd) if type(cmd) == list else cmd
PiusUtil.debug("Running: %s" % outcmd)

def clean_files(flist):
"""Delete a list of files."""
Expand Down
Loading