Is there some limit for the maximum length of the line in dovecot-sql.conf? In particular, I would be writing a long MySQL password query.
And further, can a long line be somehow split to several pieces? I tried the common unix-style way of putting backslash as the last character of the first line, but it results in an error immediatedly while restarting Dovecot (while parsing the conf, ie. not a MySQL error):
(in conf:)
password_query = SELECT user, password FROM users
WHERE user='%u' AND active='Y'
(results in log, line 88 refers to line starting with 'WHERE':) auth(default): Error in configuration file /etc/dovecot-mysql.conf line 88: Expecting '='
The example above is just the beginning, what comes to my question about a long line. I would be checking %r (remote ip) against user-specific allowed ip-address ranges given in the database. Actually, I'd like to use some MySQL user-defined variables within my query, for example to keep only the 3 highest octets of the IPv4 representation of %r (eg. '192.168.0') so I could easily check against allowed /24 networks stored in the database. That seems to run into another problem. A very simplified example what happens when I try to define a variable within the query:
(in conf, split to two lines for news only:) password_query = SET @yes='Y'; SELECT user, password FROM users WHERE user='%u' AND active=@yes
(results in log:) Password query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; SELECT user, password FROM users WHERE user='testi' AND active=@yes' at line 1
Anyway, a similar one-line construct works from the MySQL command line: SET @yes='Y'; SELECT user, password FROM users WHERE user='testi' AND active=@yes; (reults the following:) +-------+----------+ | user | password | +-------+----------+ | testi | 123 | +-------+----------+
Any ideas? Am I doing something in a completely wrong way? Of course, split lines & variables are not absolutely necessary, they just would improve readability & shorten the query. But if there is no limit on the length of the query, I propably can write everything as a one long SELECT command...
I'm trying all this on Fedora Core 5, having
- dovecot-1.0-0.beta8.2.fc5
- mysql-5.0.22-1.FC5.1
Regards, Timo Neuvonen