Compiling modules

Started by Sob, November 20, 2010, 12:47:03 AM

Previous topic - Next topic

Sob

I noticed strange thing today. I played with mod_geoip for Apache 2.3. It seems to work fine, with one exception - it doesn't add itself to version string ("Apache/x.x.x (WinXX) mod_xxx/x.x.x ..."). Then I found out that my self-compiled version for Apache 2.2 does the same thing. I tried with other module (mod_limitipconn) and the same result again. Binary from ApacheHaus adds itself to version string, while self-compiled version "prefers to stay anonymous". But it's loaded and works. I even checked the binaries and the string "mod_xxxx/x.x.x" is not present in my versions.

So I'm thinking, there must be something wrong with the way how I compile modules. What I do is:

cl.exe <include paths, defines and stuff> -c mod_xxx.c
link.exe <lib paths and stuff> mod_xxx.obj <libs>

How do you do it? :)

Gregg

nor does mod_security, and about a thousand others.

I just explained to Mario the other day why I do it. I had disabled mod_security at one time while I was working with something, forgot to re-enable it. I never realized it cause I am used to not seeing it in the signature. Well, had it been a "noisy" module, I'd of realized it much sooner, so every module that leaves my compiler from that point on has a signature, if one does not exist, I add it in.

Find the post_config hook and add it in. If there is no post_config hook, make one.

ap_add_version_component(p, "mod_macro/1.1.11");

mod_geoip 1.2.5 works in 2.3?


Sob

That explains it. I'm not really familiar with all different modules. With mod_geoip it was binary from you that I saw for the first time, so I compared mine to that. And I was wondering how the same source can produce different results. I thought, maybe there's some special way to compile it, possibly some inteligent compiling script or something that adds the signature somehow, but didn't really believe it. Now the mystery is solved. :)

Quotemod_geoip 1.2.5 works in 2.3?
I didn't do any thorough testing, but at the first sight it does. At least phpinfo() shows $_SERVER["GEOIP_*"] variables.

mario

I tried it with mod_logrotate. I haven't tried to load it, but at least it compiles


--- mod_log_rotate.c.orig 2008-07-24 13:17:45.000000000 +0200
+++ mod_log_rotate.c 2010-11-21 02:31:43.123503300 +0100
@@ -399,6 +399,19 @@
     return add;
}

+/* map into the first apache */
+static int log_rotate_post_config( apr_pool_t * p, apr_pool_t * plog, apr_pool_t * ptemp, server_rec * s)
+{
+ ap_add_version_component(p, "mod_log_rotate/1.00");
+ return OK;
+}
+
+static void log_rotate_register_hooks(apr_pool_t *p)
+{
+ ap_hook_post_config( log_rotate_post_config,   NULL, NULL, APR_HOOK_MIDDLE );
+}
+
+
module AP_MODULE_DECLARE_DATA log_rotate_module = {
     STANDARD20_MODULE_STUFF,
     NULL,                       /* create per-dir config */
@@ -406,6 +419,6 @@
     make_log_options,           /* server config */
     merge_log_options,          /* merge server config */
     rotate_log_cmds,            /* command apr_table_t */
-    NULL                        /* register hooks */
+    log_rotate_register_hooks   /* register hooks */
};



Gregg

@Mario,

It looks fine to me, looks like exactly what I gave you for mod_macro, which works fine and running on 2.3.8 currently.

Apache/2.3.8 (Win32) mod_ssl/2.3.8 OpenSSL/1.0.0a mod_fcgid/2.3.5b mod_macro/1.1.11

I thought I had put fcgid 2.3.6b in there, looks like I didn't. Just another example of why I make them make noise if they do not. Paranoid admins slaughter tokens so I see no reason for any module to be stealth.

Gregg

thanks for the patch Mario.

Builds and loads on lappy

Apache/2.3.8 (Win32) mod_ssl/2.3.8 OpenSSL/1.0.0a mod_fcgid/2.3.5 mod_ftp/1.0.0 mod_log_rotate/1.00 mod_macro/1.1.11

mario

Quote from: Gregg on November 21, 2010, 08:32:18 PM
Apache/2.3.8 (Win32) mod_ssl/2.3.8 OpenSSL/1.0.0a mod_fcgid/2.3.5 mod_ftp/1.0.0 mod_log_rotate/1.00 mod_macro/1.1.11

LOL add a few more signatures to the module and you need to scroll horizontal while viewing the status page.

Gregg

Naw, I have a page that gives it to me nice and neatly at 800px wide, so what if it's a couple lines long.