#Module-Specific definitions %define apache_version 2.0.54 %define mod_version 0.5.2 %define mod_name mod_suphp %define mod_conf A36_%{mod_name}.conf %define mod_so %{mod_name}.so %define sourcename %{mod_name}-%{mod_version} # Standard Module Definitions %define name apache-%{mod_name} %define version %{apache_version}_%{mod_version} Summary: Mod_suphp is a DSO module for the apache web server Name: %{name} Version: %{version} Release: %mkrel 2 Group: System/Servers License: GPL URL: http://www.suphp.org/ Source0: http://www.suphp.org/download/suphp-%{mod_version}.tar.bz2 Source1: %{mod_conf}.bz2 Requires(pre): rpm-helper Requires(postun): rpm-helper Requires(pre): apache-conf >= 2.0.54 Requires(pre): apache >= %{apache_version} Requires: apache-conf >= 2.0.54 Requires: apache >= %{apache_version} BuildRequires: apache-devel >= %{apache_version} BuildRequires: file Requires: php-cgi Provides: apache2-mod_suphp Obsoletes: apache2-mod_suphp BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot %description suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter. This package provides support for php4 and php5 as of: o mod_suphp4.so uses the %{_bindir}/php4-cgi binary o mod_suphp5.so uses the %{_bindir}/php-cgi binary o mod_suphp5_fcgi.so uses the %{_bindir}/php-fcgi binary %prep %setup -q -n suphp-%{mod_version} # strip away annoying ^M find . -type f|xargs file|grep 'CRLF'|cut -d: -f1|xargs perl -p -i -e 's/\r//' find . -type f|xargs file|grep 'text'|cut -d: -f1|xargs perl -p -i -e 's/\r//' %build COMMON_CONFIGURE="--enable-checkpath \ --enable-checkuid \ --enable-checkgid \ --with-apxs=%{_sbindir}/apxs \ --with-setid-mode=owner \ --with-min-uid=100 \ --with-min-gid=100 \ --with-apache-user=apache" %configure2_5x \ $COMMON_CONFIGURE \ --with-php=%{_bindir}/php4-cgi \ --with-logfile=%{_var}/log/httpd/suphp4_log cp src/apache2/mod_suphp.c src/apache2/mod_suphp4.c perl -pi -e "s|suphp|suphp4|g" src/apache2/mod_suphp4.c perl -pi -e "s|suPHP|suPHP4|g" src/apache2/mod_suphp4.c pushd src/apache2 %{_sbindir}/apxs \ -I. \ -DHAVE_CONFIG_H \ -DSUPHP_PATH_TO_SUPHP=\\\"%{_sbindir}/suphp4\\\" \ -c mod_suphp4.c popd cp src/apache2/.libs/mod_suphp4.so . %make -C src suphp cp src/suphp suphp4 make clean %configure2_5x \ $COMMON_CONFIGURE \ --with-php=%{_bindir}/php-cgi \ --with-logfile=%{_var}/log/httpd/suphp5_log cp src/apache2/mod_suphp.c src/apache2/mod_suphp5.c perl -pi -e "s|suphp|suphp5|g" src/apache2/mod_suphp5.c perl -pi -e "s|suPHP|suPHP5|g" src/apache2/mod_suphp5.c pushd src/apache2 %{_sbindir}/apxs \ -I. \ -DHAVE_CONFIG_H \ -DSUPHP_PATH_TO_SUPHP=\\\"%{_sbindir}/suphp5\\\" \ -c mod_suphp5.c popd cp src/apache2/.libs/mod_suphp5.so . %make -C src suphp cp src/suphp suphp5 make clean %configure2_5x \ $COMMON_CONFIGURE \ --with-php=%{_bindir}/php-fcgi \ --with-logfile=%{_var}/log/httpd/suphp5_fcgi_log cp src/apache2/mod_suphp.c src/apache2/mod_suphp5_fcgi.c perl -pi -e "s|suphp|suphp5_fcgi|g" src/apache2/mod_suphp5_fcgi.c perl -pi -e "s|suPHP|suPHP5_fcgi|g" src/apache2/mod_suphp5_fcgi.c pushd src/apache2 %{_sbindir}/apxs \ -I. \ -DHAVE_CONFIG_H \ -DSUPHP_PATH_TO_SUPHP=\\\"%{_sbindir}/suphp5_fcgi\\\" \ -c mod_suphp5_fcgi.c popd cp src/apache2/.libs/mod_suphp5_fcgi.so . %make -C src suphp cp src/suphp suphp5_fcgi make clean %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} install -d %{buildroot}%{_sysconfdir}/logrotate.d install -d %{buildroot}%{_sbindir} install -d %{buildroot}%{_libdir}/apache-extramodules install -d %{buildroot}%{_sysconfdir}/httpd/modules.d install -m0755 mod_suphp4.so %{buildroot}%{_libdir}/apache-extramodules/ install -m0755 mod_suphp5.so %{buildroot}%{_libdir}/apache-extramodules/ install -m0755 mod_suphp5_fcgi.so %{buildroot}%{_libdir}/apache-extramodules/ install -m0755 suphp4 %{buildroot}%{_sbindir}/suphp4 install -m0755 suphp5 %{buildroot}%{_sbindir}/suphp5 install -m0755 suphp5_fcgi %{buildroot}%{_sbindir}/suphp5_fcgi bzcat %{SOURCE1} > %{buildroot}%{_sysconfdir}/httpd/modules.d/%{mod_conf} install -d %{buildroot}%{_var}/www/html/addon-modules ln -s ../../../..%{_docdir}/%{name}-%{version} %{buildroot}%{_var}/www/html/addon-modules/%{name}-%{version} # install log rotation stuff cat > %{buildroot}%{_sysconfdir}/logrotate.d/%{name} << EOF %{_var}/log/httpd/suphp4_log %{_var}/log/httpd/suphp5_log %{_var}/log/httpd/suphp5_fcgi_log { size=2000M rotate 5 monthly missingok notifempty nocompress prerotate ADVXctl closelogs endscript postrotate ADVXctl closelogs endscript } EOF cat > REAME.MDK << EOF A P A C H E - M O D _ S U P H P ------------------------------- This package provides ways to run php4 and php5 scripts under the uid and gid of the user owning the vhost using the CGI mode oh php. The documentation states it is possible to use suphp with the mod_php DSO installed, but this is not recommended and beyond the scope of this simple documentation. You have three suphp DSO's to choose from, but you have to manually enable the ones you want to use in the %{_sysconfdir}/httpd/conf.d/%{mod_conf} file. o mod_suphp4.so uses the %{_bindir}/php4-cgi binary o mod_suphp5.so uses the %{_bindir}/php-cgi binary o mod_suphp5_fcgi.so uses the %{_bindir}/php-fcgi binary In theory it should be possible to enable all three of them, but it is not recommended. Additionally you also have to install the nessesary php bits like so: urpmi php-cgi Or: urpmi php-fcgi Good luck! Regards // Oden Eriksson EOF %post if [ -f %{_var}/lock/subsys/httpd ]; then %{_initrddir}/httpd restart 1>&2; fi %postun if [ "$1" = "0" ]; then if [ -f %{_var}/lock/subsys/httpd ]; then %{_initrddir}/httpd restart 1>&2 fi fi %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files %defattr(-,root,root) %doc AUTHORS COPYING ChangeLog README REAME.MDK doc %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/httpd/modules.d/%{mod_conf} %attr(4755,root,root) %{_sbindir}/suphp4 %attr(4755,root,root) %{_sbindir}/suphp5 %attr(4755,root,root) %{_sbindir}/suphp5_fcgi %attr(0755,root,root) %{_libdir}/apache-extramodules/mod_suphp4.so %attr(0755,root,root) %{_libdir}/apache-extramodules/mod_suphp5.so %attr(0755,root,root) %{_libdir}/apache-extramodules/mod_suphp5_fcgi.so %{_var}/www/html/addon-modules/* %changelog * Sat Jul 30 2005 Oden Eriksson <oeriksson@mandriva.com> 2.0.54_0.5.2-2mdk - fix deps * Thu Jun 02 2005 Oden Eriksson <oeriksson@mandriva.com> 2.0.54_0.5.2-1mdk - rename the package - the conf.d directory is renamed to modules.d - use new rpm-4.4.x pre,post magic * Sun Apr 03 2005 Oden Eriksson <oeriksson@mandrakesoft.com> 2.0.53_0.5.2-1mdk - initial package