-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mixed case domain name comparisons #98
Conversation
If the configured domain name is in mixed case, the expansion of Postfix configuration generates a bad result, leading to unaccessible addresses (Access denied). This DB schema fix enables case-insensitive matches for the domains key. The COLLATE NOCASE is effective also in new record insertion, to prevent inserting the same domain multiple times with different letter case.
- Define columns as case-insensitive to fix lookup of addresses with mixed case letters, e.g. duDE@My.Example.org - Define columns for LDAP user and group names case-insensitive as LDAP itself, e.g. for Administrator and Domain Admins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well you are the expert here, but maybe in the UI or in the backend we should convert everything to lowercase from the user input, what do you think, at least it will be nicer to see
I was double-minded about that. I think mixed case is rarely used, but to correctly allow it at the API level, there are a lot of code points to change. Instead the DB-level approach looks smaller and I hope this PR is enough to achieve it.
|
not possible to just add
something like (obviously we keep your changes) "domain": request['domain'].lower() |
Then open an editor and prepare a .sql file inserting CREATE TABLE statements in the template below: BEGIN TRANSACTION;
CREATE TABLE temp_domains AS SELECT * FROM destmap; DROP TABLE domains;
CREATE TABLE temp_destmap AS SELECT * FROM destmap; DROP TABLE destmap;
CREATE TABLE temp_addresses AS SELECT * FROM addresses; DROP TABLE addresses;
CREATE TABLE temp_userattrs AS SELECT * FROM userattrs; DROP TABLE userattrs;
CREATE TABLE temp_userforwards AS SELECT * FROM userforwards; DROP TABLE userforwards;
CREATE TABLE temp_groupattrs AS SELECT * FROM groupattrs; DROP TABLE groupattrs;
--
-- insert here the CREATE TABLE commands from pcdb-init.sql
-- https://github.com/NethServer/ns8-mail/blob/main/postfix/etc/postfix/pcdb-init.sql
--
INSERT INTO domains SELECT * FROM temp_destmap; DROP TABLE temp_domains ;
INSERT INTO destmap SELECT * FROM temp_destmap; DROP TABLE temp_destmap ;
INSERT INTO addresses SELECT * FROM temp_addresses; DROP TABLE temp_addresses ;
INSERT INTO userattrs SELECT * FROM temp_userattrs; DROP TABLE temp_userattrs ;
INSERT INTO userforwards SELECT * FROM temp_userforwards; DROP TABLE temp_userforwards ;
INSERT INTO groupattrs SELECT * FROM temp_groupattrs; DROP TABLE temp_groupattrs ;
COMMIT; Open a terminal and paste the resulting commands to upgrade the SQLite DB schema:
|
No, it does not fix Postfix lookup too:
Need also to fix migration code |
If the configured domain name is in mixed case, the expansion of Postfix configuration generates a bad result, leading to unaccessible addresses (Access denied). This DB schema fix enables case-insensitive matches for the domains key.
The COLLATE NOCASE is effective also in new record insertion, to prevent inserting the same domain multiple times with different letter case.
Additional columns changed to COLLATE NOCASE, to fix more failure cases:
DuDE@example.org
Refs NethServer/dev#6906
As the issue rarely occurs, the PR does not alter the DB schema of existing installations.