php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57823 htscanner httpd emulation (ISP Patch)
Submitted: 2007-09-04 17:30 UTC Modified: 2007-10-05 09:19 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: manuel at mausz dot at Assigned: pajoye
Status: Assigned Package: htscanner (PECL)
PHP Version: Irrelevant OS: Linux/Unix
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-09-04 17:30 UTC] manuel at mausz dot at
Description:
------------
Below is a patch against htscanner cvs head which (mainly) adds a httpd emulation to the htscanner extension. This is achieved by reading the ini setting from a xml file. The xml file is based on apache's configuration and therefor supports virtualhosts, location/-match, directory/-match and file/-match directives. On request serveraddress, -port and -name, the current directory and url will be read, the xml parsed and the ini settings altered. To get better performance the xml document and already prepared directives get cached.
In order to get the same result as apache, I've analysed and
reimplemented apaches parsing methods. The only exception is the vhost handling, which is completely implemented from scratch. The httpd emulation also supports the php_admin_(flag|value) > php_(flag|value) "system".
A command line conversion tool for apache13/apache2x can be found in the scripts-directory (Note: PHP4 support is intention).

Second the patch removes the main-routine from RINIT and hooks into sapi_module.activate. Thus its possible to modify certain ini settings like output_handler, register_globals, etc...

Third (and last) I've also fixed a few minor things like stripping quotes after reading from .htaccess and a few I don't remember any more.

The patch has been tested on gentoo linux and freebsd with apache13/apache20 and mod_fastcgi/mod_fcgi.

If permitted I'd like to further help you in fixing and supporting this extension/enhancement.

Any comments/improvements are much appreciated.

Reproduce code:
---------------
Patch at http://manuel.mausz.at/coding/patches/pecl/htscanner/htscanner-0.9.0.patch


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-15 10:41 UTC] m dot kurzyna at crystalpoint dot pl
When trying to compile ur patch:

 gcc -I. -I/home/users/builder/src/test -DPHP_ATOM_INC -I/home/users/builder/src/test/include -I/home/users/builder/src/test/main -I/home/users/builder/src/test -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libxml2 -DHAVE_CONFIG_H -g -O2 -c /home/users/builder/src/test/htscanner.c  -fPIC -DPIC -o .libs/htscanner.o
/home/users/builder/src/test/htscanner.c: In function 'parse_httpd_directives':
/home/users/builder/src/test/htscanner.c:769: warning: comparison of distinct pointer types lacks a cast
/home/users/builder/src/test/htscanner.c:807: warning: comparison of distinct pointer types lacks a cast
/home/users/builder/src/test/htscanner.c: In function 'parse_httpd_file':
/home/users/builder/src/test/htscanner.c:828: warning: initialization from incompatible pointer type
/home/users/builder/src/test/htscanner.c:829: warning: initialization from incompatible pointer type
/home/users/builder/src/test/htscanner.c:830: warning: initialization from incompatible pointer type
/home/users/builder/src/test/htscanner.c: At top level:
/home/users/builder/src/test/htscanner.c:949: error: expected declaration specifiers or '...' before ',' token
/home/users/builder/src/test/htscanner.c: In function 'sapi_cgi_activate':
/home/users/builder/src/test/htscanner.c:1143: error: expected expression before ',' token
/home/users/builder/src/test/htscanner.c:1143: error: too many arguments to function 'htscanner_main'


htscanner cvs snap from 2007.09.15,

[builder@builder-th64 test]$ rpm -q gcc php-devel
gcc-4.2.1-1.x86_64
php-devel-5.2.3-6.x86_64
 [2007-09-15 10:56 UTC] m dot kurzyna at crystalpoint dot pl
Build process is fixed by following patch, though i'm way too less knowledgeable to consider it a safe change - pls verify:

diff -urN ht-patched/htscanner.c ht-fixed/htscanner.c
--- ht-patched/htscanner.c      2007-09-15 16:52:59.596681277 +0200
+++ ht-fixed/htscanner.c        2007-09-15 16:53:31.807800814 +0200
@@ -946,7 +946,7 @@
 }
 /* }}} */

-static int htscanner_main(TSRMLS_DC) /* {{{ */
+static int htscanner_main(TSRMLS_C) /* {{{ */
 {
        char *doc_root;
        char cwd[MAXPATHLEN + 1];
@@ -1140,7 +1140,7 @@
                php_cgi_sapi_activate(TSRMLS_C);
        }

