Fix virtual email address maildir permissions in Cpanel

Im not a big fan of cpanel but I do manage a server that runs it. Recently some update was pushed down that caused about 50% of my users to not be able to access mail. It all boiled down to a permission issue that the cpanel scripts /scripts/mailperm did not take care of. Their scripts do not correct the permissions of the virtual user maildirs.
From my testing the virtual users maildirs need to be UID and GID the same as the domain user account. This little shell script fixed it for me as far as I can tell. Well it mostly takes care of the issue, I had a few that the script does not handle but for the vast majority it worked.

for i in $(find /home/ -type d  -maxdepth 1 ! -name '.*' -printf "%f\n");do
    echo $local_user
    domain=$(awk -F '=' '/DNS=/ {print $2}' /var/cpanel/users/$local_user)
    find /home/$local_user/mail/$domain -type d  -maxdepth 1 ! -name '.*' -printf "%f\n | xargs -n 1 chown $local_user.$local_user

One Comment

  • Phoenix Mac OS X Google Chrome 21.0.1180.89 wrote:

    Is that “quot;” stuff intentional? Seems like a formatting error, and might be much more painful to fix a problem created by that.

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha