Pkg test: use dpkg to find libnss_wrapper.so

This commit is contained in:
Dmitry Maksyoma 2021-01-28 23:35:57 +13:00
parent 6d6ebffeae
commit ead31ae2e7

View File

@ -1,3 +1,20 @@
detect_libnss_wrapper() {
if $(which dpkg &>/dev/null); then
libnss_wrapper_file=$(dpkg -S libnss_wrapper.so | awk -F' ' '{ print $2 }')
LD_PRELOAD="$libnss_wrapper_file"
return
fi
if [ -r /usr/lib/libnss_wrapper.so ]; then
LD_PRELOAD=/usr/lib/libnss_wrapper.so
elif [ -r /usr/lib64/libnss_wrapper.so ]; then
LD_PRELOAD=/usr/lib64/libnss_wrapper.so
else
echo "no libnss_wrapper.so installed!"
exit 1
fi
}
# Set current user in nss_wrapper
USER_ID=$(id -u)
GROUP_ID=$(id -g)
@ -24,14 +41,7 @@ if [ x"$USER_ID" != x"0" ]; then
export NSS_WRAPPER_PASSWD
export NSS_WRAPPER_GROUP
if [ -r /usr/lib/libnss_wrapper.so ]; then
LD_PRELOAD=/usr/lib/libnss_wrapper.so
elif [ -r /usr/lib64/libnss_wrapper.so ]; then
LD_PRELOAD=/usr/lib64/libnss_wrapper.so
else
echo "no libnss_wrapper.so installed!"
exit 1
fi
detect_libnss_wrapper
echo "nss_wrapper location: $LD_PRELOAD"
export LD_PRELOAD
fi