Commits

Zhang Huangbin committed 06b33e3

Enable Dovecot Master User for Dovecot-1.x.

Comments (0)

Files changed (3)

iRedMail/conf/dovecot

 export DOVECOT_PGSQL_CONF="${DOVECOT_CONF_DIR}/dovecot-pgsql.conf"
 export DOVECOT_REALTIME_QUOTA_CONF="${DOVECOT_CONF_DIR}/dovecot-used-quota.conf"
 export DOVECOT_SHARE_FOLDER_CONF="${DOVECOT_CONF_DIR}/dovecot-share-folder.conf"
-export DOVECOT_MASTER_USER_PASSWORD_FILE="${DOVECOT_CONF_DIR}/dovecot-master-users-passwd"
+export DOVECOT_MASTER_USER_PASSWORD_FILE="${DOVECOT_CONF_DIR}/dovecot-master-users-password"
 
 # Log & logrotate files.
 export DOVECOT_LOG_FILE='/var/log/dovecot.log'

iRedMail/functions/dovecot1.sh

 first_valid_uid = ${VMAIL_USER_UID}
 last_valid_uid = ${VMAIL_USER_UID}
 
+# Master user.
+# Master users are able to log in as other users. It's also possible to
+# directly log in as any user using a master password, although this isn't
+# recommended.
+# Reference: http://wiki1.dovecot.org/Authentication/MasterUsers
+auth_master_user_separator = *
+
 #
 # Debug options.
 #
 auth default {
     mechanisms = plain login
     user = ${VMAIL_USER_NAME}
+
+    # Master user.
+    passdb passwd-file {
+        args = ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+        master = yes
+    }
 EOF
 
+    # Master user password file.
+    touch ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+    chown ${VMAIL_USER_NAME}:${VMAIL_GROUP_NAME} ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+    chmod 0550 ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+
     if [ X"${BACKEND}" == X"OPENLDAP" ]; then
         cat >> ${DOVECOT_CONF} <<EOF
     passdb ldap {

iRedMail/functions/dovecot2.sh

     # Master user.
     perl -pi -e 's#PH_DOVECOT_MASTER_USER_PASSWORD_FILE#$ENV{DOVECOT_MASTER_USER_PASSWORD_FILE}#' ${DOVECOT_CONF}
     touch ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+    chown ${DOVECOT_USER}:${DOVECOT_GROUP} ${DOVECOT_MASTER_USER_PASSWORD_FILE}
+    chmod 0500 ${DOVECOT_MASTER_USER_PASSWORD_FILE}
 
     perl -pi -e 's#PH_AUTH_SOCKET_PATH#$ENV{DOVECOT_AUTH_SOCKET_PATH}#' ${DOVECOT_CONF}