Apache module removed from httpd.conf after pkg install

I've noticed that when I install the www/mod_authnz_external24 (i.e. pkg install ap24-mod_authnz_external24), the line
Code:
LoadModule authnz_external_module libexec/apache24/mod_authnz_external.so
in /usr/local/etc/apache24/httpd.conf gets removed. If I re-add the line and reinstall the port ( pkg install -f ap24-mod_authnz_external24), it gets removed again.

I'm wondering what is causing this behavior, and how might I stop it from happening? I haven't noticed any other package installations altering my Apache configuration.

Thanks!
 
I'm wondering what is causing this behavior, and how might I stop it from happening? I haven't noticed any other package installations altering my Apache configuration.
I have, in fact I even think this is somewhat common behavior amongst packages/ports. Not exactly great behavior considering the existence of the modules.d folder (not to mention Includes), but nevertheless....

When installing www/mod_jk for example I'm experiencing the exact same thing with its include line. Of course other ports like www/mod_mono do things as you'd expect: add a config file and handle the mod loading in there.
 
I'm wondering what is causing this behavior,
Examining the +MANIFEST [1] of package ap24-mod_authnz_external24-3.3.3.pkg, the cause is that a post-install script is executed, involving apxs(1) (installed by package apache24).

This application overwrites /usr/local/etc/apache24/httpd.conf every time it is installed.

See also install message:
Code:
[preparing module `authnz_external' in /usr/local/etc/apache24/httpd.conf]

and how might I stop it from happening?
This "module preparation" appears to be integrated in the source code of www/mod_authnz_external24 ( Makefile , see install: $(APXS) -a . For -a see apxs(1)), which suggest, to change the behavior, patching the source code is required (without breaking things).


[1]
Rich (BB code):
 % tar xfO  ap24-mod_authnz_external24-3.3.3.pkg +MANIFEST
...
"scripts":{"post-install":"/usr/local/sbin/apxs -e -A -n authnz_external /usr/local/libexec/apache24/mod_authnz_external.so"
...
Description of apxs(1) -e -A -n options:
Code:
...
SUMMARY
       apxs is a tool for building and installing extension modules for the
       Apache HyperText Transfer Protocol (HTTP) server. This is achieved by
       building a dynamic shared object (DSO) from one or more source or
       object files which then can be loaded into the Apache server under
       runtime via the LoadModule directive from mod_so.
...
OPTIONS
   Common Options
       -n modname
              This explicitly sets the module name for the -i (install) and -g
              (template generation) option. Use this to explicitly specify the
              module name. For option -g this is required, for option -i the
              apxs tool tries to determine the name from the source or (as a
              fallback) at least by guessing it from the filename.
...
   DSO Installation and Configuration Options
...
       -A     Same as option -a but the created LoadModule directive is
              prefixed with a hash sign (#), i.e., the module is just prepared
              for later activation but initially disabled.

       -e     This indicates the editing operation, which can be used with the
              -a and -A options similarly to the -i operation to edit Apache's
              httpd.conf configuration file without attempting to install the
              module.
 
Ah, interesting. It looks like the -A argument for apxs is supposed to add it to httpd.conf, but commented out with a #. Instead, it's removing it entirely (even if it already exists). Although it would still be annoying if the install script disabled it when it was already enabled. I wonder if it should use -a instead of -A.
 
After a little more experimenting, I've found the following:
  • Running /usr/local/sbin/apxs -e -A -n authnz_external /usr/local/libexec/apache24/mod_authnz_external.so has two behaviors:
    • If the authnz_external_module module already exists in httpd.conf, then it removes it entirely. It does not matter if the LoadModule line is commented out or not! It always removes it if the line exists.
    • If the LoadModule line does not already exist, it adds one commented out with a #
  • Running /usr/local/sbin/apxs -e -a -n authnz_external /usr/local/libexec/apache24/mod_authnz_external.so works as expected:
    • If the module already exists, it does nothing.
    • If the module doesn't exist, it adds it (uncommented).
The behavior in the first bullet seems like a bug in apxs to me. I don't know why repeated runs of the same command with the -A argument would alternate between adding and removing the LoadModule line. I filed a bug for this in Apache's bugzilla.

Additionally, it seems like it would make more sense for the post-install script to use -a since a user presumably wants to use the module they just installed from this package. In fact, I see the mod-auth-external Makefile calls apxs like this: $(APXS) -i -a mod_authnz_external.la

My suggestion would be to change the post-install script to pass -a instead of -A to apxs. Is the typical approach for changes like this to reach out directly to the maintainer of www/mod_authnz_external24?
 
Back
Top