https://bz.apache.org/bugzilla/show_bug.cgi?id=70259

            Bug ID: 70259
           Summary: apxs -A may leave a module enabled when duplicate
                    LoadModule entries exist
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: support
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Tested on trunk bae35cfbf7. The -a/-A code in support/apxs.in is identical on
2.4.x. Found while investigating bug 69648. This is separate from the
file-boundary problem (bug 70258): it happens in the middle of a file and has a
different cause.

If httpd.conf contains both an active and a commented copy of the same
LoadModule line, apxs -A can leave the active one in place.

  d=$(mktemp -d); mkdir $d/conf
  printf 'LoadModule other_module modules/mod_other.so\nLoadModule foo_module
modules/mod_foo.so\n#LoadModule foo_module modules/mod_foo.so\n# end\n' >
$d/conf/httpd.conf
  apxs -S SYSCONFDIR=$d/conf -e -A -n foo mod_foo.so
  cat $d/conf/httpd.conf

Expected: no active LoadModule line for foo remains. The apxs documentation
says -A leaves the module "just prepared for later activation but initially
disabled".
Actual: the active line is not touched and only the commented copy is
rewritten, so the module stays enabled:

  LoadModule other_module modules/mod_other.so
  LoadModule foo_module modules/mod_foo.so
  #LoadModule foo_module         modules/mod_foo.so
  # end

Running it again does not change anything.

The result depends on the order of the two lines. With the commented line first
and the active line second, the active line is the one that gets disabled:

  LoadModule other_module modules/mod_other.so
  #LoadModule foo_module modules/mod_foo.so
  #LoadModule foo_module         modules/mod_foo.so
  # end

Cause: after the existence test finds a match, the replacement
    s|^(.*\n)#?\s*$lmd_re[^\n]*\n|$1$c$lmd\n|s
is applied. Its leading greedy (.*\n) always makes the pattern match the last
matching line in the file, and only one substitution is done, so only that one
copy is rewritten.

-a has the mirror problem: with the same input, apxs -e -a uncomments the
commented copy and leaves the first active copy, giving two active LoadModule
lines for the module.

The documentation does not say what apxs should do with duplicate entries. The
smallest behavior that is consistent with the documentation is that -A leaves
no active copy (and -a leaves a single active copy). Whether duplicates should
also be collapsed is a separate question and is not needed to fix this.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to