benningm / mtpolicyd

a modular policy daemon for postfix
21 stars 3 forks source link

Accounting not recording user with uppercase names #31

Closed simonb256 closed 6 years ago

simonb256 commented 6 years ago

Running 2.02-3 from Debian Stretch repos.

Purely to record mail volume for sasl authenticated users to a MySQL database.

Users whos name starts with a capital letter do not get recorded.

I'm currently poking around the files in /usr/share/perl5/Mail/MtPolicyd as this sounds like a simple re-ex problem at the moment.

mtpolicyd.conf contents below:

# listen on port 12345 (multiple ports can be separated by ',') port="127.0.0.1:12345"

# DB settings <Connection db> module = "Sql" dsn="dbi:mysql:database=relaystats:host=W.X.Y.Z" user=username password=password </Connection>

# defined host for this port <VirtualHost 12345> name=outgoing <Plugin acct-clients> module = "Accounting" # per ip and user fields = "client_address,sasl_username" time_pattern = "%Y-%m-%d" table_prefix = "acct_" </Plugin> </VirtualHost>

benningm commented 6 years ago

In a quick test it created and increased counter for keys with upper case letters:

MariaDB [mtpolicyd]> select * from acct_sasl_username;
+----+--------+------------+-------+------------+--------+-----------+
| id | key    | time       | count | count_rcpt | size   | size_rcpt |
+----+--------+------------+-------+------------+--------+-----------+
|  1 | you    | 2018-07-18 |     3 |          3 |  37035 |     37035 |
|  2 | BIGONE | 2018-07-18 |    14 |         14 | 172830 |    172830 |
+----+--------+------------+-------+------------+--------+-----------+
2 rows in set (0.000 sec)

The database field for key is currently case insensitive (in the database). That means that the row will be created with the string of the first occurance. And it will be used for all following requests regardless of the case.

benningm commented 6 years ago

Closing this. Reopen if another behaviour is expected.