enable switching user and running task command by using environment variable CCP_SWITCH_USER, which is to fix a bug that command, like "ulimit -l" on Ubuntu, is executed as root even if the runas user is specified as other user

This commit is contained in:
FAREAST\chezhang 2018-12-07 22:00:33 +08:00
Родитель 53211d728a
Коммит 0ba6267b9f
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -34,9 +34,11 @@ fi
if $CGInstalled; then
groupName=$(GetCGroupName "$taskId")
group=$CGroupSubSys:$groupName
cgexec -g "$group" /bin/bash $taskFolder/TestMutualTrust.sh "$taskId" "$taskFolder" "$userName" &&\
cgexec -g "$group" sudo -H -E -u $userName env "PATH=$PATH" /bin/bash $runPath
cgexec -g "$group" /bin/bash $taskFolder/TestMutualTrust.sh "$taskId" "$taskFolder" "$userName" && (\
[ "$CCP_SWITCH_USER" == "1" ] && (cgexec -g "$group" su - $userName -m -c "/bin/bash $runPath" || exit) ||\
cgexec -g "$group" sudo -H -E -u $userName env "PATH=$PATH" /bin/bash $runPath)
else
/bin/bash $taskFolder/TestMutualTrust.sh "$taskId" "$taskFolder" "$userName" &&\
sudo -H -E -u $userName env "PATH=$PATH" /bin/bash $runPath
/bin/bash $taskFolder/TestMutualTrust.sh "$taskId" "$taskFolder" "$userName" && (\
[ "$CCP_SWITCH_USER" == "1" ] && (su - $userName -m -c "/bin/bash $runPath" || exit) ||\
sudo -H -E -u $userName env "PATH=$PATH" /bin/bash $runPath)
fi