Skip to content

Instantly share code, notes, and snippets.

@jpramosi
Created December 25, 2021 15:04
Show Gist options
  • Save jpramosi/e5694c1f858a92205929060e64358be7 to your computer and use it in GitHub Desktop.
Save jpramosi/e5694c1f858a92205929060e64358be7 to your computer and use it in GitHub Desktop.
A fixed version that doesn't crash the plasma desktop environment (atleast for me)
#!/bin/sh -e
#
# update-ca-certificates-fix
#
# Copyright (c) 2003 Fumitoshi UKAI <[email protected]>
# Copyright (c) 2009 Philipp Kern <[email protected]>
# Copyright (c) 2021 jpramosi <[email protected]>
#
# 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.
#
verbose=0
fresh=0
default=0
CERTSCONF=/etc/ca-certificates.conf
CERTSDIR=/usr/share/ca-certificates
LOCALCERTSDIR=/usr/local/share/ca-certificates
CERTBUNDLE=ca-certificates.crt
ETCCERTSDIR=/etc/ssl/certs
HOOKSDIR=/etc/ca-certificates/update.d
while [ $# -gt 0 ];
do
case $1 in
--verbose|-v)
verbose=1;;
--fresh|-f)
fresh=1;;
--default|-d)
default=1
fresh=1;;
--certsconf)
shift
CERTSCONF="$1";;
--certsdir)
shift
CERTSDIR="$1";;
--localcertsdir)
shift
LOCALCERTSDIR="$1";;
--certbundle)
shift
CERTBUNDLE="$1";;
--etccertsdir)
shift
ETCCERTSDIR="$1";;
--hooksdir)
shift
HOOKSDIR="$1";;
--help|-h|*)
echo "$0: [--verbose] [--fresh]"
exit;;
esac
shift
done
if [ ! -s "$CERTSCONF" ]
then
fresh=1
fi
cleanup() {
rm -f "$TEMPBUNDLE"
rm -f "$ADDED"
rm -f "$REMOVED"
}
trap cleanup 0
# Helper files. (Some of them are not simple arrays because we spawn
# subshells later on.)
TEMPBUNDLE="$(mktemp -t "${CERTBUNDLE}.tmp.XXXXXX")"
ADDED="$(mktemp -t "ca-certificates.tmp.XXXXXX")"
REMOVED="$(mktemp -t "ca-certificates.tmp.XXXXXX")"
# Adds a certificate to the list of trusted ones. This includes a symlink
# in /etc/ssl/certs to the certificate file and its inclusion into the
# bundle.
add() {
CERT="$1"
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"
echo "+$PEM" >> "$ADDED"
fi
# Add trailing newline to certificate, if it is missing (#635570)
sed -e '$a\' "$CERT" >> "$TEMPBUNDLE"
}
remove() {
CERT="$1"
PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem"
if test -L "$PEM"
then
rm -f "$PEM"
echo "-$PEM" >> "$REMOVED"
fi
}
cd "$ETCCERTSDIR"
if [ "$fresh" = 1 ]; then
echo "Clearing symlinks in $ETCCERTSDIR..."
find . -type l -print | while read symlink
do
case $(readlink "$symlink") in
$CERTSDIR*|$LOCALCERTSDIR*) rm -f $symlink;;
esac
done
find . -type l -print | while read symlink
do
test -f "$symlink" || rm -f "$symlink"
done
echo "done."
fi
echo "Updating certificates in $ETCCERTSDIR..."
# Add default certificate authorities if requested
if [ "$default" = 1 ]; then
find -L "$CERTSDIR" -type f -name '*.crt' | sort | while read crt
do
add "$crt"
done
fi
# Handle certificates that should be removed. This is an explicit act
# by prefixing lines in the configuration files with exclamation marks (!).
sed -n -e '/^$/d' -e 's/^!//p' "$CERTSCONF" | while read crt
do
remove "$CERTSDIR/$crt"
done
sed -e '/^$/d' -e '/^#/d' -e '/^!/d' "$CERTSCONF" | while read crt
do
if ! test -f "$CERTSDIR/$crt"
then
echo "W: $CERTSDIR/$crt not found, but listed in $CERTSCONF." >&2
continue
fi
add "$CERTSDIR/$crt"
done
# Now process certificate authorities installed by the local system
# administrator.
if [ -d "$LOCALCERTSDIR" ]
then
find -L "$LOCALCERTSDIR" -type f -name '*.crt' | sort | while read crt
do
add "$crt"
done
fi
rm -f "$CERTBUNDLE"
ADDED_CNT=$(wc -l < "$ADDED")
REMOVED_CNT=$(wc -l < "$REMOVED")
if [ "$ADDED_CNT" -gt 0 ] || [ "$REMOVED_CNT" -gt 0 ]
then
# only run if set of files has changed
# Remove orphan symlinks found in ETCCERTSDIR to prevent `openssl rehash`
# from exiting with an error. See #895482, #895473.
# finding orphan symlinks with:
# find $ETCCERTSDIR -type l ! -exec test -e {} \; -print | while read orphan
# can crash plasma desktop environments
find $ETCCERTSDIR -xtype l | while read orphan
do
rm -f "$orphan"
if [ "$verbose" = 1 ]; then
echo "Removed orphan symlink $orphan"
fi
done
if [ "$verbose" = 0 ]
then
openssl rehash . > /dev/null
else
openssl rehash -v .
fi
fi
chmod 0644 "$TEMPBUNDLE"
mv -f "$TEMPBUNDLE" "$CERTBUNDLE"
# Restore proper SELinux label after moving the file
[ -x /sbin/restorecon ] && /sbin/restorecon "$CERTBUNDLE" >/dev/null 2>&1
echo "$ADDED_CNT added, $REMOVED_CNT removed; done."
if [ -d "$HOOKSDIR" ]
then
echo "Running hooks in $HOOKSDIR..."
VERBOSE_ARG=
[ "$verbose" = 0 ] || VERBOSE_ARG="--verbose"
eval run-parts "$VERBOSE_ARG" --test -- "$HOOKSDIR" | while read hook
do
( cat "$ADDED"
cat "$REMOVED" ) | "$hook" || echo "E: $hook exited with code $?."
done
echo "done."
fi
# vim:set et sw=2:
@jpramosi
Copy link
Author

