From 8b77f22eaf0fe2157a7e951d0fdd226941ea8d83 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Mon, 21 Jul 2025 00:05:36 +0800 Subject: [PATCH] Reduce log directory permissions and remove incorrect comments (#90) * Remove incorrect comments * Reduce log directory permissions --- alpinelinux/install-release.sh | 8 ++++++-- install-release.sh | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/alpinelinux/install-release.sh b/alpinelinux/install-release.sh index a7f14f4..bef0a03 100644 --- a/alpinelinux/install-release.sh +++ b/alpinelinux/install-release.sh @@ -12,7 +12,6 @@ check_alpine() { } check_if_running_as_root() { - # If you want to run as another user, please modify $EUID to be owned by this user if [ "$(id -u)" -eq 0 ]; then return 0 else @@ -154,10 +153,15 @@ install_confdir() { install_log() { LOG='0' if [ ! -d '/var/log/xray/' ]; then - install -d -o nobody -g nobody /var/log/xray/ + install -d -m 755 -o 0 -g 0 /var/log/xray/ install -m 600 -o nobody -g nobody /dev/null /var/log/xray/access.log install -m 600 -o nobody -g nobody /dev/null /var/log/xray/error.log LOG='1' + else + chown 0:0 /var/log/xray/ + chmod 755 /var/log/xray/ + chown nobody:nobody /var/log/xray/*.log + chmod 600 /var/log/xray/*.log fi } diff --git a/install-release.sh b/install-release.sh index 785d6ac..739d12d 100755 --- a/install-release.sh +++ b/install-release.sh @@ -116,7 +116,6 @@ systemd_cat_config() { } check_if_running_as_root() { - # If you want to run as another user, please modify $EUID to be owned by this user if [[ "$(id -u)" -eq 0 ]]; then return 0 else @@ -511,12 +510,15 @@ install_xray() { # Used to store Xray log files if [[ "$NO_LOGFILES" -eq '0' ]]; then if [[ ! -d '/var/log/xray/' ]]; then - install -d -m 700 -o "$INSTALL_USER_UID" -g "$INSTALL_USER_GID" /var/log/xray/ + install -d -m 755 -o 0 -g 0 /var/log/xray/ install -m 600 -o "$INSTALL_USER_UID" -g "$INSTALL_USER_GID" /dev/null /var/log/xray/access.log install -m 600 -o "$INSTALL_USER_UID" -g "$INSTALL_USER_GID" /dev/null /var/log/xray/error.log LOG='1' else - chown -R "$INSTALL_USER_UID:$INSTALL_USER_GID" /var/log/xray/ + chown 0:0 /var/log/xray/ + chmod 755 /var/log/xray/ + chown "$INSTALL_USER_UID:$INSTALL_USER_GID" /var/log/xray/*.log + chmod 600 /var/log/xray/*.log fi fi }