Sophie

Sophie

distrib > Mandriva > 10.2 > x86_64 > by-pkgid > 72f89cc2c7c55918d7832659aa907af6 > files > 2

apache2-mod_suphp-2.0.53_0.5.2-1mdk.src.rpm

#Module-Specific definitions
%define apache_version 2.0.53
%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 apache2-%{mod_name}
%define version %{apache_version}_%{mod_version}

Summary:	Mod_suphp is a DSO module for the apache2 Web server
Name:		%{name}
Version:	%{version}
Release:	%mkrel 1
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
Prereq:		apache2 >= %{apache_version}
Prereq:		apache2-conf
BuildRequires:	apache2-devel >= %{apache_version}-1mdk
BuildRequires:	file
Requires:	php-cgi
BuildRoot:	%{_tmppath}/%{name}-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}/php-cgi binary
 o mod_suphp5.so uses the %{_bindir}/php5-cgi binary
 o mod_suphp5_fcgi.so uses the %{_bindir}/php5-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}/apxs2 \
    --with-setid-mode=owner \
    --with-min-uid=100 \
    --with-min-gid=100 \
    --with-apache-user=apache"

%configure2_5x \
    $COMMON_CONFIGURE \
    --with-php=%{_bindir}/php-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}/apxs2 \
    -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}/php5-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}/apxs2 \
    -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}/php5-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}/apxs2 \
    -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}/apache2-extramodules
install -d %{buildroot}%{_sysconfdir}/httpd/conf.d

install -m0755 mod_suphp4.so %{buildroot}%{_libdir}/apache2-extramodules/
install -m0755 mod_suphp5.so %{buildroot}%{_libdir}/apache2-extramodules/
install -m0755 mod_suphp5_fcgi.so %{buildroot}%{_libdir}/apache2-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/conf.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 2 - 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}/php-cgi binary
 o mod_suphp5.so uses the %{_bindir}/php5-cgi binary
 o mod_suphp5_fcgi.so uses the %{_bindir}/php5-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 php5 bits like so:

urpmi php5-cgi

Or:

urpmi php5-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/conf.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}/apache2-extramodules/mod_suphp4.so
%attr(0755,root,root) %{_libdir}/apache2-extramodules/mod_suphp5.so
%attr(0755,root,root) %{_libdir}/apache2-extramodules/mod_suphp5_fcgi.so
%{_var}/www/html/addon-modules/*

%changelog
* Sun Apr 03 2005 Oden Eriksson <oeriksson@mandrakesoft.com> 2.0.53_0.5.2-1mdk
- initial package