mirror of
https://github.com/ben-grande/qusal.git
synced 2025-02-02 10:24:56 -05:00
fix: verify all subkeys expiration date
For: https://github.com/ben-grande/qusal/issues/46
This commit is contained in:
parent
2c91bf24ab
commit
40a4107290
@ -9,21 +9,35 @@ set -eu
|
|||||||
now="$(date +%s)"
|
now="$(date +%s)"
|
||||||
fail="0"
|
fail="0"
|
||||||
for key in "${@}"; do
|
for key in "${@}"; do
|
||||||
## TODO: exit only after evaluating all subkeys, not on the first error.
|
data="$(gpg --no-keyring --no-auto-check-trustdb --no-autostart \
|
||||||
gpg --no-keyring --no-auto-check-trustdb --no-autostart \
|
--with-colons --show-keys "${key}")"
|
||||||
--with-colons --show-keys "${key}" |
|
nr="$(echo "${data}" | awk '/^(p|s)ub:/' | wc -l | cut -d " " -f1)"
|
||||||
awk -v key="${key}" -v now="${now}" -F ':' '/^(p|s)ub:/ {
|
echo "${data}" | awk -v fail="0" -v key="${key}" -v nr="${nr}" \
|
||||||
|
-v now="${now}" -F ':' '/^(p|s)ub:/ {
|
||||||
|
nlines++;
|
||||||
|
|
||||||
if ($7=="") {
|
if ($7=="") {
|
||||||
|
if (nlines==nr) { if (fail==1) { exit 1; }; }
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($7<now) {
|
if ($7<now) {
|
||||||
print key ": expired:", $5 >"/dev/stderr";
|
print key ": expired:", $5 >"/dev/stderr";
|
||||||
exit 1
|
fail=1
|
||||||
|
if (nlines==nr) { if (fail==1) { exit 1; }; }
|
||||||
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# 60 days
|
# 60 days
|
||||||
else if (($7-now)<(60*60*24*60)) {
|
else if (($7-now)<(60*60*24*60)) {
|
||||||
print key ": expires soon:", $5 >"/dev/stderr";
|
print key ": expires soon:", $5 >"/dev/stderr";
|
||||||
exit 1
|
fail=1
|
||||||
|
if (nlines==nr) { if (fail==1) { exit 1; }; }
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fail==1) {
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
}' || fail="1"
|
}' || fail="1"
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user