-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathupdate-ca-certificates
executable file
·113 lines (103 loc) · 2.77 KB
/
update-ca-certificates
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
#!/bin/bash
#
# update-ca-certificates
#
# Copyright (c) 2010,2013 SUSE Linux Products GmbH
# Copyright (c) 2020,2021 SUSE LLC
# Author: Ludwig Nussel
#
# Inspired by Debian's update-ca-certificates
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301,
# USA.
#
statedir='/var/lib/ca-certificates'
hooksdir1='/etc/ca-certificates/update.d'
hooksdir2='/usr/lib/ca-certificates/update.d'
verbose=
destdir=/
fresh=
export statedir
help_and_exit()
{
cat <<-EOF
USAGE: $0 [OPTIONS]
OPTIONS:
--verbose, -v verbose output
--root <Directory> Root directory to use (default: $destdir)
--fresh, -f start from scratch
--help, -h this screen
EOF
exit 0
}
args=("$@")
while [ $# -gt 0 ]; do
param="$1"
arg="$2"
test "$arg" = "${arg#-}" || arg=
shift
case "$param" in
-v|--verbose) verbose='-v' ;;
-f|--fresh) fresh='-f' ;;
-r|--root) destdir="$arg"; shift
if [ -z "$destdir" ]; then
echo "-r option requires parameter <directory>"
exit 1
fi
;;
-h|--help) help_and_exit ;;
-*) echo "invalid option: $param" >&2; exit 1 ;;
esac
done
# set sane umask
umask 0222;
case "${TRANSACTIONAL_UPDATE,,*}" in
true|yes|1)
[ -z "$verbose" ] || echo "transactional update in progress, not running any scripts" >&2
> /etc/pki/trust/.updated
exit 0
;;
esac
rm -f /etc/pki/trust/.updated
export destdir
install -d -m 0755 "$destdir/$statedir"
# serialize calls if we can
if [ -z "$_CA_CERTIFICATES_LOCKED" -a -x /usr/bin/flock ]; then
export _CA_CERTIFICATES_LOCKED="1"
set -- "${args[@]}"
exec /usr/bin/flock "$destdir/$statedir" "$0" "$@"
echo "failed to lock $destdir/$statedir\n" >&2
exit 1
fi
function find_hooks {
shopt -s nullglob
for hooksdir in $hooksdir1 $hooksdir2; do
for f in "$hooksdir"/*.run; do
if [ -L "$f" ] || [ -f "$f" ]; then
echo "${f##*/}" "$f"
fi
done
done
}
while read s f; do
if [ -L "$f" -a "`readlink "$f"`" = "/dev/null" ]; then
[ -z "$verbose" ] || echo "skipping $f"
continue
else
[ -z "$verbose" ] || echo "running $f .."
fi
"$f" $fresh $verbose
done < <(find_hooks|sort -k 1,1 -u)
chmod 0555 "$destdir/$statedir"