mushorg / bfr Goto Github PK
View Code? Open in Web Editor NEWBetter Function Replacer based on APD
License: Other
Better Function Replacer based on APD
License: Other
I am getting the following error when building in a Alpine 3.14 environment (php7.x):
creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
/bin/sh /opt/BFR/libtool --mode=compile cc -Werror -Wall -I. -I/opt/BFR -DPHP_ATOM_INC -I/opt/BFR/include -I/opt/BFR/main -I/opt/BFR -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /opt/BFR/php_bfr.c -o php_bfr.lo
make: /bin/sh: Operation not permitted
make: *** [Makefile:191: php_bfr.lo] Error 127
You can reproduce the error using this Dockerfile (Alpine 3.13 works, though):
FROM alpine:3.14
#
# Install packages
RUN apk -U --no-cache add \
build-base \
file \
git \
make \
php7 \
php7-dev \
py3-pip \
python3 \
python3-dev \
re2c && \
#
# Install bfr sandbox from git
git clone https://github.com/mushorg/BFR /opt/BFR && \
cd /opt/BFR && \
phpize7 && \
./configure \
--with-php-config=/usr/bin/php-config7 \
--enable-bfr && \
make && \
make install && \
cd / && \
rm -rf /opt/BFR /tmp/* /var/tmp/* && \
echo "zend_extension = "$(find /usr -name bfr.so) >> /etc/php7/php.ini && \
#
# Install PHP Sandbox
git clone https://github.com/mushorg/phpox /opt/phpox && \
cd /opt/phpox && \
git checkout a62c8136ec7b3ebab0c989f4235e2960175121f8 && \
pip3 install -r requirements.txt && \
make && \
#
# Clean up
apk del --purge build-base \
git \
php7-dev \
python3-dev && \
rm -rf /root/* && \
rm -rf /var/cache/apk/*
#
# Set workdir and start phpsandbox
USER nobody:nobody
WORKDIR /opt/phpox
CMD ["python3", "sandbox.py"]
Are you planning for PHP8 support?
Building with BFR with PHP8 currently fails...
/opt/BFR/php_bfr.c: In function 'zif_override_function':
/opt/BFR/php_bfr.c:123:55: error: expected ')' before 'TSRMLS_CC'
123 | zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
| ~ ^~~~~~~~~
/opt/BFR/php_bfr.c:123:17: error: too few arguments to function 'zend_parse_parameters'
123 | zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
| ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_API.h:304:22: note: declared here
304 | ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
| ^~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:139:79: error: expected ')' before 'TSRMLS_CC'
139 | eval_name = zend_make_compiled_string_description(TEMP_OVRD_FUNC_DESC TSRMLS_CC);
| ~ ^~~~~~~~~
/opt/BFR/php_bfr.c:140:61: error: expected ')' before 'TSRMLS_CC'
140 | retval = zend_eval_string(eval_code, NULL, eval_name TSRMLS_CC);
| ~ ^~~~~~~~~~
| )
/opt/BFR/php_bfr.c:147:58: error: 'TSRMLS_C' undeclared (first use in this function); did you mean 'TSRM_H'?
147 | get_active_function_name(TSRMLS_C));
| ^~~~~~~~
| TSRM_H
/opt/BFR/php_bfr.c:147:58: note: each undeclared identifier is reported only once for each function it appears in
/opt/BFR/php_bfr.c:147:33: error: too many arguments to function 'get_active_function_name'
147 | get_active_function_name(TSRMLS_C));
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:156:33: error: too many arguments to function 'get_active_function_name'
156 | get_active_function_name(TSRMLS_C));
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:175:33: error: too many arguments to function 'get_active_function_name'
175 | get_active_function_name(TSRMLS_C));
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:184:33: error: too many arguments to function 'get_active_function_name'
184 | get_active_function_name(TSRMLS_C));
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c: In function 'zif_rename_function':
/opt/BFR/php_bfr.c:200:55: error: expected ')' before 'TSRMLS_CC'
200 | zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
| ~ ^~~~~~~~~
/opt/BFR/php_bfr.c:200:17: error: too few arguments to function 'zend_parse_parameters'
200 | zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
| ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_API.h:304:22: note: declared here
304 | ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
| ^~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:211:58: error: 'TSRMLS_C' undeclared (first use in this function); did you mean 'TSRM_H'?
211 | get_active_function_name(TSRMLS_C),
| ^~~~~~~~
| TSRM_H
/opt/BFR/php_bfr.c:211:33: error: too many arguments to function 'get_active_function_name'
211 | get_active_function_name(TSRMLS_C),
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:219:33: error: too many arguments to function 'get_active_function_name'
219 | get_active_function_name(TSRMLS_C),
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:230:33: error: too many arguments to function 'get_active_function_name'
230 | get_active_function_name(TSRMLS_C), z_new_fname);
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c:237:33: error: too many arguments to function 'get_active_function_name'
237 | get_active_function_name(TSRMLS_C), z_orig_fname);
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php8/Zend/zend_API.h:29,
from /usr/include/php8/main/php.h:35,
from /opt/BFR/php_bfr.h:27,
from /opt/BFR/php_bfr.c:24:
/usr/include/php8/Zend/zend_execute.h:311:22: note: declared here
311 | ZEND_API const char *get_active_function_name(void);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/BFR/php_bfr.c: In function 'bfr_zend_startup':
/opt/BFR/php_bfr.c:253:9: error: implicit declaration of function 'TSRMLS_FETCH'; did you mean 'TSRMLS_CACHE'? [-Werror=implicit-function-declaration]
253 | TSRMLS_FETCH();
| ^~~~~~~~~~~~
| TSRMLS_CACHE
cc1: all warnings being treated as errors
make: *** [Makefile:208: php_bfr.lo] Error 1
I compiled the extension just fine on PHP7:
php -v
PHP 7.0.10-1~dotdeb+8.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Better Function Replacer (BFR) v0.1, Copyright (C) 2015, by Lukas Rist
I'm using this code to test:
<?php
$ren=rename_function('strlen', 'old_strlen');
$ovr=override_function('strlen', '$string', 'return override_lenstr($string);');
function override_strlen($string) {
return 'THIS TEXT IS ADDED '.old_strlen($string);
}
echo "Results of rename and replace: |{$ren}|{$ovr}|\n";
$var='some string to be measured';
echo "The length of '{$var}' is (override) ".strlen($var)."\n";
echo "The length of '{$var}' is (rename) ".old_strlen($var)."\n";
This is the result:
Results of rename and replace: |1||
The length of 'some string to be measured' is (override) 26
The length of 'some string to be measured' is (rename) 26
As a side note, if I remove line 3 of above (the override_function
line) strlen
is still available.
Also, override_function
never returns true.
Regards.
Resolved.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.