]> git.donarmstrong.com Git - ca-certificates.git/blobdiff - sbin/update-ca-certificates
Broken symlinks on upgrade due to plain c_rehash call #643667
[ca-certificates.git] / sbin / update-ca-certificates
index 728e9099764456eb158fa88b0bc4ef0d3426414d..53759501cfcf738992e10b2ad075962cc50e2b6a 100755 (executable)
@@ -17,7 +17,8 @@
 #
 # 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301,
+# USA.
 #
 
 verbose=0
@@ -60,7 +61,9 @@ REMOVED="$(mktemp -t "ca-certificates.tmp.XXXXXX")"
 # bundle.
 add() {
   CERT="$1"
-  PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem"
+  PEM="$ETCCERTSDIR/$(basename "$CERT" .crt | sed -e 's/ /_/g' \
+                                                  -e 's/[()]/=/g' \
+                                                  -e 's/,/_/g').pem"
   if ! test -e "$PEM" || [ "$(readlink "$PEM")" != "$CERT" ]
   then
     ln -sf "$CERT" "$PEM"
@@ -118,14 +121,13 @@ done
 # administrator.
 if [ -d "$LOCALCERTSDIR" ]
 then
-  find -L "$LOCALCERTSDIR" -type f | while read crt
+  find -L "$LOCALCERTSDIR" -type f -name '*.crt' | while read crt
   do
     add "$crt"
   done
 fi
 
-chmod 0644 "$TEMPBUNDLE"
-mv -f "$TEMPBUNDLE" "$CERTBUNDLE"
+rm -f "$CERTBUNDLE"
 
 ADDED_CNT=$(wc -l < "$ADDED")
 REMOVED_CNT=$(wc -l < "$REMOVED")
@@ -135,19 +137,22 @@ then
   # only run if set of files has changed
   if [ "$verbose" = 0 ]
   then
-    c_rehash . > /dev/null 2>&1
+    c_rehash . > /dev/null
   else
     c_rehash .
   fi
 fi
 
+chmod 0644 "$TEMPBUNDLE"
+mv -f "$TEMPBUNDLE" "$CERTBUNDLE"
+
 echo "$ADDED_CNT added, $REMOVED_CNT removed; done."
 
 HOOKSDIR=/etc/ca-certificates/update.d
 echo -n "Running hooks in $HOOKSDIR...."
 VERBOSE_ARG=
 [ "$verbose" = 0 ] || VERBOSE_ARG=--verbose
-eval run-parts $VERB_ARG --test -- $HOOKSDIR | while read hook
+eval run-parts $VERBOSE_ARG --test -- $HOOKSDIR | while read hook
 do
   ( cat $ADDED
     cat $REMOVED ) | $hook || echo E: $hook exited with code $?.