I had many problems in Virtualmin accounts after migrating a cPanel reseller hosting plan. Many of the problems were related to the creation of users and their permissions. Searching the forums here, and with the help of user JamieCameron - who sent me a pre-release version 3.90 - I got my move with about 30 retail accounts. And everything is working fine.
I realized that Virtualmin is the conversion of cPanel account to account Virtualmin with some important principles for our understanding:
- The administrator user cPanel - we'll call cpanel_account - will have a directory /home/cpanel_account
and a user named on OS cpanel_account. The directory /home/cpanel_account
- when everything is right
/home/cpanel_account/Maildir/cpanel_sub_account
and a user named on OS cpanel_sub_account@domain.tdl
, which belong to the group cpanel_account
. The directory /home/cpanel_account/Maildir/cpanel_sub_account
and their subdirectories and files will be - when everything is right - owned by the user cpanel_sub_account@domain.tdl
In some cases, Virtualmin does Cpanel migration to perfection. However, when the account cPanel has many users (email, ftp et cetera) is one or more of these problems:
cpanel_sub_account@domain.tdl
) instead of cpanel_account@dominio.tdl
in /home/cpanel_account/
/home/cpanel_account/Maildir
the Virtualmin creates a subdirectory for each email account. But not all the permissions are correct. Since if the above-mentioned problem has occurred, it leaves all these sub-directories with permission for the user owning the directory /home/cpanel_account/
, ie, for some cpanel_sub_account@domain.tdl
Solution The solution is to change the permissions with chown, in their respective situations:
chown cpanel_account:cpanel_account /home/cpanel_account/
chown cpanel_account:cpanel_account /home/cpanel_account/Maildir
/home/cpanel_account/Maildir
must have the permission of the account that will use this directory. Therefore, for each sub-directory using chown -R cpanel_sub_account@domain.tdl: cpanel_account /home/cpanel_account/Maildir/cpanel_sub_account
Resolving the last situation with shell script
I've had some situations cPanel accounts with more than 50 emails each. Despite having almost no experience with shell script, I created one that solves the problem. Just put this file in the directory /home/cpanel_account/Maildir
and run it with sh. /changeper.sh
. The following simple script code changeper.sh:
sufix="domain.tdl"
domain_user="cpanel_account"
for dir in $( ls . )
do
chown -R ${dir}@${sufix}:${domain_user} ./$dir
done
This newbie script is not perfect. It generates two alerts that have not caused problems. Ideally, someone improve this script so that it was passed as an argument the directory to be checked and the domain account which this directory belongs. It would be also good that someone created ums script to do this check on all accounts from a cPanel/Virtualmin migration. The Virtualmin even has a tool that does this check in Virtualmin > Limits and Validation > Validate Virtual Servers, but it does not work perfectly in this situation (this is another matter).
This situation extends to other situations of errors during the migration Virtualmin and cPanel. I believe that most of the users with the migration issue, is because of this situation. So I decided to create this topic even if it was sure to be the right place for it.