Generated user cannot access sudo or su on Cloudlinux
If this script is run on a server with CloudLinux (with the option to add new users to CageFS configuration automatically enabled), the user created does not not have access to su or sudo. This script should account for that and make sure that the user in question is removed from the CageFS config upon creation. That can be implemented via something akin to the following:
local fulluser="${userprefix}${usersuffix}"
if command -v cagefsctl >/dev/null 2>&1; then
echo "Detected CageFS, making sure CageFS is disabled for user ${fulluser}"
if (cagefsctl --list-enabled | grep -qE "^\s*${fulluser}\s*\$" >/dev/null 2>&1); then
cagefsctl --disable "$fulluser"
fi
fi
Issue Example:
hdadmin77319@manu29 [/root]# su
bash: su: command not found
hdadmin77319@manu29 [/root]# sudo su
bash: sudo: command not found
Edited by michael.beasley@hostdime.com