-
-
Save deeagle/768bc0b50bf705e6edb027a04c14c076 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Needed for debian upgrade | |
# atm from buster to bullseye the linked libs are broken | |
# see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951880 | |
LIB="libcrypt.so.1" | |
# Checks if the executer has super user permissions. | |
# | |
# @exit 2 if the user has no super user permissions | |
function validateRootPermissions() { | |
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | |
echo "[ERR!] script must be run as root (sudo) and you're not root." | |
exit 2 | |
fi | |
} | |
# Validates the existing of: | |
# - the source library exists (normally a link to the lib file) | |
# - both destinations are symlinks | |
function validateLibsExists() { | |
if [[ ! -f "/lib/x86_64-linux-gnu/${LIB}" ]]; then | |
echo "ERROR: Library file </lib/x86_64-linux-gnu/${LIB}> does not exists." | |
exit 1 | |
fi | |
if [[ ! -L "/lib64/${LIB}" ]]; then | |
echo "ERROR: Library symlink </lib64/${LIB}> does not exists." | |
exit 2 | |
fi | |
if [[ ! -L "/lib/x86_64-linux-gnu/${LIB}" ]]; then | |
echo "ERROR: Library symlink </lib/x86_64-linux-gnu/${LIB}> does not exists." | |
exit 3 | |
fi | |
} | |
# Analyse the src and dest libs and if they link this src lib. | |
function analyseLibLinks() { | |
validateLibsExists | |
local correctPathSrcLib="$(readlink -f "/lib/x86_64-linux-gnu/${LIB}")" | |
if [[ $(readlink -f "/lib64/${LIB}") = "${correctPathSrcLib}" ]]; then | |
echo "[ ok ] $(ls -la "/lib64/${LIB}")" | |
else | |
echo "[ERR!] $(ls -la "/lib64/${LIB}")" | |
fi | |
if [[ $(readlink -f "/lib/x86_64-linux-gnu/${LIB}") = "${correctPathSrcLib}" ]]; then | |
echo "[ ok ] $(ls -la "/lib/x86_64-linux-gnu/${LIB}")" | |
else | |
echo "[ERR!] $(ls -la "/lib/x86_64-linux-gnu/${LIB}")" | |
fi | |
} | |
# Simple list of the symlinks to check. | |
function showLibLinks() { | |
ls -la "/lib64/${LIB}" | |
ls -la "/lib/x86_64-linux-gnu/${LIB}" | |
} | |
# Removes the old links and set the new symlinks. | |
function changeLibLinks() { | |
sudo rm "/lib64/${LIB}" | |
sudo rm "/lib/x86_64-linux-gnu/${LIB}" | |
sudo ln -s "/usr/lib/x86_64-linux-gnu/${LIB}" "/lib64/${LIB}" | |
sudo ln -s "/usr/lib/x86_64-linux-gnu/${LIB}" "/lib/x86_64-linux-gnu/${LIB}" | |
} | |
# Prints the help to stdout. | |
function printHelp() { | |
cat <<EOF | |
Project: rlxcrypt | |
Desc: Repair lib error XCRYPT2.x, XCRYPT4.4 not found. | |
Version: 0.0.2 | |
Infos: Martin Kock <[email protected]> | |
Possible options: | |
-a | --analyse Show the actual linked libraries | |
-r | --repair Change the library links to </usr/lib/x86_64-linux-gnu/${LIB} | |
-h | --help prints this help | |
EOF | |
} | |
# Catch arguments and go | |
if [[ $# -eq 0 ]]; then | |
# starts the main function | |
printHelp | |
else | |
case "${1}" in | |
-a | --analyse) | |
analyseLibLinks | |
;; | |
-r | --repair) | |
validateRootPermissions | |
changeLibLinks | |
;; | |
-h | --help | *) | |
printHelp | |
;; | |
esac | |
fi | |
exit 0 |
Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=974552
Hi,
Tried your script, to fix perl issue but still getting errors:
root@rescue:/usr/lib/x86_64-linux-gnu# ./repairlibcrypt.sh -a [ ok ] lrwxrwxrwx 1 root root 39 May 16 10:07 /lib64/libcrypt.so.1 -> /usr/lib/x86_64-linux-gnu/libcrypt.so.1 [ ok ] lrwxrwxrwx 1 root root 39 May 16 10:07 /lib/x86_64-linux-gnu/libcrypt.so.1 -> /usr/lib/x86_64-linux-gnu/libcrypt.so.1 root@rescue:/usr/lib/x86_64-linux-gnu# apt-get upgrade Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y /usr/bin/perl: /usr/lib/x86_64-linux-gnu/libcrypt.so.1: version
XCRYPT_2.0' not found (required by /usr/bin/perl)
Setting up linux-image-5.10.0-6-amd64 (5.10.28-1) ...
/usr/bin/perl: /usr/lib/x86_64-linux-gnu/libcrypt.so.1: version XCRYPT_2.0' not found (required by /usr/bin/perl) dpkg: error processing package linux-image-5.10.0-6-amd64 (--configure): installed linux-image-5.10.0-6-amd64 package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: linux-image-5.10.0-6-amd64 E: Sub-process /usr/bin/dpkg returned an error code (1)
I have always been in branch testing, recently after the update I received the error XCRYPT_2.0 'not found and relative KP on boot.
I recovered a previous backup with rsync but running your script and do apt update I always get the above error and KP on boot.
Is there any way to fix the error?
kind regards
Hey, thx for your feedback. @HazMatt69 @famarm
I could not solve the problem yet either.
Through the log script and further bug reports I have managed an approximation. With some bullseye-container diffs I could find the following fix for me.
- I upgrade the system as root only (
sudo
won't work because it can break while upgrade!) - I test the runtime with
perl -v
- ok -> done
- error -> next step
- I checked my installation of libcrypt:
ll /lib64/libcrypt.so.1
=> links tolibcrypt.so.1
-> links tolibcrypt-2.19.so
libcrypt-2.19.so
is wrong! bullseye runlibc-2.31
-> delete the linkrm /lib64/libcrypt.so.1
- adapt the link
ln -s /lib/x86_64-linux-gnu/libcrypt.so.1 /lib64/libcrypt.so.1
- test again
perl -v
-> it works! - test sudo
sudo su
-> it works! => done
Maybe this will help you
Here the repair steps as script.
- upgrade the system as root only (sudo won't work because it can break while upgrade!)
- if you saw an error while update
- something like this
Processing triggers for initramfs-tools (0.140) ... /usr/bin/perl: /lib64/libcrypt.so.1: version `XCRYPT_2.0' not found (required by /usr/bin/perl) /usr/bin/perl: /lib64/libcrypt.so.1: version `XCRYPT_2.0' not found (required by /usr/bin/perl) dpkg: error processing package initramfs-tools (--configure): installed initramfs-tools package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: initramfs-tools E: Sub-process /usr/bin/dpkg returned an error code (1)
- something like this
- run the following script
#!/bin/bash rm /lib64/libcrypt.so.1 ln -s /lib/x86_64-linux-gnu/libcrypt.so.1 /lib64/libcrypt.so.1 # shows your current perl version -> system ok perl -v >/dev/null && echo "[ OK ] libcrypt spot is correct" || echo "[ERR!] libcrypt spot seems not correct (can't run perl -v) don't logout root-shell"
edit: add echo
to perl -v
-call
Sorry but the solution you wrote did not solve for me.
I keep getting the error after the update and go to KP.
I have to restore with rsync to have a bootable system again.
@famarm I'm sorry about that, but good thing you have a backup of the pre-situation.
My system runs clean with this workaround but I run the following cli loop til apt
says "nothing to do":
apt upgrade -yq
bash repair-libcrypt-v2.sh
Overall, though, this is a really terrible situation. Yes, it is testing, but I would have thought that the kind of bugs are found between unstable and testing.
Let's see how to support the community process in the future.
Good luck too you
After spending even more time on this issue, I found a simple way of fixing all the lib related issues that pop up during the upgrade, since there is a bunch.
Simply install usrmerge, modify the script to remove the files located in the /usr directories when it errors, run till it's finally happy and run the upgrade afterwards. Just works.
Update: I need to log this problematic packages, so i implement a simple log script: https://gist.github.com/deeagle/6ee1129a4e893d04c9ee98e69a7e0839