From c4367da51e3ded38dff5b98c189a26a798d54123 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 23 Nov 2015 14:19:41 +0800 Subject: [PATCH] Dirty hack, fix the permission of direcotry /var/log/xcat --- xCAT-server/share/xcat/install/scripts/post.ubuntu | 9 ++++++++- xCAT-server/share/xcat/install/scripts/post.xcat | 9 +++++++-- xCAT/postscripts/syslog | 3 ++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 26d062e8b..2e6d77a55 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -153,6 +153,14 @@ return_value=0 run_ps () { local ret_local=0 mkdir -p "\"/var/log/xcat\"" + # On Ubuntu, the rsyslogd daemon write log files with syslog:adm + # permissison. And in some case, the directory /var/log/xcat was + # created by xCAT, and had root:root ownership. In this way, rsyslogd + # did not have enough permission to write to log files under this + # directory. + # As a dirty hack, change the ownership of directory /var/log/xcat + # to the same ownership of directory /var/log. + chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\"" local logfile=\"/var/log/xcat/xcat.log\" if [ -f \$1 ]; then @@ -300,4 +308,3 @@ cd / #rm -Rf /xcatpost #rm -f /tmp/mypostscript exit 0 - diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 0ad6ce8e6..abc36d1c8 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -138,6 +138,13 @@ return_value=0 run_ps () { local ret_local=0 mkdir -p "\"/var/log/xcat\"" + # On some Linux distro, the rsyslogd daemon write log files with permision + # other than root:root. And in some case, the directory /var/log/xcat was + # created by xCAT, and had root:root ownership. In this way, rsyslogd + # did not have enough permission to write to log files under this directory. + # As a dirty hack, change the ownership of directory /var/log/xcat to the + # same ownership of directory /var/log. + chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\"" local logfile=\"/var/log/xcat/xcat.log\" if [ -f \$1 ]; then @@ -274,5 +281,3 @@ updateflag.awk $MASTER 3002 cd / #rm -Rf /xcatpost #rm -f /xcatpost/mypostscript - - diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 1b0aa07b4..2403351e8 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -348,7 +348,8 @@ else #making sure all the messages goes to /var/log/messages touch /var/log/messages if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then - chown syslog:adm /var/log/messages + chown --reference=/var/log /var/log/messages + chown --reference=/var/log /var/log/xcat fi if [ $ng -eq 0 ]; then if [ ! -f $conf_file.XCATORIG ]; then