Bug 58304 - Unexpected Warnings from Macro Use in 2.4
Summary: Unexpected Warnings from Macro Use in 2.4
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_macro (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 normal with 2 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-30 17:01 UTC by Tom Browder
Modified: 2018-03-24 14:24 UTC (History)
1 user (show)



Attachments
Add warning about syntax clash (717 bytes, patch)
2016-07-06 07:11 UTC, Marc Stern
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Browder 2015-08-30 17:01:19 UTC
Starting with 2.4.12 and still existing in 2.4.16, when using a Macro definition for virtual hosts, I get repeated warnings to stdout that the macro variables are undefined every time apache is started or during a syntax check: 

root@dedi2:/home/tbrowde# apachectl -t
[Sun Aug 30 16:39:35.097827 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${PROJECT} is not defined
[Sun Aug 30 16:39:35.097911 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${TLD} is not defined
[Sun Aug 30 16:39:35.098007 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${PROJECT} is not defined
[Sun Aug 30 16:39:35.098021 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${TLD} is not defined
[Sun Aug 30 16:39:35.098562 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${PROJECT} is not defined
[Sun Aug 30 16:39:35.098575 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${TLD} is not defined
[Sun Aug 30 16:39:35.098889 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${PROJECT} is not defined
[Sun Aug 30 16:39:35.098904 2015] [core:warn] [pid 4101:tid 140105241839360] AH00111: Config variable ${TLD} is not defined
Syntax OK

I am using three macros that are defined in the httpd.conf file as follows:

<Macro VHOST_NONTLS ${PROJECT} ${TLD}>
  <VirtualHost *:80>
    ServerName  ${PROJECT}.${TLD}
    ServerAlias *.${PROJECT}.${TLD}
    DocumentRoot /home/web-server/${PROJECT}.${TLD}/public
  </VirtualHost>
</Macro>
Use VHOST_NONTLS niceville.pm          org
UndefMacro VHOST_NONTLS

<Macro VHOST_FREE_CERT_TLS ${PROJECT} ${TLD}>
  <VirtualHost *:80>
    ServerName  ${PROJECT}.${TLD}
    ServerAlias *.${PROJECT}.${TLD}
    # enforce ssl/tls
    Redirect Permanent / https://${PROJECT}.${TLD}/
  </VirtualHost>
</Macro>
Use VHOST_FREE_CERT_TLS  computertechnwf  org
UndefMacro VHOST_FREE_CERT_TLS

<Macro VHOST_WILDCARD_TLS ${PROJECT} ${TLD}>
  <VirtualHost *:80>
    ServerName  ${PROJECT}.${TLD}
    ServerAlias *.${PROJECT}.${TLD}
    # enforce ssl/tls
    Redirect Permanent / https://${PROJECT}.${TLD}/
  </VirtualHost>
  # ...
</Macro>
Use VHOST_WILDCARD_TLS highlandsprings61     org
UndefMacro VHOST_WILDCARD_TLS
Comment 1 Marc Stern 2015-09-04 06:43:45 UTC
${VAR} is interpreted as a defined variable (http://httpd.apache.org/docs/2.4/mod/core.html#define). It's equivalent to %{VAR}.

mod_macro uses the syntax $var but also ${var}, which is mandatory if you want the variable to be a part of a string, like in "${var}abc".
The syntax clashes with the Define directive, so it should be changed. Ans %{var} clashes with mod_rewrite.

This doe not only give a warning but could lead to a real mismatch between something defined as a local parameter and somebody else defining it at a global level as a defined config variable.

To make interpolation not clash with another module, we should use another character (instead of an existing one or on top of?) like &{var}.
Comment 2 Marc Stern 2016-07-06 07:11:15 UTC
Created attachment 34013 [details]
Add warning about syntax clash

In case a macro argument uses the syntax ${...}, adds a warning that it clashes with the 'Define' directive