update-ca-certificates-fix-diff

crash.log
Clearing symlinks in /etc/ssl/certs...
done.
Updating certificates in /etc/ssl/certs...
"Application plasmashell could not be found using service org.kde.plasmashell and path /MainApplication."
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Omitting both --window and --windowclass arguments is not recommended
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kf.coreaddons: Expected JSON property "X-Plasma-ContainmentCategories" to be a string list. Treating it as a list with a single entry: "panel" org.kde.plasma.desktop.defaultPanel
kf.coreaddons: Expected JSON property "X-Plasma-ContainmentCategories" to be a string list. Treating it as a list with a single entry: "panel" org.kde.plasma.desktop.appmenubar
kf.coreaddons: Expected JSON property "X-Plasma-ContainmentCategories" to be a string list. Treating it as a list with a single entry: "panel" org.kde.plasma.desktop.emptyPanel
QDBusConnection: name 'org.kde.kglobalaccel' had owner '' but we thought it was ':1.4'
kf.plasma.quick: Applet preload policy set to 1
qt.svg: <input>:406:376: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:407:130: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:408:130: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:408:393: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:409:130: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:410:129: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:411:129: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:412:129: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:413:129: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:413:379: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:413:631: Could not add child element to parent element because the types are incorrect.
trying to show an empty dialog
file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/libexec/kf5/klauncher'
kdeinit5: Launched KLauncher, pid = 3995, result = 0
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kdeinit5: opened connection to :0
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/desktop.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/desktop.so'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Plasma Shell startup completed
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Both point size and pixel size set. Using pixel size.
Both point size and pixel size set. Using pixel size.
Both point size and pixel size set. Using pixel size.
file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml:534:9: QML Label: Binding loop detected for property "height"
file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml:493:13: QML Label: Binding loop detected for property "height"
trying to show an empty dialog
file:///usr/share/plasma/plasmoids/org.kde.panel/contents/ui/main.qml:30:1: QML DropArea (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth"
file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml:493:13: QML Label: Binding loop detected for property "height"
file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml:534:9: QML Label: Binding loop detected for property "height"
file:///usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml:554:5: QML Label: Binding loop detected for property "height"
trying to show an empty dialog
Cyclic dependency detected between "file:///usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/global/Globals.qml" and "file:///usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/NotificationHeader.qml"
libkcups: CUPS-Get-Printers last error: 1030 No destinations added.
libkcups: Create-Printer-Subscriptions last error: 0 successful-ok
libkcups: Get-Jobs last error: 0 successful-ok
libkcups: Get-Jobs last error: 0 successful-ok
libkcups: 0
libkcups: 0
trying to show an empty dialog
file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
file:///usr/share/plasma/shells/org.kde.plasma.desktop/contents/views/Desktop.qml:146:19: QML Loader: Binding loop detected for property "height"
kf.kirigami: Warning: Theme implementations should use Kirigami.BasicThemeDefinition for its root item
kf.i18n: "0 instead of 2 arguments to message {%1 — %2} supplied before conversion."
Both point size and pixel size set. Using pixel size.
Entry is not valid "org.kde.kontact.desktop" QSharedPointer(0x5652f005e5e0)
Entry is not valid "libreoffice-startcenter.desktop" QSharedPointer(0x5652f005e7f0)
Entry is not valid "org.kde.kontact.desktop" QSharedPointer(0x5652f0064f70)
Entry is not valid "libreoffice-startcenter.desktop" QSharedPointer(0x5652f00649f0)
trying to show an empty dialog
file:///usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/ui/LeaveButtons.qml:69:5: QML ToolButton: Binding loop detected for property "display"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kdeinit5: Got EXEC_NEW '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so' from launcher.
kdeinit5: preparing to launch '/usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/kio/file.so'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
trying to show an empty dialog
file:///usr/lib/x86_64-linux-gnu/qt5/qml/org/kde/plasma/components/ModelContextMenu.qml:38:1: QML ModelContextMenu: Accessible must be attached to an Item
file:///usr/share/plasma/plasmoids/org.kde.plasma.printmanager/contents/ui/PopupDialog.qml:91:17: Unable to assign [undefined] to QString
The X11 connection broke (error 1). Did the X11 server die?
kdeinit5: Fatal IO error: client killed
klauncher: Exiting on signal 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment