From 60beaecead4e8b1008dcb2fc0a202f57bd58c1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Thu, 22 Oct 2026 14:18:03 -0300 Subject: [PATCH] fix(syslog): create the local log directory before setting its owner Create missing Debian-family log directories before assigning their owner. Use mode 0750 for syslog-owned directories. In the legacy reference-owner path, copy the parent directory mode so group-writing daemons retain access. Preserve existing directory modes, log files and forwarding policy. Stop with an error before restarting syslog if the directory cannot be created. Keep existing ownership-command failures nonfatal. --- xCAT/postscripts/syslog | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index b0acfedd35..7840b3b763 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -83,6 +83,14 @@ is_lsb_ubuntu () # failure (not Ubuntu), which is the correct outcome. } +set_log_directory_owner() +{ + local mode=$1 + shift + mkdir -p -m "$mode" /var/log/xcat || exit $? + chown "$@" /var/log/xcat +} + config_Rsyslog_C3() { isReceiving=0 @@ -127,7 +135,7 @@ config_Rsyslog_C3() touch /var/log/messages chown syslog:adm /var/log/messages sed -i 's/\$PrivDropToGroup syslog/\$PrivDropToGroup adm/' $2 - chown syslog:adm /var/log/xcat + set_log_directory_owner 0750 syslog:adm fi else sed -i 's/^\(\*\..*\)/\#\1/; @@ -286,7 +294,7 @@ config_rsyslog_V8() if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then chown syslog:adm /var/log/messages sed -i 's/\$PrivDropToGroup syslog/\$PrivDropToGroup adm/' $conf_file - chown syslog:adm /var/log/xcat + set_log_directory_owner 0750 syslog:adm fi # Mark the start of xCAT section @@ -523,7 +531,7 @@ else touch /var/log/messages if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then chown --reference=/var/log /var/log/messages - chown --reference=/var/log /var/log/xcat + set_log_directory_owner "$(stat -c %a /var/log)" --reference=/var/log fi if [ $ng -eq 0 ]; then if [ ! -f $conf_file.XCATORIG ]; then