2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 08:52:15 +00:00

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.
This commit is contained in:
Vinícius Ferrão
2026-10-22 14:18:03 -03:00
parent d42f3e3150
commit 60beaecead
+11 -3
View File
@@ -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