配置使用 LD_PRELOAD 功能的应用程序的允许列表
注意:
使用 LD_PRELOAD 功能配置允许列表仅适用于适用于 Linux 的 Citrix Workspace™ 应用程序。
如果其他正在运行的应用程序使用 LD_PRELOAD,应用程序保护会阻止受保护会话的启动。如果存在真正的应用程序或经管理员批准,您可以使用允许列表功能。要允许使用其他使用 LD_PRELOAD 的应用程序,您必须配置允许列表。
如果其他使用 LD_PRELOAD 的应用程序正在运行,应用程序保护会阻止受保护会话启动。但如果存在合法的应用程序或经管理员批准,您可以使用允许列表功能。要允许这些应用程序运行,您需要设置允许列表。
您可以通过以下步骤将具有预加载功能的应用程序添加到允许列表:
- 识别阻止受保护的 VDA/应用程序会话启动的进程。
- 为允许列表创建配置文件并添加已识别的进程。
识别阻止受保护 VDA 启动的进程
当 AppProtection 因使用 LD_PRELOAD 而阻止受保护 VDA 启动时,请验证使用 LD_PRELOAD 的进程。可以将真正的进程添加到允许列表。
要识别使用 LD_PRELOAD 的进程,请使用以下脚本。将其保存为 .sh 扩展名并在终端窗口中以 sudo 运行:
#!/bin/bash
declare -A map
append_kv() {
local key="$1"
local val="$2"
local sep="$3"
if [[ -v "map[$key]" && -n "${map[$key]}" ]]; then
map["$key"]+="$sep$val"
else
map["$key"]="$val"
fi
}
escape_json_string() {
local str="$1"
# Escape backslashes first, then quotes, then other control characters
str="${str//\\/\\\\}" # \ → \\
str="${str//\"/\\\"}" # " → \"
str="${str//$'\t'/\\t}" # tab → \t
str="${str//$'\n'/\\n}" # newline → \n
str="${str//$'\r'/\\r}" # carriage return → \r
printf '%s' "$str"
}
print_procs_JSON() {
printf "{\n"
first=true
for key in "${!map[@]}"; do
if [ "$first" = true ]; then
first=false
else
printf ",\n"
fi
printf " \"%s\": \"%s\"" "$(escape_json_string "$key")" "$(escape_json_string "${map[$key]}")"
done
printf "\n}\n"
}
validate_json() {
local json="$1"
if command -v jq >/dev/null 2>&1; then
printf '%s' "$json" | jq -e . >/dev/null 2>&1
return $?
fi
if command -v python3 >/dev/null 2>&1; then
printf '%s' "$json" | python3 -c 'import json, sys; json.load(sys.stdin)' >/dev/null 2>&1
return $?
fi
# No validator available on PATH.
return 2
}
for pid in /proc/*/; do
pid=${pid%*/}
pid=${pid##*/}
# Only numeric /proc entries are process IDs.
[[ "$pid" =~ ^[0-9]+$ ]] || continue
environ_file="/proc/$pid/environ"
cmdline_file="/proc/$pid/cmdline"
if [[ ! -r "$environ_file" || ! -r "$cmdline_file" ]]; then
continue
fi
# Check if the process has the LD_PRELOAD environment variable set
ld_preload=$(cat "$environ_file" 2>/dev/null | tr '\0' '\n' | grep '^LD_PRELOAD=' | cut -d '=' -f 2-)
if [ -n "$ld_preload" ]; then
# Keep only argv[0] (the executable path/name) from cmdline.
cmdline=$(cat "$cmdline_file" 2>/dev/null | tr '\0' '\n' | head -n 1)
[ -n "$cmdline" ] || continue
# Output the LD_PRELOAD value and the process cmdline in JSON format
append_kv "LD_PRELOAD=$ld_preload" "$cmdline" "|"
fi
done
# Generate and validate JSON output before printing.
json_output="$(print_procs_JSON)"
if ! validate_json "$json_output"; then
status=$?
if [ "$status" -eq 2 ]; then
echo "Warning: could not validate JSON (no jq/python3 found)." >&2
printf '%s\n' "$json_output"
exit 0
fi
echo "Error: generated invalid JSON output." >&2
exit 1
fi
printf '%s\n' "$json_output"
<!--NeedCopy-->
根据上述脚本的输出,识别导致受保护 VDA 启动失败的进程,并将这些进程添加到允许列表。
以下是一个示例图像,显示了带有预加载列表的应用程序输出。

创建允许列表的配置文件
出于安全考虑,进程允许列表配置文件默认情况下不会安装。您需要在首次使用时创建此配置文件。
- Create an empty file named AppProtection_Preload_Allowlist.json in the “$ICAROOT/config/” folder.
-
以以下格式添加进程详细信息。第二个条目描述了如何管理在 LD_PRELOAD 中使用相同库的多个进程。
{ "LD_PRELOAD_PATH1" : "PROCESS_PATH1", "LD_PRELOAD_PATH2" : "PROCESS_PATH2|PROCESS_PATH3" } <!--NeedCopy-->以下是显示新添加配置的示例图像:

- Save the file and then set the permissions to the AppProtection_Preload_Allowlist.json file using the following command.
sudo chmod 644 $ICAROOT/config/AppProtection_Preload_Allowlist.json
注意:
配置条目中允许使用最小的正则表达式,以防止冗余。必须检查特殊的正则表达式字符并使用双反斜杠 (\) 进行转义。
- 例如,请考虑脚本输出如下所示:
LD_PRELOAD=:/snap/firmware-updater/226/gnome-platform/\\$LIB/bindtextdomain\\.so": "/snap/firmware-updater/226/bin/firmware-notifier
- 要使用像数字 126 这样的可变元素,可以使用正则表达式来实现更通用的允许列表条目:
LD_PRELOAD=:/snap/firmware-updater/\\d+/gnome-platform/\\$LIB/bindtextdomain\\.so": "/snap/firmware-updater/226/bin/firmware-notifier
- 您可以看到输出中包含“.”、“$”,它们是正则表达式模式中的特殊字符,并且已转义:
LD_PRELOAD=:/snap/firmware-updater/226/gnome-platform/\\$LIB/bindtextdomain\\.so": "/snap/firmware-updater/226/bin/firmware-notifier
- 如果存在其他特殊字符,例如
"(引号)或^(插入符号),请以相同的方式对其进行转义。