-
Notifications
You must be signed in to change notification settings - Fork 0
/
sbu-list-sigs.sh.in
executable file
·108 lines (88 loc) · 2.14 KB
/
sbu-list-sigs.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
usage () {
local old_xtrace
old_xtrace="$(shopt -po xtrace || :)"
set +o xtrace
{
echo "${script_name} - List signature certificates of signed files."
echo "Usage: ${script_name} [flags] in-file [in-file]..."
echo "Option flags:"
echo " -h --help - Show this help and exit."
echo " -v --verbose - Verbose execution."
echo " -g --debug - Extra verbose execution."
echo "Info:"
echo ' @PACKAGE_NAME@ v@PACKAGE_VERSION@'
echo ' @PACKAGE_URL@'
echo " Send bug reports to: Geoff Levand <[email protected]>."
} >&2
eval "${old_xtrace}"
}
process_opts() {
local short_opts="hvg"
local long_opts="help,verbose,debug"
usage=''
verbose=''
local opts
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${script_name}" -- "$@")
eval set -- "${opts}"
while true ; do
# echo "${FUNCNAME[0]}: (${#}) '${*}'" >&2
case "${1}" in
-h | --help)
usage=1
shift
;;
-v | --verbose)
verbose=1
shift
;;
-g | --debug)
verbose=1
debug=1
set -x
shift
;;
--)
shift
in_files=("$@")
break
;;
*)
echo "${script_name}: ERROR: Internal opts: '${*}'" >&2
exit 1
;;
esac
done
}
#===============================================================================
export PS4='\[\e[0;33m\]+ ${BASH_SOURCE##*/}:${LINENO}:(${FUNCNAME[0]:-main}):\[\e[0m\] '
script_name="${0##*/}"
base_name="${script_name##*/%}"
base_name="${base_name%.sh}"
real_source="$(realpath "${BASH_SOURCE}")"
SCRIPT_TOP="$(realpath "${SCRIPT_TOP:-${real_source%/*}}")"
start_time="$(date +%Y.%m.%d-%H.%M.%S)"
SECONDS=0
trap "on_exit 'Failed'" EXIT
trap 'on_err ${FUNCNAME[0]:-main} ${LINENO} ${?}' ERR
set -eE
set -o pipefail
set -o nounset
source "${SCRIPT_TOP}/sbu-lib.sh"
source "${SCRIPT_TOP}/tdd-lib/util.sh"
declare -a in_files
process_opts "${@}"
if [[ ${usage} ]]; then
usage
trap - EXIT
exit 0
fi
check_sb_progs
check_in_files "${in_files[@]}"
echo "Generated by ${script_name} (Secure Boot Utils) - ${start_time}"
echo 'https://github.com/glevand/secure-boot-utils'
for f in "${in_files[@]}"; do
list_file_cert "${f}"
done
trap "on_exit 'Success.'" EXIT
exit 0