mcreboot: Fix umask for /proc and /sys files

This commit is contained in:
Masamichi Takagi
2017-10-26 23:57:26 +09:00
parent 85d36f1469
commit 6c33e236d7
2 changed files with 9 additions and 10 deletions

View File

@ -35,7 +35,6 @@ error_exit() {
;& ;&
tmp_mcos_created) tmp_mcos_created)
if [ "$enable_mcoverlay" == "yes" ]; then if [ "$enable_mcoverlay" == "yes" ]; then
umask $umask_old
rm -rf /tmp/mcos rm -rf /tmp/mcos
fi fi
;& ;&
@ -48,10 +47,6 @@ error_exit() {
} }
fi fi
# Change umask for /proc and /sys files
umask_dec=$(( 8#${umask_old} & 8#0002 ))
umask 0`printf "%o" ${umask_dec}`
if [ ! -e /tmp/mcos ]; then if [ ! -e /tmp/mcos ]; then
mkdir -p /tmp/mcos; mkdir -p /tmp/mcos;
fi fi
@ -149,7 +144,3 @@ for cpuid in `find /sys/bus/cpu/devices/* -maxdepth 0 -name "cpu[0123456789]*" -
rm -rf /tmp/mcos/mcos0_sys/bus/cpu/devices/$cpuid rm -rf /tmp/mcos/mcos0_sys/bus/cpu/devices/$cpuid
fi fi
done done
# Restore umask
umask ${umask_old}

View File

@ -117,7 +117,6 @@ error_exit() {
;& ;&
tmp_mcos_created) tmp_mcos_created)
if [ "$enable_mcoverlay" == "yes" ]; then if [ "$enable_mcoverlay" == "yes" ]; then
umask $umask_old
rm -rf /tmp/mcos rm -rf /tmp/mcos
fi fi
;& ;&
@ -158,6 +157,7 @@ error_exit() {
rmmod ihk 2>/dev/null || echo "warning: failed to remove ihk" >&2 rmmod ihk 2>/dev/null || echo "warning: failed to remove ihk" >&2
;& ;&
irqbalance_stopped) irqbalance_stopped)
umask $umask_old
if [ "`systemctl status irqbalance_mck.service 2> /dev/null |grep -E 'Active: active'`" != "" ]; then if [ "`systemctl status irqbalance_mck.service 2> /dev/null |grep -E 'Active: active'`" != "" ]; then
if ! systemctl stop irqbalance_mck.service 2>/dev/null; then if ! systemctl stop irqbalance_mck.service 2>/dev/null; then
echo "warning: failed to stop irqbalance_mck" >&2 echo "warning: failed to stop irqbalance_mck" >&2
@ -261,6 +261,11 @@ if [ "${irqbalance_used}" == "yes" ]; then
fi fi
# Set umask so that proc/sys files/directories created by
# mcctrl.ko and mcreboot.sh have appropriate permission bits
umask_dec=$(( 8#${umask_old} & 8#0002 ))
umask 0`printf "%o" ${umask_dec}`
# Load IHK if not loaded # Load IHK if not loaded
if ! grep -E 'ihk\s' /proc/modules &>/dev/null; then if ! grep -E 'ihk\s' /proc/modules &>/dev/null; then
if ! taskset -c 0 insmod ${KMODDIR}/ihk.ko 2>/dev/null; then if ! taskset -c 0 insmod ${KMODDIR}/ihk.ko 2>/dev/null; then
@ -426,4 +431,7 @@ if [ "${irqbalance_used}" == "yes" ]; then
# echo cpus=$cpus ncpus=$ncpus banirq=$banirq # echo cpus=$cpus ncpus=$ncpus banirq=$banirq
fi fi
# Restore umask
umask ${umask_old}
exit 0 exit 0