Files
docker-easyconnect/build-scripts/install-vpn-gui.sh
Hagb 71f1b24974 Fix aTrust on podman and other potential errors about aTrust
On docker, `/proc/self/loginuid` is -1 by default, while on podman it is
0 (root), which makes aTrust services refuse to start, because after they
use `getlogin_r`, which is affected by `/proc/self/loginuid`, to get the
username successfully, they give up trying any other way (such as
`loginctl`) to get the non-root user used to start the http server (port
54631), even if the username they got is root.

This commit adds a LD_PRELOAD hook named fake-getlogin, which hooks
`getlogin` and `getlogin_r` to provide the non-root username directly.

This commit also:
- reduces errors when running postinst script of aTrust;
- uses LD_LIBRARY_PATH to make aTrust use its versions of libraries,
  especially those very old and no longer getatable from debian
  packages.
2024-07-07 07:01:50 +08:00

63 lines
2.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "$VPN_TYPE" > /etc/vpn-type &&
cd /tmp &&
. ./build-scripts/get-echost-names.sh &&
if [ -z "${VPN_DEB_PATH}" ]; then
busybox wget "${VPN_URL}" -O VPN.deb
else
busybox wget "${VPN_URL}" -O VPN.zip &&
busybox unzip -p VPN.zip "${VPN_DEB_PATH}" > VPN.deb &&
rm VPN.zip
fi &&
dpkg-deb -R VPN.deb / &&
package_name=$(echo $(grep -Po '(?<=Package:).*' /DEBIAN/control)) &&
{ /DEBIAN/preinst || true ; } &&
mkdir /var/lib/dpkg/info/$package_name &&
for file in /DEBIAN/*; do
cp "$file" /var/lib/dpkg/info/"$package_name.$(basename $file)" &&
# workaround for aTrust scripts
cp "$file" /var/lib/dpkg/info/"$(basename $file)"
done &&
/var/lib/dpkg/info/$package_name.postinst &&
for file in /DEBIAN/*; do
rm /var/lib/dpkg/info/"$(basename $file)"
done &&
rm -r /DEBIAN VPN.deb &&
if [ -e /home/sangfor/ ]; then
chown sangfor:sangfor -R /home/sangfor/
fi &&
ln -fs /bin/false /usr/sbin/dmidecode &&
if [ "EC_CLI" != "$VPN_TYPE" -a "EC_GUI" != "$VPN_TYPE" ]; then
exit 0
fi &&
extra_bins=EasyMonitor ./build-scripts/mk-qemu-wrapper.sh &&
rm -f /usr/share/sangfor/EasyConnect/resources/conf/easy_connect.json &&
mv /usr/share/sangfor/EasyConnect/resources/conf/ /usr/share/sangfor/EasyConnect/resources/conf_backup &&
if ! is_echost_foreign && [ ! -z "${USE_VPN_ELECTRON}" ] ; then
exit 0
fi &&
declare -A ELECTRON_URLS &&
# v1.8 以下的 electron 无官方 arm64、mips64el 构建
# armhf 在 v1.8.2-beta4 到 v1.8.8 无法渲染https://github.com/electron/electron/issues/11797
ELECTRON_URLS=(
[amd64]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-x64.zip
[i386]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-ia32.zip
[armhf]=https://github.com/electron/electron/releases/download/v1.7.16/electron-v1.7.16-linux-armv7l.zip
[arm64]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-arm64.zip
[mips64el]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-mips64el.zip
) &&
if [ -z "${ELECTRON_URL}" ]; then
ELECTRON_URL="${ELECTRON_URLS[$(dpkg --print-architecture)]}"
fi &&
busybox wget "${ELECTRON_URL}" -O electron.zip &&
busybox unzip electron.zip -od /usr/share/sangfor/EasyConnect/ &&
rm electron.zip &&
mv /usr/share/sangfor/EasyConnect/{electron,EasyConnect}