Zhang Huangbin avatar Zhang Huangbin committed f0e7e84

Add new value of enabledService: doveadm. Required by command doveadm provided by Dovecot-2.

Comments (0)

Files changed (11)

extra/update/updateLDAPValues_074_to_080.py

+#!/usr/bin/env python
+# encoding: utf-8
+
+# Author:   Zhang Huangbin <zhb _at_ iredmail.org>
+# Purpose:  Add enabledService=doveadm for all mail users.
+#           Required by command doveadm which provided by Dovecot-2.0.
+# Date:     2012-04-19
+
+import sys
+import ldap
+
+# Note:
+#   * bind_dn must have write privilege on LDAP server.
+uri = 'ldap://127.0.0.1:389'
+basedn = 'o=domains,dc=example,dc=com'
+bind_dn = 'cn=Manager,dc=example,dc=com'
+bind_pw = 'passwd'
+
+# Initialize LDAP connection.
+print >> sys.stderr, "* Connecting to LDAP server: %s" % uri
+conn = ldap.initialize(uri=uri, trace_level=0,)
+conn.bind_s(bind_dn, bind_pw)
+
+# Get all mail users.
+print >> sys.stderr, "* Get all mail accounts..."
+allUsers = conn.search_s(
+        basedn,
+        ldap.SCOPE_SUBTREE,
+        "(objectClass=mailUser)",
+        ['mail', 'enabledService'],
+        )
+
+total = len(allUsers)
+print >> sys.stderr, "* Total %d user(s)." % (total)
+
+# Values of 'enabledService' which need to be added.
+services = ['doveadm']
+
+# Counter.
+count = 1
+
+for user in allUsers:
+    (dn, entry) = user
+    mail = entry['mail'][0]
+    if not 'enabledService' in entry:
+        continue
+
+    enabledService = entry['enabledService']
+    # Get missing values.
+    values = [str(s).lower() for s in services if s not in enabledService]
+
+    mod_attrs = []
+
+    # Add missing values of 'enabledService'.
+    if len(values) > 0:
+        mod_attrs += [(ldap.MOD_ADD, 'enabledService', values)]
+
+    # Update.
+    if len(mod_attrs) > 0:
+        print >> sys.stderr, "* (%d of %d) Updating user: %s" % (count, total, mail)
+        conn.modify_s(dn, mod_attrs)
+    else:
+        print >> sys.stderr, "* (%d of %d) [SKIP] No update required: %s" % (count, total, mail)
+
+    count += 1
+
+# Unbind connection.
+print >> sys.stderr, "* Unbind LDAP server."
+conn.unbind()
+
+print >> sys.stderr, "* Update completed."

iRedMail/ChangeLog

 iRedMail-0.8.0-beta4:
+    * Add new value of enabledService: doveadm. Required by command doveadm
+      provided by Dovecot-2.
     * All clients are forced to use IMAPS and POPS (via STARTTLS).
     * Drop support for Dovecot-1.1. At least Dovecot-1.2 is required.
     * Fixed:

iRedMail/conf/openldap

 export LDAP_SERVICE_DOMAIN_ALIAS='domainalias'
 export LDAP_SERVICE_MAIL='mail'
 export LDAP_SERVICE_INTERNAL='internal'
+export LDAP_SERVICE_DOVEADM='doveadm'
 export LDAP_SERVICE_SMTP='smtp'
 export LDAP_SERVICE_SMTPS='smtpsecured'
 export LDAP_SERVICE_POP3='pop3'

iRedMail/functions/amavisd.sh

 #########################
 # Quarantine VIRUS mails.
 #
-# Quarantine VIRUS into local file system. Default is 'virus-quarantine'.
 #\$virus_quarantine_to     = 'virus-quarantine';
+#\$virus_quarantine_method = 'sql:';
 
-# Quarantine method. How to store VIRUS mail body. Default is 'local:virus-%m'.
-# VIRUS is quarantined into local file system by default.
-#\$virus_quarantine_method = 'sql:';
+#########################
+# Quarantine BANNED mails.
+#
+#\$banned_files_quarantine_method = 'sql:';
+#\$banned_quarantine_to = 'banned-quarantine';
+
 
 # Modify email subject, add '\$sa_spam_subject_tag'.
 #   0:  disable

iRedMail/functions/openldap.sh

 ${LDAP_ATTR_USER_PASSWD}: $(gen_ldap_passwd "${FIRST_USER_PASSWD}")
 ${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_MAIL}
 ${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_INTERNAL}
+${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_DOVEADM}
 ${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_SMTP}
 ${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_SMTPS}
 ${LDAP_ENABLED_SERVICE}: ${LDAP_SERVICE_POP3}

