Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 3.133.136.95
#!/bin/sh
run_cmd() {
CMD="$1"
shift
unset LD_LIBRARY_PATH
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
[ -z "${XDG_DATA_HOME:-}" ] && export XDG_DATA_HOME="${HOME}/.local/share/"
[ -z "${XDG_CONFIG_HOME:-}" ] && export XDG_CONFIG_HOME="${HOME}/.config/"
[ -z "${XDG_STATE_HOME:-}" ] && export XDG_STATE_HOME="${HOME}/.local/state/"
# shellcheck disable=SC2145
exec unshare --kill-child -U -m -p -r -f -R "/var/lib/snapd/hostfs/" "/bin/sh" -c "mount -t proc proc /proc 2>/dev/null || true; exec \"${CMD}\" \"$@\""
}
USERNS=1
[ -e /proc/sys/kernel/unprivileged_userns_clone ] && grep -qxF 0 /proc/sys/kernel/unprivileged_userns_clone && USERNS=0
[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_userns && USERNS=0
[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined && USERNS=0
find_and_spawn() {
for path in / /usr/ /usr/local/; do
if [ -e "/var/lib/snapd/hostfs/${path}bin/${1}" ] || [ -L "/var/lib/snapd/hostfs/${path}bin/${1}" ]; then
run_cmd "$@"
fi
done
}
EDIT_CMD="${1}"
EDIT_PATH="${2}"
if [ -z "${EDIT_PATH}" ] || [ "$#" -ge "3" ]; then
EDIT_CMD=""
for arg in "${@}"; do
EDIT_PATH="${arg}"
done
fi
# Try running the editor through the host.
if [ -n "${EDIT_CMD}" ] && [ "${USERNS}" = 1 ]; then
exec 9< /tmp/
# Replace "/tmp/" prefix by exec'ed FD 9.
EDIT_PATH_HOST="/proc/self/fd/9/$(echo "${EDIT_PATH}" | cut -d/ -f3)"
find_and_spawn "${EDIT_CMD}" "${EDIT_PATH_HOST}"
fi
# If the editor's rcfile is not readable, ignore it.
EDIT_IGNORE_RC=""
EDIT_RESTRICT=""
# Default to built-in nano.
if [ -z "${EDIT_CMD}" ]; then
EDIT_CMD="nano"
EDIT_RESTRICT="--restricted"
[ -r "${SNAP}/etc/nanorc" ] || EDIT_IGNORE_RC="--ignorercfiles"
fi
# Setup for VIM.
if [ "$EDIT_CMD" != "nano" ]; then
# Find the base use by the LXD snap.
for vimrc in "${SNAP_USER_COMMON}/.vimrc" "/snap/core20/current/etc/vim/vimrc"; do
[ -r "${vimrc}" ] || continue
export VIMINIT="source ${vimrc}"
done
# Ignore vimrc if none was found to be readable.
if [ -z "${VIMINIT:-""}" ]; then
EDIT_IGNORE_RC="--clean"
fi
EDIT_CMD="vim.tiny"
EDIT_RESTRICT="-Z"
fi
# Run the editor.
exec "${EDIT_CMD}" ${EDIT_RESTRICT} ${EDIT_IGNORE_RC} "${EDIT_PATH}"
|