https://redmine.lighttpd.net/https://redmine.lighttpd.net/favicon.ico?13667327412010-02-11T19:25:38Zlighty labsLighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=67902010-02-11T19:25:38Zphpmysqlfreak
<ul><li><strong>File</strong> <a href="/attachments/1107">mod_mysql_vhost.c</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1107/mod_mysql_vhost.c">mod_mysql_vhost.c</a> added</li><li><strong>% Done</strong> changed from <i>0</i> to <i>10</i></li></ul><p>depending on the sources of 1.4.19 - installed on my system - i tried to change some things.<br />now i get some other errors like following, while testing some testbuilds.</p>
<pre>
Feb 11 18:01:51 atom019 kernel: lighttpd[1613]: segfault at 0 ip b7519bbf sp bffe9b20 error 6 in libc-2.7.so[b74a7000+138000]
Feb 11 18:06:33 atom019 kernel: lighttpd[2515]: segfault at 0 ip b747dbbf sp bfe5c3b0 error 6 in libc-2.7.so[b740b000+138000]
Feb 11 18:10:29 atom019 kernel: lighttpd[2558]: segfault at 0 ip b7505bbf sp bff5f510 error 6 in libc-2.7.so[b7493000+138000]
Feb 11 18:10:34 atom019 kernel: lighttpd[2572]: segfault at 0 ip b7497bbf sp bfb8b830 error 6 in libc-2.7.so[b7425000+138000]
Feb 11 18:19:04 atom019 kernel: lighttpd[2599]: segfault at 0 ip b7458bbf sp bf909600 error 6 in libc-2.7.so[b73e6000+138000]
Feb 11 18:19:50 atom019 kernel: lighttpd[2616]: segfault at 0 ip b74adbbf sp bfe44700 error 6 in libc-2.7.so[b743b000+138000]
Feb 11 18:26:44 atom019 kernel: lighttpd[2642]: segfault at 0 ip b74e4bbf sp bfc5cf50 error 6 in libc-2.7.so[b7472000+138000]
Feb 11 18:32:18 atom019 kernel: lighttpd[2668]: segfault at 0 ip b7475bbf sp bfc30540 error 6 in libc-2.7.so[b7403000+138000]
Feb 11 18:35:49 atom019 kernel: lighttpd[2687]: segfault at 0 ip b74ecbbf sp bfe081c0 error 6 in libc-2.7.so[b747a000+138000]
Feb 11 18:37:47 atom019 kernel: lighttpd[2706]: segfault at 0 ip b749bbbf sp bfc38f60 error 6 in libc-2.7.so[b7429000+138000]
Feb 11 19:05:48 atom019 kernel: lighttpd[2749]: segfault at 0 ip b74b5bbf sp bf856320 error 6 in libc-2.7.so[b7443000+138000]
</pre>
<p>The attached file has some modifications - first I added mysql_mid between mysql_pre/post. to assemble the complete query i replicated some lines at about line 370.<br />with some output to the error log i verified, that the string is splittet into 3 parts (for me enough, but normally a dirty version with strrchr) - not 2, like before.</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=70522010-07-03T02:06:17Zlonnyk
<ul></ul><p>I was just looking into this and I'm not sure how this can be used in real life with two '?'.</p>
<p>Keep in mind, the '?' is replaced by the URI (hostname) that is being used to hit the server. So if you had:<br />mysql-vhost.sql = "SELECT docroot FROM domains WHERE domain='?';" <br />And my site hit the server the query ran would be:<br />SELECT docroot FROM domains WHERE domain='lonnylot.com';</p>
<p>I don't see how having that in two separate places would make any sense. Can you please post the query you're running as well as an example MySQL table so I can see why this is needed before adding the feature?</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=70532010-07-03T11:39:01Zphpmysqlfreak
<ul></ul><p>My Setup is the following:</p>
<p>MySQL-Table:<br /><pre>
id subdomain domain
2015 www example.tld
2016 www2 example.tld
</pre></p>
<p>the mysql-table contains some data more (for ftp-access, etc.), while the username contains the user-id - in all services.</p>
<p>Now I want this module using a query like this:<br /><pre>
SELECT CONCAT("/webs/",id) AS docroot FROM users WHERE CONCAT(subdomain,".",domain) = '?' OR CONCAT("web-",id,".",domain) = '?';
</pre></p>
<p>One questionmark was not changed, so I tried to change the code. But while running the updated mod, I got the errors mentioned above, so I opened this feature-request.</p>
<p>So one webspace should be accessible by two names:<br />web-2015.example.tld <strong>OR <a class="external" href="http://www.example.tld">www.example.tld</a></strong> should give the content of /webs/2015/<br />web-2016.example.tld <strong>OR www2.example.tld</strong> should give the content of /webs/2016/</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=70902010-07-07T05:16:01Zlonnyk
<ul><li><strong>File</strong> <a href="/attachments/1167">lighttpd_feature_2163.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1167/lighttpd_feature_2163.diff">lighttpd_feature_2163.diff</a> added</li><li><strong>Status</strong> changed from <i>New</i> to <i>Patch Pending</i></li></ul><p>Attached is a diff for this feature against the version in 1.4.26</p>
<p>Let me know what you think.</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=70912010-07-07T09:19:19Zphpmysqlfreak
<ul></ul><p>I applied the patch with following summary:<br />The query is set to right format. All occurences of "?" are replaced.</p>
<p>Now the server is listening on both applied addresses and my aim was reached fully.<br />Thank you for your help.</p>
<p>I will follow the function with much care and report bugs, if I find any.</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=81722013-09-08T17:50:15Ztronox@hotmail.com
<ul></ul><p>Seems like the functions from: <a class="external" href="http://coding.debuntu.org/c-implementing-str_replace-replace-all-occurrences-substring">http://coding.debuntu.org/c-implementing-str_replace-replace-all-occurrences-substring</a> would do the job of this.</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=81742013-09-09T00:25:39Ztronox@hotmail.com
<ul><li><strong>File</strong> <a href="/attachments/1495">mod_mysql_vhost.c</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1495/mod_mysql_vhost.c">mod_mysql_vhost.c</a> added</li><li><strong>File</strong> <i>mod_mysql_vhost.so</i> added</li></ul><p>Attached is the source code and a compiles .so file for the mod_mysql_vhost. This one allows for multiple '?' in the SQL query. And if I knew more about c I could even get it to escape the URI just to be safe (left the code in there that I was working on).</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=81752013-09-09T00:34:39Zstbuehler
<ul><li><strong>File</strong> deleted (<del><i>mod_mysql_vhost.so</i></del>)</li></ul> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=81762013-09-09T05:12:09Ztronox@hotmail.com
<ul><li><strong>File</strong> <a href="/attachments/1497">mod_mysql_vhost.c</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1497/mod_mysql_vhost.c">mod_mysql_vhost.c</a> added</li></ul><p>Further Edited the mod_mysql_vhost.c to allow for user directories to be listed through mysql.<br />SQL Table & Sample Data:<br /><pre>
CREATE TABLE IF NOT EXISTS `vhosts` (
`Uid` int(10) unsigned NOT NULL,
`vhost` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`rootdir` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`admin` varchar(255) COLLATE utf8_bin DEFAULT '',
`extra_php_config` text COLLATE utf8_bin,
UNIQUE KEY `vhostname` (`vhost`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='vhosts';
INSERT INTO `vhosts` (`Uid`, `vhost`, `rootdir`, `admin`, `extra_php_config`) VALUES
(5000, 'example.com', '/var/www/vhosts/example.com/subdomains/test', 'admin@example.com', ''),
(5000, '~shinrai', '/var/www/vhosts/example.com/subdomains/test', 'admin@example.com', '');
</pre></p>
<p><a class="external" href="http://localhost/~shinrai/">http://localhost/~shinrai/</a> or <a class="external" href="http://example.com/">http://example.com/</a> Will serve up the directory '/var/www/vhosts/example.com/subdomains/test'</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=81772013-09-09T05:28:50Ztronox@hotmail.com
<ul></ul><p>Forgot to give the sample SQL for the config:<br /><pre>
SELECT rootdir FROM (SELECT IF((SELECT rootdir FROM vhosts WHERE vhost='~@@') IS NOT NULL,(SELECT rootdir FROM vhosts WHERE vhost='~@@'),IF((SELECT rootdir FROM vhosts WHERE vhost='?') IS NOT NULL,(SELECT rootdir FROM vhosts WHERE vhost='?'),(SELECT rootdir FROM vhosts WHERE '?' like vhost))) as rootdir) as a WHERE rootdir IS NOT NULL
</pre></p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=105222016-10-05T10:06:47Zgstrauss
<ul><li><strong>Target version</strong> changed from <i>1.4.x</i> to <i>1.4.42</i></li><li><strong>% Done</strong> changed from <i>10</i> to <i>0</i></li></ul><p>PSA: anyone using tronox (shinrai) patches above, the patches have serious memory leaks upon every request to URI beginning "/~username"</p>
<p>I re-implemented much simplified support for replacing multiple '?' with escaped URI authority in the MySQL query string.</p>
<p>However, the userdir feature (part of some of the contributed patches above) is not included. If it is desirable to add mod_userdir features into mod_mysql_vhost, giving the option to replace use of mod_userdir with mod_mysql_vhost queries, then there should be a new directive in mod_mysql_vhost to enable this feature (and the memory leaks in the contributed patches must be removed).</p> Lighttpd - Feature #2163: Multiple use of '?' in mysql-vhost.sqlhttps://redmine.lighttpd.net/issues/2163?journal_id=105232016-10-05T10:10:05Zgstrauss
<ul><li><strong>Status</strong> changed from <i>Patch Pending</i> to <i>Fixed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset <a class="changeset" title="[mod_mysql_vhost] support multiple '?' replacement (fixes #2163) support multiple '?' replacemen..." href="https://redmine.lighttpd.net/projects/lighttpd/repository/14/revisions/145ddc2ee72cfed9cedaee85dce69047755aa995">145ddc2ee72cfed9cedaee85dce69047755aa995</a>.</p>