Topic: iRedAPD plugin sql_user_restrictions dont work as expected
==== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version: 0.8.5
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Debian 6 squeeze
- Related log if you're reporting an issue: end of topic
====
Hi all, thanks for this great piece of software, it's great!
Need your help to fix a problem, i have one virtual domain in mysql backend ( mydomain.local ) and i want to lock all users of this domain to send and receive mail only within the local domain, so no mail coming from or directed to internet domain are allowed.
From the research I found this forum topic:
http://www.iredmail.org/forum/topic5325 … users.html
but the iRedAPD plugin sql_user_restrictions dont work as expected.
In practice i have updated the user row on vmail.mailbox as described and set the field allowedrecipients='@mydomain.local', rejectedrecipients='@' for all users.
The problem is that when a user try to send a mail outside of mydomain.local (for example john.smith@gmail.com) the mail is delivered successfully.
One notice: when i set the field rejectedrecipients='@.' (whit a dot after the @) no one is allowed to send mail everywhere
I have enebled debug mode log in the iRedAPD settings (/opt/iredapd/settings.py)
Here is the log where user_1@mydomain.local send a mail to user_2@mydomain.local and to john.smith@gmail.com :
2013-09-23 15:27:38 DEBUG Connect from 127.0.0.1, port 58643.
2013-09-23 15:27:38 DEBUG smtp session: request=smtpd_access_policy
2013-09-23 15:27:38 DEBUG smtp session: protocol_state=RCPT
2013-09-23 15:27:38 DEBUG smtp session: protocol_name=ESMTP
2013-09-23 15:27:38 DEBUG smtp session: client_address=127.0.0.1
2013-09-23 15:27:38 DEBUG smtp session: client_name=localhost
2013-09-23 15:27:38 DEBUG smtp session: reverse_client_name=localhost
2013-09-23 15:27:38 DEBUG smtp session: helo_name=192.168.1.10
2013-09-23 15:27:38 DEBUG smtp session: sender=user_1@mydomain.local
2013-09-23 15:27:38 DEBUG smtp session: recipient=user_2@mydomain.local
2013-09-23 15:27:38 DEBUG smtp session: recipient_count=0
2013-09-23 15:27:38 DEBUG smtp session: queue_id=
2013-09-23 15:27:38 DEBUG smtp session: instance=a72.524041ca.dcafc.0
2013-09-23 15:27:38 DEBUG smtp session: size=0
2013-09-23 15:27:38 DEBUG smtp session: etrn_domain=
2013-09-23 15:27:38 DEBUG smtp session: stress=
2013-09-23 15:27:38 DEBUG smtp session: sasl_method=LOGIN
2013-09-23 15:27:38 DEBUG smtp session: sasl_username=user_1@mydomain.local
2013-09-23 15:27:38 DEBUG smtp session: sasl_sender=
2013-09-23 15:27:38 DEBUG smtp session: ccert_subject=
2013-09-23 15:27:38 DEBUG smtp session: ccert_issuer=
2013-09-23 15:27:38 DEBUG smtp session: ccert_fingerprint=
2013-09-23 15:27:38 DEBUG smtp session: encryption_protocol=
2013-09-23 15:27:38 DEBUG smtp session: encryption_cipher=
2013-09-23 15:27:38 DEBUG smtp session: encryption_keysize=0
2013-09-23 15:27:38 DEBUG --> Apply plugin: sql_alias_access_policy
2013-09-23 15:27:38 DEBUG SQL: SELECT accesspolicy, goto, moderators
FROM alias
WHERE
address='user_2@mydomain.local'
AND address <> goto
AND domain='rapspa.local'
AND active=1
LIMIT 1
2013-09-23 15:27:38 DEBUG SQL Record: None
2013-09-23 15:27:38 DEBUG <-- Result: DUNNO (Not mail alias)
2013-09-23 15:27:38 DEBUG --> Apply plugin: sql_user_restrictions
2013-09-23 15:27:38 DEBUG SQL to get restriction rules of sender (user_1@mydomain.local):
SELECT
allowedrecipients, rejectedrecipients,
allowedsenders, rejectedsenders
FROM mailbox
WHERE username='user_1@mydomain.local'
LIMIT 1
2013-09-23 15:27:38 DEBUG Returned SQL Record: ('@mudomain.local', '@', '', '')
2013-09-23 15:27:38 DEBUG All allowed recipient: ['@mudomain.local']
2013-09-23 15:27:38 DEBUG All rejected recipient: ['@']
2013-09-23 15:27:38 DEBUG SQL to get restriction rules of recipient (user_2@mydomain.local):
SELECT
allowedrecipients, rejectedrecipients,
allowedsenders, rejectedsenders
FROM mailbox
WHERE username='user_2@mydomain.local'
LIMIT 1
2013-09-23 15:27:38 DEBUG Returned SQL Record: ('@mudomain.local', '@', '', '')
2013-09-23 15:27:38 DEBUG No restrictions of recipient.
2013-09-23 15:27:38 DEBUG <-- Result: DUNNO
2013-09-23 15:27:38 INFO [127.0.0.1] user_1@mydomain.local -> user_2@mydomain.local, DUNNO
2013-09-23 15:27:38 DEBUG Connection closed
2013-09-23 15:27:38 DEBUG Closed SQL connection.
2013-09-23 15:27:39 DEBUG Connect from 127.0.0.1, port 58652.
2013-09-23 15:27:39 DEBUG smtp session: request=smtpd_access_policy
2013-09-23 15:27:39 DEBUG smtp session: protocol_state=RCPT
2013-09-23 15:27:39 DEBUG smtp session: protocol_name=ESMTP
2013-09-23 15:27:39 DEBUG smtp session: client_address=127.0.0.1
2013-09-23 15:27:39 DEBUG smtp session: client_name=localhost
2013-09-23 15:27:39 DEBUG smtp session: reverse_client_name=localhost
2013-09-23 15:27:39 DEBUG smtp session: helo_name=192.168.1.10
2013-09-23 15:27:39 DEBUG smtp session: sender=user_1@mydomain.local
2013-09-23 15:27:39 DEBUG smtp session: recipient=john.smith@gmail.com
2013-09-23 15:27:39 DEBUG smtp session: recipient_count=0
2013-09-23 15:27:39 DEBUG smtp session: queue_id=DF6D8A3AF0
2013-09-23 15:27:39 DEBUG smtp session: instance=a72.524041ca.dcafc.0
2013-09-23 15:27:39 DEBUG smtp session: size=0
2013-09-23 15:27:39 DEBUG smtp session: etrn_domain=
2013-09-23 15:27:39 DEBUG smtp session: stress=
2013-09-23 15:27:39 DEBUG smtp session: sasl_method=LOGIN
2013-09-23 15:27:39 DEBUG smtp session: sasl_username=user_1@mydomain.local
2013-09-23 15:27:39 DEBUG smtp session: sasl_sender=
2013-09-23 15:27:39 DEBUG smtp session: ccert_subject=
2013-09-23 15:27:39 DEBUG smtp session: ccert_issuer=
2013-09-23 15:27:39 DEBUG smtp session: ccert_fingerprint=
2013-09-23 15:27:39 DEBUG smtp session: encryption_protocol=
2013-09-23 15:27:39 DEBUG smtp session: encryption_cipher=
2013-09-23 15:27:39 DEBUG smtp session: encryption_keysize=0
2013-09-23 15:27:39 DEBUG --> Apply plugin: sql_alias_access_policy
2013-09-23 15:27:39 DEBUG SQL: SELECT accesspolicy, goto, moderators
FROM alias
WHERE
address='john.smith@gmail.com'
AND address <> goto
AND domain='gmail.com'
AND active=1
LIMIT 1
2013-09-23 15:27:39 DEBUG SQL Record: None
2013-09-23 15:27:39 DEBUG <-- Result: DUNNO (Not mail alias)
2013-09-23 15:27:39 DEBUG --> Apply plugin: sql_user_restrictions
2013-09-23 15:27:39 DEBUG SQL to get restriction rules of sender (user_1@mydomain.local):
SELECT
allowedrecipients, rejectedrecipients,
allowedsenders, rejectedsenders
FROM mailbox
WHERE username='user_1@mydomain.local'
LIMIT 1
2013-09-23 15:27:39 DEBUG Returned SQL Record: ('@mudomain.local', '@', '', '')
2013-09-23 15:27:39 DEBUG All allowed recipient: ['@mudomain.local']
2013-09-23 15:27:39 DEBUG All rejected recipient: ['@']
2013-09-23 15:27:39 DEBUG SQL to get restriction rules of recipient (john.smith@gmail.com):
SELECT
allowedrecipients, rejectedrecipients,
allowedsenders, rejectedsenders
FROM mailbox
WHERE username='john.smith@gmail.com'
LIMIT 1
2013-09-23 15:27:39 DEBUG Returned SQL Record: None
2013-09-23 15:27:39 DEBUG <-- Result: DUNNO
2013-09-23 15:27:39 INFO [127.0.0.1] user_1@mydomain.local -> john.smith@gmail.com, DUNNO
2013-09-23 15:27:39 DEBUG Connection closed
2013-09-23 15:27:39 DEBUG Closed SQL connection.
I hope you can help me.
Regards.
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.