commit:     1d1a53e19a9dab621249c1cdf698e2aec30d5d1a
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 22 00:30:25 2016 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Fri Jan 22 00:45:28 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-php.git/commit/?id=1d1a53e1

Add 70_mod_php.conf.in to the project source.

We are currently shipping 70_mod_php.conf as part of the Gentoo ebuild
for eselect-php. This introduces a potential disconnect between the
path in php.eselect and the path in 70_mod_php.conf. By adding the
conf file to the project, we are able to ensure that they are both
set to the same value. Moreover, the new autotools directory magic
lets us set them both based on @localstatedir@. So, for example, in
the conf file we have "@localstatedir <AT> /lib/eselect-php/mod_php.conf"
and in php.eselect we have "@localstatedir@/lib/eselect-php".

We have followed the PHP project's lead in assuming that
$localstatedir will be set to (for example) /var and not /var/lib.
See Gentoo bug 572002. For testing, you should now use something like,

  ./configure --bindir=/usr/bin --sysconfdir=/etc --localstatedir=/var

Of course, the ebuild for eselect-php will automatically pass the
correct values to ./configure.

 Makefile.am            |  6 +++++-
 src/70_mod_php.conf.in | 24 ++++++++++++++++++++++++
 src/php.eselect.in.in  |  2 +-
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 073abf9..9487f1b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,9 @@
 eselectdir = $(datadir)/eselect/modules
 nodist_eselect_DATA = $(srcdir)/src/php.eselect
 
+apacheconfdir = $(sysconfdir)/apache2/modules.d
+nodist_apacheconf_DATA = $(srcdir)/src/70_mod_php.conf
+
 # The next few rules allow us to replace bindir, libdir, and
 # localstatedir within our script and conf file. The example is taken
 # from the autoconf documentation and can be found in the
@@ -9,7 +12,7 @@ edit = sed -e 's|@bindir[@]|$(bindir)|g' \
            -e 's|@libdir[@]|$(libdir)|g' \
            -e 's|@localstatedir[@]|$(localstatedir)|g'
 
-$(nodist_eselect_DATA): Makefile
+$(nodist_eselect_DATA) $(nodist_apacheconf_DATA): Makefile
        rm -f $@ $@.tmp
        srcdir=''; \
          test -f ./$@.in || srcdir=$(srcdir)/; \
@@ -17,3 +20,4 @@ $(nodist_eselect_DATA): Makefile
        mv $@.tmp $@
 
 $(srcdir)/src/php.eselect: $(srcdir)/src/php.eselect.in
+$(srcdir)/src/70_mod_php.conf: $(srcdir)/src/70_mod_php.conf.in

diff --git a/src/70_mod_php.conf.in b/src/70_mod_php.conf.in
new file mode 100644
index 0000000..4b97354
--- /dev/null
+++ b/src/70_mod_php.conf.in
@@ -0,0 +1,24 @@
+<IfDefine PHP>
+       # The mod_php.so symlink is controlled by
+       # eselect-php. However, the module name changed from
+       # php5_module to php7_module so we can't blindly load whatever
+       # is there. Instead we let eselect-php manage a small
+       # configuration file that loads the appropriate module.
+       Include "@localstatedir@/lib/eselect-php/mod_php.conf"
+
+       # Tell apache that mod_php should handle PHP files.
+       #
+       # NOTE: Avoiding AddHandler/AddType for security (bug
+       # #538822). Please read the related news item!
+       <FilesMatch "\.(php|php[57]|phtml)$">
+               SetHandler application/x-httpd-php
+       </FilesMatch>
+
+       # PHP source files which are meant to be displayed as
+       # syntax-highlighted source code.
+       <FilesMatch "\.phps$">
+               SetHandler application/x-httpd-php-source
+       </FilesMatch>
+
+       DirectoryIndex index.php index.phtml
+</IfDefine>

diff --git a/src/php.eselect.in.in b/src/php.eselect.in.in
index e24cd39..689b1db 100644
--- a/src/php.eselect.in.in
+++ b/src/php.eselect.in.in
@@ -332,7 +332,7 @@ get_sapi_active_target() {
 #
 write_mod_php_conf() {
        local target="${1}"
-       local conf_dir="${EROOT}"/var/lib/eselect-php
+       local conf_dir="@localstatedir@/lib/eselect-php"
        local conf_path="${conf_dir}/mod_php.conf"
 
        @MKDIR_P@ "${conf_dir}" || die "failed to create ${conf_dir}"

Reply via email to