use DynamicUser instead of nobody

pull/102/head
W 2023-11-29 14:49:22 +08:00
parent 242123f0b0
commit b8f249d384
No known key found for this signature in database
GPG Key ID: CA4B4555280A26A5
1 changed files with 8 additions and 2 deletions

View File

@ -518,6 +518,12 @@ install_startup_service_file() {
temp_AmbientCapabilities="#${temp_AmbientCapabilities}" temp_AmbientCapabilities="#${temp_AmbientCapabilities}"
temp_NoNewPrivileges="#${temp_NoNewPrivileges}" temp_NoNewPrivileges="#${temp_NoNewPrivileges}"
fi fi
local temp_UserSet=""
if [[ "$INSTALL_USER" -eq 'nobody' ]]; then
temp_UserSet="DynamicUser=yes"
else
temp_UserSet="User=${INSTALL_USER}"
fi
cat > /etc/systemd/system/xray.service << EOF cat > /etc/systemd/system/xray.service << EOF
[Unit] [Unit]
Description=Xray Service Description=Xray Service
@ -525,7 +531,7 @@ Documentation=https://github.com/xtls
After=network.target nss-lookup.target After=network.target nss-lookup.target
[Service] [Service]
User=$INSTALL_USER ${temp_UserSet}
${temp_CapabilityBoundingSet} ${temp_CapabilityBoundingSet}
${temp_AmbientCapabilities} ${temp_AmbientCapabilities}
${temp_NoNewPrivileges} ${temp_NoNewPrivileges}
@ -545,7 +551,7 @@ Documentation=https://github.com/xtls
After=network.target nss-lookup.target After=network.target nss-lookup.target
[Service] [Service]
User=$INSTALL_USER ${temp_UserSet}
${temp_CapabilityBoundingSet} ${temp_CapabilityBoundingSet}
${temp_AmbientCapabilities} ${temp_AmbientCapabilities}
${temp_NoNewPrivileges} ${temp_NoNewPrivileges}