Skip to content

Commit e8efc2b

Browse files
committed
Make use of glob patterns valid for files
Closes #17
1 parent 6120820 commit e8efc2b

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

cryptboot-efikeys

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ exit_no_keys() {
4040
var_invalid_warning() {
4141
log_warning "'${1}' is invalid in '${2}'."
4242
}
43+
var_invalid_err() {
44+
log_err "'${1}' is invalid in '${2}'."
45+
}
4346

4447
# Default path for cryptboot.conf
4548
CONFIGURATION_FILE=/etc/cryptboot.conf
@@ -298,15 +301,23 @@ sign)
298301
exit_no_keys "${EFI_KEYS_DIR:?}/keys" "${0}"
299302
fi
300303

301-
# Sign FILENAME
302-
sbverify --cert ./db.crt "${FILENAME}" ||
303-
{
304-
echo "Signing file '${FILENAME}' with UEFI Secure Boot keys..."
305-
sbsign --key ./db.key --cert ./db.crt --output "${FILENAME}" "${FILENAME}"
304+
# Sign valid files included in FILENAME
305+
for file in ${FILENAME}; do
306+
[[ -f "${file}" ]] ||
307+
{
308+
var_invalid_err "${file}" "${FILENAME}"
309+
exit 1
310+
}
311+
# Sign file
312+
sbverify --cert ./db.crt "${file}" ||
313+
{
314+
echo "Signing file '${file}' with UEFI Secure Boot keys..."
315+
sbsign --key ./db.key --cert ./db.crt --output "${file}" "${file}"
316+
}
317+
done
306318

307-
## Synchronize cached writes to persistent storage
308-
sync
309-
}
319+
# Synchronize cached writes to persistent storage
320+
sync
310321
;;
311322
verify)
312323
# cd to EFI_KEYS_DIR/keys and check arguments
@@ -319,14 +330,21 @@ verify)
319330
exit_no_keys "${EFI_KEYS_DIR:?}/keys" "${0}"
320331
fi
321332

322-
# List signatures in FILENAME
323-
echo "List of all signatures in '${FILENAME}':"
324-
sbverify --list "${FILENAME}"
325-
echo ""
326-
327-
# Verify FILENAME
328-
echo "Verifying signature with UEFI Secure Boot keys..."
329-
sbverify --cert ./db.crt "${FILENAME}"
333+
# Verify valid files included in FILENAME
334+
for file in ${FILENAME}; do
335+
[[ -f "${file}" ]] ||
336+
{
337+
var_invalid_err "${file}" "${FILENAME}"
338+
exit 1
339+
}
340+
# List signatures in FILENAME
341+
echo "List of all signatures in '${file}':"
342+
sbverify --list "${file}"
343+
echo ""
344+
# Verify FILENAME
345+
echo "Verifying signature with UEFI Secure Boot keys..."
346+
sbverify --cert ./db.crt "${file}"
347+
done
330348
;;
331349
list)
332350
# List all UEFI Secure Boot keys enrolled in your UEFI firmware

0 commit comments

Comments
 (0)