6b13f685e
김민수
BSP 최초 추가
|
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
109
110
111
112
113
114
115
116
117
118
|
set -e
while getopts :q OPT; do
case "${OPT}" in
q) exec >/dev/null;;
\?) exit 1;;
esac
done
shift $((OPTIND-1))
h_file="${1}"
file="${2}"
base="${3}"
if [ -z "${h_file}" ]; then
exit 0
fi
if [ ! -f "${h_file}" ]; then
printf "WARNING: no hash file for %s
" "${base}" >&2
exit 0
fi
check_one_hash() {
_h="${1}"
_known="${2}"
_file="${3}"
case "${_h}" in
none)
return 0
;;
md5|sha1) ;;
sha224|sha256|sha384|sha512) ;;
*)
printf "ERROR: unknown hash '%s' for '%s'
" \
"${_h}" "${base}" >&2
exit 4
;;
esac
_hash=$( ${_h}sum "${_file}" |cut -d ' ' -f 1 )
if [ "${_hash}" = "${_known}" ]; then
printf "%s: OK (%s: %s)
" "${base}" "${_h}" "${_hash}"
return 0
fi
printf "ERROR: %s has wrong %s hash:
" "${base}" "${_h}" >&2
printf "ERROR: expected: %s
" "${_known}" >&2
printf "ERROR: got : %s
" "${_hash}" >&2
printf "ERROR: Incomplete download, or man-in-the-middle (MITM) attack
" >&2
exit 2
}
nb_checks=0
while read t h f; do
case "${t}" in
''|'#'*)
continue
;;
*)
if [ "${f}" = "${base}" ]; then
check_one_hash "${t}" "${h}" "${file}"
: $((nb_checks++))
fi
;;
esac
done <"${h_file}"
if [ ${nb_checks} -eq 0 ]; then
case " ${BR_NO_CHECK_HASH_FOR} " in
*" ${base} "*)
exit 0
;;
esac
printf "ERROR: No hash found for %s
" "${base}" >&2
exit 3
fi
|