-       htscanner_main(TSRMLS_CC);
+       htscanner_main(TSRMLS_C);

        return SUCCESS;
 }
 [2007-09-15 12:38 UTC] manuel at mausz dot at
Thanks for your report. The updated patch can be fetched from http://manuel.mausz.at/coding/patches/pecl/htscanner/htscanner-0.9.0-1.patch at. The compiler warnings should be fixed aswell.
 [2007-09-15 15:34 UTC] pierre dot php at gmail dot com
Hi Manuel,

First thanks for the patch!

We have chosen another way to solve the non support ini settings issue as well as the system configuration problems (like admin values in vhost).

We are working on a complete merge of htscanner in php. It will support per dir configuration both in php.ini or in the directories directly (like htscanner). The syntax is the same we have now in php.ini. 

It has a big advantage over apache syntax (which is painful), it is consistent with the php.ini settings (same documentations, settings or options).

The system directives can be set in the main php.ini's using a syntax like (I really mean "like" :):

[admin:/path/to/vhost1] 
 ..option..

[admin:/path/to/vhost2]
 ..option..

Jani is working on the patch while I'm trying to finish the documentation. Cache is already supported as well (ttl).

I will update this bug as soon as we have publish the patch and the docs. A version for php 5.2.x and 5.3+ will be available.
 [2007-09-15 15:58 UTC] manuel at mausz dot at
Hi Pierre,

I thought about such an directory and ini based configuration too, but the problem is that this doesn't support per-vhost settings which is widly used by many ISPs running apache and admin panels like plesk/confixx. So your upcoming implementation isn't a simple drop-in replacement of current setups.

/ manuel
 [2007-09-15 16:36 UTC] pierre dot php at gmail dot com
Vhosts are related to file system paths (from an ISP point of view even more). Everything you can do about php in a httpd.conf can be done this way using this new patch, using the exact same syntax than any other php.ini.

The idea is not to have a dropin replacement of current setup, that's not possible and a would end in a maintenance nightmare. 

The idea behind using PHP's ini syntax and PHP's own ini parser is to keep it working independently from any other non PHP implementations or configuration. It should have been done like this already since day #1.

Having this feature implemented in any distribution is a joke, they do it already in some way. To implement it in tools like webmin, plex or whatever else is also easy as everything is in place. They can even add the per directory htaccess-like in minutes for any sapi.
 [2007-09-17 12:54 UTC] manuel at mausz dot at
per-vhost is not per-directory (or per-location/per-file). But I fully understand your point of view and I'm looking forward to get this implemented and released.

Will your enhancement support something similar then ini-settings modifications via .htaccess files? - If not there's still a need for the htscanner extension. Thus it would be great to at least merge the sapi_module.activate hook into cvs head.
 [2007-09-17 14:04 UTC] pierre dot php at gmail dot com
per-vhost is not per-directory (or per-location/per-file). But I fully
understand your point of view and I'm looking forward to get this
implemented and released.

"Will your enhancement support something similar then ini-settings modifications via .htaccess files?"

Yes, you can have ini files in your document_root like you have .htaccess/scanner files now.

"- If not there's still a need for the htscanner extension. Thus it would be great to at least merge the sapi_module.activate hook into cvs head."

It may makes sense to apply your patch anyway. PHP4 and 5.1 will not be supported (the feature won't be backported).

I'll not have the time to deeply review it before the weekend, but I think it would be good to release htscanner with your patch.
 [2007-09-18 12:59 UTC] m dot kurzyna at crystalpoint dot pl
>> "Will your enhancement support something similar then
>> ini-settings modifications via .htaccess files?"

> Yes, you can have ini files in your document_root like 
> you have .htaccess/scanner files now.

i'm not shure i got it right: will .htaccess style syntax be supported in .htaccess files as well or not? 
as in: "php_value name value" in document_root/.htaccess

many hosted applications come with sutch htaccess files bundled so having to rewrite them to any other syntax (no matter how well motivated) will be a pain. and avg joe user won't understand even the concept of sutch changes so most of the work would have to be done by hosting party.
 [2007-09-18 16:31 UTC] pierre dot php at gmail dot com
"as in: "php_value name value" in document_root/.htacces"

No, as I said earlier the syntax is the php.ini syntax.
 [2007-10-05 09:19 UTC] manuel at mausz dot at
Hi Pierre,

any progress on your review? - If you've questions or suggestions you can contact me anytime (I'd prefer mail)
 [2007-11-19 08:18 UTC] ronny dot schick at udmedia dot de
Feedback please!
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC