diff options
author | Remi Collet <fedora@famillecollet.com> | 2014-04-28 09:38:58 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2014-04-28 09:38:58 +0200 |
commit | 4de194cf4152c77d08ca183fe990f07ee455b98f (patch) | |
tree | 31da85251086ce542d1800b9a03a7baaa263724c |
php-pecl-blenc: 1.1.4b - New package
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | blenc-rpm.patch | 20 | ||||
-rw-r--r-- | blenc-svn.patch | 13 | ||||
-rw-r--r-- | php-pecl-blenc.spec | 248 |
4 files changed, 285 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + diff --git a/blenc-rpm.patch b/blenc-rpm.patch new file mode 100644 index 0000000..4effd3f --- /dev/null +++ b/blenc-rpm.patch @@ -0,0 +1,20 @@ +diff -up blenc-1.1.4b/blenc.c.rpm blenc-1.1.4b/blenc.c +--- blenc-1.1.4b/blenc.c.rpm 2014-04-28 08:13:45.000000000 +0200 ++++ blenc-1.1.4b/blenc.c 2014-04-28 08:14:02.000000000 +0200 +@@ -80,7 +80,7 @@ ZEND_GET_MODULE(blenc) + + /* {{{ PHP_INI */ + PHP_INI_BEGIN() +- STD_PHP_INI_ENTRY("blenc.key_file", "/usr/local/etc/blenckeys", PHP_INI_ALL, OnUpdateString, key_file, zend_blenc_globals, blenc_globals) ++ STD_PHP_INI_ENTRY("blenc.key_file", "/etc/blenckeys", PHP_INI_ALL, OnUpdateString, key_file, zend_blenc_globals, blenc_globals) + PHP_INI_END() + /* }}} */ + +diff -up blenc-1.1.4b/tools/blencode.php.rpm blenc-1.1.4b/tools/blencode.php +--- blenc-1.1.4b/tools/blencode.php.rpm 2014-04-28 08:14:21.000000000 +0200 ++++ blenc-1.1.4b/tools/blencode.php 2014-04-28 08:17:43.000000000 +0200 +@@ -1,3 +1,4 @@ ++#!/usr/bin/php + <?php + /* + +----------------------------------------------------------------------+ diff --git a/blenc-svn.patch b/blenc-svn.patch new file mode 100644 index 0000000..67e518c --- /dev/null +++ b/blenc-svn.patch @@ -0,0 +1,13 @@ +Index: blenc.c +=================================================================== +--- blenc.c (révision 333437) ++++ blenc.c (copie de travail) +@@ -550,7 +550,7 @@ + } + + script = emalloc(BLENC_BUFSIZE); +- for(i = 2; (bytes = php_stream_read(stream, &script[index], BLENC_BUFSIZE TSRMLS_CC)) > 0; i++) { ++ for(i = 2; (bytes = php_stream_read(stream, &script[index], BLENC_BUFSIZE)) > 0; i++) { + + script_len += bytes; + if(bytes == BLENC_BUFSIZE) { diff --git a/php-pecl-blenc.spec b/php-pecl-blenc.spec new file mode 100644 index 0000000..564d7fe --- /dev/null +++ b/php-pecl-blenc.spec @@ -0,0 +1,248 @@ +# spec file for php-pecl-blenc +# +# Copyright (c) 2014 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/3.0/ +# +# Please, preserve the changelog entries +# +%{?scl: %scl_package php-pecl-blenc} +%{!?php_inidir: %global php_inidir %{_sysconfdir}/php.d} +%{!?__pecl: %global __pecl %{_bindir}/pecl} +%{!?__php: %global __php %{_bindir}/php} + +##### bundled lib bf_algo.c (blowfish.c, Paul Kocher) ##### + +%global pecl_name blenc +%global with_zts 0%{?__ztsphp:1} +%global prever b +%if "%{php_version}" < "5.6" +%global ini_name %{pecl_name}.ini +%else +%global ini_name 40-%{pecl_name}.ini +%endif + +Summary: BLowfish ENCryption for PHP Scripts +Name: %{?scl_prefix}php-pecl-%{pecl_name} +Version: 1.1.4 +Release: 0.1.%{prever}%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} + +# blenc is PHP, bf_algo.c is LGPL +License: PHP and LGPL +Group: Development/Languages +URL: http://pecl.php.net/package/blenc +Source0: http://pecl.php.net/get/%{pecl_name}-%{version}%{?prever}.tgz + +# Fix for packaging +Patch0: %{pecl_name}-rpm.patch +# http://svn.php.net/viewvc?view=revision&revision=333439 +Patch1: %{pecl_name}-svn.patch + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: %{?scl_prefix}php-devel +BuildRequires: %{?scl_prefix}php-pear + +Requires(post): %{__pecl} +Requires(postun): %{__pecl} +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} + +Provides: %{?scl_prefix}php-%{pecl_name} = %{version} +Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name}) = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} + +%if "%{?vendor}" == "Remi Collet" +# Other third party repo stuff +Obsoletes: php53-pecl-%{pecl_name} +Obsoletes: php53u-pecl-%{pecl_name} +Obsoletes: php54-pecl-%{pecl_name} +%if "%{php_version}" > "5.5" +Obsoletes: php55u-pecl-%{pecl_name} +%endif +%if "%{php_version}" > "5.6" +Obsoletes: php56u-pecl-%{pecl_name} +%endif +%endif + +%if 0%{?fedora} < 20 && 0%{?rhel} < 7 +# Filter private shared +%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} +%{?filter_setup} +%endif + + +%description +BLENC is an extension that permit to protect PHP source scripts with +Blowfish Encription. + +BLENC hooks into the Zend Engine, allowing for transparent execution +of PHP scripts previously encoded with BLENC. + +It is not designed for complete security (it is still possible to disassemble +the script into op codes using a package such as XDebug), however it does +keep people out of your code and make reverse engineering difficult. + + +%prep +%setup -qc + +mv %{pecl_name}-%{version}%{?prever} NTS +cd NTS + +%patch0 -p1 -b .rpm +%patch1 -p0 -b .rpm + +# Fix shebang for SCL +sed -e 's:/usr/bin/php:%{__php}:' -i tools/blencode.php + +# http://svn.php.net/viewvc?view=revision&revision=333438 +chmod -x bf_algo.? + +extver=$(sed -n '/#define PHP_BLENC_VERSION/{s/.* "//;s/".*$//;p}' php_blenc.h) +if test "x${extver}" != "x%{version}%{?prever}"; then + : Error: Upstream version is ${extver}, expecting %{version}%{?prever}. + exit 1 +fi +cd .. + +cat << 'EOF' | tee %{ini_name} +; Enable BLowfish ENCryption extension module +extension=%{pecl_name}.so + +; It's the location where BLENC can find the file containing a list of +; available decryption keys. This file must be readable by webserver. +;blenc.key_file = "%{_sysconfdir}/blenckeys" +EOF + +%if %{with_zts} +# Duplicate source tree for NTS / ZTS build +cp -pr NTS ZTS +%endif + + +%build +cd NTS +%{_bindir}/phpize +%configure --with-php-config=%{_bindir}/php-config +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +%configure --with-php-config=%{_bindir}/zts-php-config +make %{?_smp_mflags} +%endif + + +%install +rm -rf %{buildroot} + +make -C NTS install INSTALL_ROOT=%{buildroot} + +# Install XML package description +install -Dpm 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml + +# install config file +install -Dpm644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + +%if %{with_zts} +make -C ZTS install INSTALL_ROOT=%{buildroot} +install -Dpm644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} +%endif + +# The command +install -Dpm755 NTS/tools/blencode.php %{buildroot}%{_bindir}/blencode +touch %{buildroot}%{_sysconfdir}/blenckeys + +# Test & Documentation +cd NTS +for i in $(grep 'role="test"' ../package.xml | sed -e 's/^.*name="//;s/".*$//') +do install -Dpm 644 $i %{buildroot}%{pecl_testdir}/%{pecl_name}/$i +done +for i in $(grep 'role="doc"' ../package.xml | sed -e 's/^.*name="//;s/".*$//') +do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i +done + + +%check +: Simple module load test for NTS extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --modules | grep %{pecl_name} + +: Minimal encrytion test +cat <<EOF >foo.php +<?php +echo "Hello World\n"; +EOF +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --define date.timezone=UTC \ + NTS/tools/blencode.php foo.php + +[ -f foo.phpenc ] || exit 1 + +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --define blenc.key_file=key_file.blenc \ + foo.php | grep "Hello World" + +: Upstream test suite for NTS extension +cd NTS +TEST_PHP_EXECUTABLE=%{_bindir}/php \ +TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{__php} -n run-tests.php + +%if %{with_zts} +: Simple module load test for ZTS extension +%{__ztsphp} --no-php-ini \ + --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ + --modules | grep %{pecl_name} + +: Upstream test suite for ZTS extension +cd ../ZTS +TEST_PHP_EXECUTABLE=%{__ztsphp} \ +TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{__ztsphp} -n run-tests.php +%endif + + +%post +%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : + + +%postun +if [ $1 -eq 0 ] ; then + %{pecl_uninstall} %{pecl_name} >/dev/null || : +fi + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%doc %{pecl_docdir}/%{pecl_name} +%doc %{pecl_testdir}/%{pecl_name} +%{pecl_xmldir}/%{name}.xml +%{_bindir}/blencode +%ghost %config(noreplace) %{_sysconfdir}/blenckeys + +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{pecl_name}.so + +%if %{with_zts} +%config(noreplace) %{php_ztsinidir}/%{ini_name} +%{php_ztsextdir}/%{pecl_name}.so +%endif + + +%changelog +* Mon Apr 28 2014 Remi Collet <remi@fedoraproject.org> - 1.1.4-0.1.b +- initial package, version 1.1.4b (beta)
\ No newline at end of file |