iRedMail/samples/iredmail.mysql

     enablesieve TINYINT(1) NOT NULL DEFAULT 1,
     enablesievesecured TINYINT(1) NOT NULL DEFAULT 1,
     enableinternal TINYINT(1) NOT NULL DEFAULT 1,
+    enabledoveadm TINYINT(1) NOT NULL DEFAULT 1,
     lastlogindate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
     lastloginipv4 INT(4) UNSIGNED NOT NULL DEFAULT 0,
     lastloginprotocol CHAR(255) NOT NULL DEFAULT '',

iRedMail/samples/iredmail.pgsql

     enablesieve INT2 NOT NULL DEFAULT 1,
     enablesievesecured INT2 NOT NULL DEFAULT 1,
     enableinternal INT2 NOT NULL DEFAULT 1,
+    enabledoveadm INT2 NOT NULL DEFAULT 1,
     lastlogindate TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT '1970-01-01 00:00:00',
     lastloginipv4 INET NOT NULL DEFAULT '0.0.0.0',
     lastloginprotocol CHAR(255) NOT NULL DEFAULT '',

iRedMail/tools/create_mail_user_MySQL.sh

-#!/usr/bin/env bash
-
-# Author:   Zhang Huangbin (zhb(at)iredmail.org)
-# Purpose:  Import users to MySQL database from plain text file.
-# Project:  iRedMail (http://www.iredmail.org/)
-
-# -------------------------------------------------------------------
-# Usage:
-#   * Edit these variables:
-#       STORAGE_BASE_DIRECTORY
-#       DEFAULT_PASSWD='888888'
-#       USE_DEFAULT_PASSWD='NO'
-#       DEFAULT_QUOTA='100'   # 100 -> 100M
-#
-#   * Run this script to generate SQL files used to import to MySQL
-#     database later.
-#
-#       # sh create_mail_user_MySQL.sh domain.ltd user [user1 user2 user3 ...]
-#
-#     It will generate file 'output.sql' in current directory, open
-#     it and confirm all records are correct.
-#
-#   * Import output.sql into MySQL database.
-#
-#       # mysql -uroot -p
-#       mysql> USE vmail;
-#       mysql> SOURCE /path/to/output.sql;
-#
-#   That's all.
-# -------------------------------------------------------------------
-
-# ChangeLog:
-#   - 2009.05.07 Add hashed maildir style support.
-#   - Improve file detect.
-#   - Drop output message of 'which dos2unix'.
-
-# --------- CHANGE THESE VALUES ----------
-# Storage base directory used to store users' mail.
-STORAGE_BASE_DIRECTORY="/var/vmail/vmail1"
-
-# Password setting.
-# Note: password will be crypted in MD5.
-DEFAULT_PASSWD='88888888'
-USE_DEFAULT_PASSWD='NO'     # If set to 'NO', password is the same as username.
-
-# Default mail quota.
-DEFAULT_QUOTA='100'   # 100 -> 100M
-
-# -------------- You may not need to change variables below -------------------
-# Mailbox format: mbox, Maildir.
-MAILBOX_FORMAT='Maildir'
-
-# ---- Maildir settings ----
-# Maildir style: hashed, normal.
-# Hashed maildir style, so that there won't be many large directories
-# in your mail storage file system. Better performance in large scale
-# deployment.
-# Format: e.g. username@domain.td
-#   hashed  -> domain.ltd/u/us/use/username/
-#   normal  -> domain.ltd/username/
-# Default hash level is 3.
-MAILDIR_STYLE='hashed'      # hashed, normal.
-
-# Time stamp, will be appended in maildir.
-DATE="$(date +%Y.%m.%d.%H.%M.%S)"
-
-STORAGE_BASE="$(dirname ${STORAGE_BASE_DIRECTORY})"
-STORAGE_NODE="$(basename ${STORAGE_BASE_DIRECTORY})"
-
-# Path to SQL template file.
-SQL="output.sql"
-echo '' > ${SQL}
-
-# Cyrpt the password.
-if [ X"${USE_DEFAULT_PASSWD}" == X"YES" ]; then
-    export CRYPT_PASSWD="$(openssl passwd -1 ${DEFAULT_PASSWD})"
-else
-    :
-fi
-
-generate_sql()
-{
-    # Get domain name.
-    DOMAIN="$1"
-    shift 1
-
-    for i in $@; do
-        username="$i"
-        mail="${username}@${DOMAIN}"
-
-        if [ X"${USE_DEFAULT_PASSWD}" != X"YES" ]; then
-            export CRYPT_PASSWD="$(openssl passwd -1 ${username})"
-        else
-            :
-        fi
-
-        # Different maildir style: hashed, normal.
-        if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then
-            length="$(echo ${username} | wc -L)"
-            str1="$(echo ${username} | cut -c1)"
-            str2="$(echo ${username} | cut -c2)"
-            str3="$(echo ${username} | cut -c3)"
-
-            if [ X"${length}" == X"1" ]; then
-                str2="${str1}"
-                str3="${str1}"
-            elif [ X"${length}" == X"2" ]; then
-                str3="${str2}"
-            else
-                :
-            fi
-
-            # Use mbox, will be changed later.
-            maildir="${DOMAIN}/${str1}/${str2}/${str3}/${username}-${DATE}"
-        else
-            # Use mbox, will be changed later.
-            maildir="${DOMAIN}/${username}-${DATE}"
-        fi
-
-        # Different maildir format: maildir, mbox.
-        if [ X"${MAILBOX_FORMAT}" == X"Maildir" ]; then
-            # Append slash to make it 'maildir' format.
-            maildir="${maildir}/"
-        else
-            # It's already mbox format.
-            :
-        fi
-
-        cat >> ${SQL} <<EOF
-INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
-    VALUES ('${mail}', '${CRYPT_PASSWD}', '${username}', '${STORAGE_BASE}','${STORAGE_NODE}', '${maildir}', '${DEFAULT_QUOTA}', '${DOMAIN}', '1','${username}', NOW());
-INSERT INTO alias (address, goto, domain, created, active) VALUES ('${mail}', '${mail}','${DOMAIN}', NOW(), 1);
-EOF
-    done
-}
-
-if [ $# -lt 2 ]; then
-    echo "Usage: $0 domain_name username [user2 user3 user4 ...]"
-else
-    # Generate SQL template.
-    generate_sql $@ && \
-    cat <<EOF
-
-SQL template file was generated successfully, Please import it
-*MANUALLY* after verify the records:
-
-    - ${SQL}
-
-Steps to import these users looks like below:
-
-    # mysql -uroot -p
-    mysql> USE vmail;
-    mysql> SOURCE ${SQL};
-
-EOF
-fi

iRedMail/tools/create_mail_user_OpenLDAP.py

         ('homeDirectory',       [homeDirectory]),
         ('accountStatus',       ['active']),
         ('mtaTransport',        ['dovecot']),
-        ('enabledService',      ['mail', 'smtp', 'smtpsecured',
+        ('enabledService',      ['internal', 'doveadm',
+                                 'mail', 'smtp', 'smtpsecured',
                                  'pop3', 'pop3secured', 'imap', 'imapsecured',
                                 'deliver', 'lda', 'forward', 'senderbcc', 'recipientbcc',
-                                 'managesieve', 'managesievesecured', 'internal',
+                                 'managesieve', 'managesievesecured',
                                  'sieve', 'sievesecured', 'shadowaddress',
                                 'displayedInGlobalAddressBook', ]),
         ('memberOfGroup',       groups),

iRedMail/tools/create_mail_user_OpenLDAP.sh

 sn: ${USERNAME}
 givenName: ${USERNAME}
 uid: ${USERNAME}
+enabledService: internal
+enabledService: doveadm
 enabledService: mail
 enabledService: pop3
 enabledService: pop3secured
 enabledService: recipientbcc
 enabledService: shadowaddress
 enabledService: displayedInGlobalAddressBook
-enabledService: internal
 ${LDIF_PUREFTPD_USER}
 EOF
 }

iRedMail/tools/create_mail_user_SQL.sh

+#!/usr/bin/env bash
+
+# Author:   Zhang Huangbin (zhb(at)iredmail.org)
+# Purpose:  Import users to MySQL database from plain text file.
+# Project:  iRedMail (http://www.iredmail.org/)
+
+# -------------------------------------------------------------------
+# Usage:
+#   * Edit these variables:
+#       STORAGE_BASE_DIRECTORY
+#       DEFAULT_PASSWD='888888'
+#       USE_DEFAULT_PASSWD='NO'
+#       DEFAULT_QUOTA='100'   # 100 -> 100M
+#
+#   * Run this script to generate SQL files used to import to MySQL
+#     database later.
+#
+#       # sh create_mail_user_MySQL.sh domain.ltd user [user1 user2 user3 ...]
+#
+#     It will generate file 'output.sql' in current directory, open
+#     it and confirm all records are correct.
+#
+#   * Import output.sql into MySQL database.
+#
+#       # mysql -uroot -p
+#       mysql> USE vmail;
+#       mysql> SOURCE /path/to/output.sql;
+#
+#   That's all.
+# -------------------------------------------------------------------
+
+# ChangeLog:
+#   - 2009.05.07 Add hashed maildir style support.
+#   - Improve file detect.
+#   - Drop output message of 'which dos2unix'.
+
+# --------- CHANGE THESE VALUES ----------
+# Storage base directory used to store users' mail.
+STORAGE_BASE_DIRECTORY="/var/vmail/vmail1"
+
+# Password setting.
+# Note: password will be crypted in MD5.
+DEFAULT_PASSWD='88888888'
+USE_DEFAULT_PASSWD='NO'     # If set to 'NO', password is the same as username.
+
+# Default mail quota.
+DEFAULT_QUOTA='100'   # 100 -> 100M
+
+# -------------- You may not need to change variables below -------------------
+# Mailbox format: mbox, Maildir.
+MAILBOX_FORMAT='Maildir'
+
+# ---- Maildir settings ----
+# Maildir style: hashed, normal.
+# Hashed maildir style, so that there won't be many large directories
+# in your mail storage file system. Better performance in large scale
+# deployment.
+# Format: e.g. username@domain.td
+#   hashed  -> domain.ltd/u/us/use/username/
+#   normal  -> domain.ltd/username/
+# Default hash level is 3.
+MAILDIR_STYLE='hashed'      # hashed, normal.
+
+# Time stamp, will be appended in maildir.
+DATE="$(date +%Y.%m.%d.%H.%M.%S)"
+
+STORAGE_BASE="$(dirname ${STORAGE_BASE_DIRECTORY})"
+STORAGE_NODE="$(basename ${STORAGE_BASE_DIRECTORY})"
+
+# Path to SQL template file.
+SQL="output.sql"
+echo '' > ${SQL}
+
+# Cyrpt the password.
+if [ X"${USE_DEFAULT_PASSWD}" == X"YES" ]; then
+    export CRYPT_PASSWD="$(openssl passwd -1 ${DEFAULT_PASSWD})"
+else
+    :
+fi
+
+generate_sql()
+{
+    # Get domain name.
+    DOMAIN="$1"
+    shift 1
+
+    for i in $@; do
+        username="$i"
+        mail="${username}@${DOMAIN}"
+
+        if [ X"${USE_DEFAULT_PASSWD}" != X"YES" ]; then
+            export CRYPT_PASSWD="$(openssl passwd -1 ${username})"
+        else
+            :
+        fi
+
+        # Different maildir style: hashed, normal.
+        if [ X"${MAILDIR_STYLE}" == X"hashed" ]; then
+            length="$(echo ${username} | wc -L)"
+            str1="$(echo ${username} | cut -c1)"
+            str2="$(echo ${username} | cut -c2)"
+            str3="$(echo ${username} | cut -c3)"
+
+            if [ X"${length}" == X"1" ]; then
+                str2="${str1}"
+                str3="${str1}"
+            elif [ X"${length}" == X"2" ]; then
+                str3="${str2}"
+            else
+                :
+            fi
+
+            # Use mbox, will be changed later.
+            maildir="${DOMAIN}/${str1}/${str2}/${str3}/${username}-${DATE}"
+        else
+            # Use mbox, will be changed later.
+            maildir="${DOMAIN}/${username}-${DATE}"
+        fi
+
+        # Different maildir format: maildir, mbox.
+        if [ X"${MAILBOX_FORMAT}" == X"Maildir" ]; then
+            # Append slash to make it 'maildir' format.
+            maildir="${maildir}/"
+        else
+            # It's already mbox format.
+            :
+        fi
+
+        cat >> ${SQL} <<EOF
+INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
+    VALUES ('${mail}', '${CRYPT_PASSWD}', '${username}', '${STORAGE_BASE}','${STORAGE_NODE}', '${maildir}', '${DEFAULT_QUOTA}', '${DOMAIN}', '1','${username}', NOW());
+INSERT INTO alias (address, goto, domain, created, active) VALUES ('${mail}', '${mail}','${DOMAIN}', NOW(), 1);
+EOF
+    done
+}
+
+if [ $# -lt 2 ]; then
+    echo "Usage: $0 domain_name username [user2 user3 user4 ...]"
+else
+    # Generate SQL template.
+    generate_sql $@ && \
+    cat <<EOF
+
+SQL template file was generated successfully, Please import it
+*MANUALLY* after verify the records:
+
+    - ${SQL}
+
+Steps to import these users looks like below:
+
+    # mysql -uroot -p
+    mysql> USE vmail;
+    mysql> SOURCE ${SQL};
+
+EOF
+fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.