Commit b4a41ea4 authored by R's avatar R
Browse files

minor fixes

parent bdcd515c
......@@ -32,6 +32,9 @@ from urllib.request import urlopen
from email.parser import BytesParser
__version__ = '0.1.1'
ADDRESSPATTERN = re.compile(r'^[^<]*<(.*)>$')
......@@ -281,11 +284,12 @@ if __name__ == '__main__':
# check for Autocrypt header
if 'Autocrypt' in eml:
eprint('Found Autocrypt header')
data = parse_autocrypt_header(eml['Autocrypt'])
if 'addr' not in data or data['addr'] not in addresses[-1]:
if 'addr' not in data or data['addr'] not in addresses[0]:
# addr in Autocrypt must match the From address
# but matching a variant is probably good enough?
pass
eprint('Address in autocrypt did not match From')
elif 'keydata' in data:
if gpg_import(base64.b64decode(bytes(data['keydata'], 'utf-8'))):
# this key is authoritative
......@@ -295,14 +299,20 @@ if __name__ == '__main__':
for header in ['X-PGP', 'X-PGP-Key', 'X-PGP-KeyID', 'X-PGP-Fingerprint']:
if header not in eml:
continue
eprint(f'Found {header} header')
value = eml[header].strip()
if value.lower().startswith('0x'):
eprint(f'... found ID {value}')
keyids.append(value[2:])
if '://' in value:
urls.append(value)
eprint(f'... found URL {value}')
if ''.join([ch for ch in value if ch in string.hexdigits]) == value:
eprint(f'... found ID {value}')
keyids.append(value)
if len(keyids) > 0:
eprint('Trying to find ID on keybase and keyservers')
for keyid in keyids:
# fetch URLs from keybase
try:
......@@ -326,6 +336,8 @@ if __name__ == '__main__':
'--search-keys',
'0x'+keyid], stdout=subprocess.PIPE)
if len(urls) > 0:
eprint('Trying to get key from URL')
for url in urls:
try:
result = urlopen(url)
......
......@@ -7,24 +7,24 @@
# the output file name.
#
VERSION="0.1.0"
VERSION="0.1.1"
SELF="$(basename $0)"
XZ=""
[ -x "$(which xz)" ] && XZ="xz"
[ -x "$(which pixz)" ] && XZ="pixz"
[ -x "$(which xz 2>/dev/null)" ] && XZ="xz"
[ -x "$(which pixz 2>/dev/null)" ] && XZ="pixz"
GZ=""
[ -x "$(which gzip)" ] && GZ="gzip"
[ -x "$(which pigz)" ] && GZ="pigz"
[ -x "$(which gzip 2>/dev/null)" ] && GZ="gzip"
[ -x "$(which pigz 2>/dev/null)" ] && GZ="pigz"
BZ=""
[ -x "$(which bzip2)" ] && BZ="bzip2"
[ -x "$(which bzip2 2>/dev/null)" ] && BZ="bzip2"
ZP=""
[ -x "$(which zip)" ] && ZP="zip"
[ -x "$(which zip 2>/dev/null)" ] && ZP="zip"
PACKER="$XZ"
[ -z "$PACKER" ] && PACKER="$BZ"
[ -z "$PACKER" ] && PACKER="$GZ"
[ -z "$PACKER" ] && PACKER="$ZP"
TAR="$(which tar)"
TAR="$(which tar 2>/dev/null)"
DATE="$(date +%Y-%m-%d-)"
TIME="$(date +%H-%M-%S-)"
......@@ -157,7 +157,7 @@ case "$PACKER" in
*) exit -4 ;;
esac
PACKER="$(which $PACKER)"
PACKER="$(which $PACKER 2>/dev/null)"
if [ -z "$PACKER" ]
then
echo "Compression format not available"
......@@ -172,20 +172,28 @@ then
fi
BASENAME="$USE_DATE$USE_TIME$BASENAME"
OLDIFS=$IFS
IFS="$(printf '\n\t')"
result=-3
if [[ "$PACKER" =~ [^bg]zip$ ]]
then
# zip doesn't care if it's one or many
exec $PACKER r "$BASENAME$EXT" $@
$PACKER r "$BASENAME$EXT" $@
result=$?
elif [ $# -gt 1 -o ! -f "$1" ]
then
exec $TAR -I"$PACKER" -cf "$BASENAME.tar$EXT" $@
$TAR -I"$PACKER" -cf "$BASENAME.tar$EXT" $@
result=$?
else
if [ -z "$USERBASENAME" ]
then
BASENAME="$(basename $1)"
fi
exec "$PACKER" -kc "$1" > "$BASENAME$EXT"
"$PACKER" -kc "$1" > "$BASENAME$EXT"
result=$?
fi
exit -3
IFS=$OLDIFS
exit $result
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment