Skip to content

Commit

Permalink
dovecot: update SQL for valiasdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Jan 24, 2024
1 parent 50c9ade commit 8a6d809
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/vpopmail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_vpopmail_source()
fi

_conf_args="--disable-users-big-dir --enable-logging=y --enable-md5-passwords"
if [ "$TOASTER_MYSQL" = "1" ]; then _conf_args="$_conf_args --enable-auth-module=mysql --enable-valias"; fi
if [ "$TOASTER_MYSQL" = "1" ]; then _conf_args="$_conf_args --enable-auth-module=mysql --enable-valias --enable-sql-aliasdomains"; fi
if [ "$TOASTER_VPOPMAIL_EXT" = "1" ]; then _conf_args="$_conf_args --enable-qmail-ext"; fi
if [ "$TOASTER_VPOPMAIL_CLEAR" = "1" ]; then _conf_args="$_conf_args --enable-clear-passwd"; fi

Expand Down
31 changes: 16 additions & 15 deletions provision/dovecot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,25 @@ configure_dovecot_sql_conf()
connect = host=mysql user=vpopmail password=$_vpass dbname=vpopmail
password_query = SELECT \\
CONCAT(pw_name, '@', pw_domain) AS user \\
,pw_clear_passwd AS password \\
,pw_dir AS userdb_home, 89 AS userdb_uid, 89 AS userdb_gid \\
,CASE \\
WHEN (pw_shell = 'NOQUOTA') THEN '*:bytes=0' \\
WHEN (pw_shell RLIKE '^[0-9]+S') THEN concat('*:bytes=', SUBSTRING_INDEX(pw_shell, 'S', 1)) \\
ELSE '?:bytes=0' \\
END AS userdb_quota_rule \\
FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d'
CONCAT(v.pw_name, '@', v.pw_domain) AS user \\
,v.pw_clear_passwd AS password \\
,v.pw_dir AS userdb_home, \\
89 AS userdb_uid, \\
89 AS userdb_gid, \\
CONCAT('*:bytes=', REPLACE(SUBSTRING_INDEX(v.pw_shell, 'S', 1), 'NOQUOTA', '0')) AS userdb_quota_rule \\
FROM vpopmail v \\
LEFT JOIN aliasdomains a ON a.alias='%d' \\
WHERE v.pw_name = '%n' \\
AND (v.pw_domain='%d' OR v.pw_domain=a.domain) \\
AND ('%a'!='995' OR !(v.pw_gid & 2)) \\
AND ('%a'!='993' OR !(v.pw_gid & 8))
user_query = SELECT pw_dir as home \\
,89 AS uid ,89 AS gid \\
,CASE \\
WHEN (pw_shell = 'NOQUOTA') THEN '*:bytes=0' \\
WHEN (pw_shell RLIKE '^[0-9]+S') THEN concat('*:bytes=', SUBSTRING_INDEX(pw_shell, 'S', 1)) \\
ELSE '?:bytes=0' \\
END AS quota_rule \\
FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d'
,CONCAT('*:bytes=', REPLACE(SUBSTRING_INDEX(pw_shell, 'S', 1), 'NOQUOTA', '0')) AS quota_rule \\
FROM vpopmail \\
WHERE pw_name = '%n' \\
AND pw_domain = '%d'
iterate_query = SELECT CONCAT(pw_name, '@', pw_domain) AS user FROM vpopmail
EO_DOVECOT_SQL
Expand Down

0 comments on commit 8a6d809

Please sign in to comment.