Skip to content

Instantly share code, notes, and snippets.

@cataphract

cataphract/Dockerfile

Last active Dec 6, 2019
Embed
What would you like to do?
PHP bug #78919
PHP_ARG_ENABLE(rinit_error, whether to enable rinit_error support,
[ --enable-rinit_error Enable rinit_error support], no)
if test "$PHP_RINIT_ERROR" != "no"; then
AC_DEFINE(HAVE_RINIT_ERROR, 1, [ Have rinit_error support ])
PHP_NEW_EXTENSION(rinit_error, rinit_error.c, $ext_shared)
fi
FROM php:7.2.25
ADD config.m4 php_rinit_error.h rinit_error.c /opt/rinit_error/
RUN cd /opt/rinit_error && phpize && ./configure && make -j install && make clean
ADD index.php /var/www/html
CMD ["php", "-S", "0.0.0.0:8080", "-d", "memory_limit=2m", \
"-d", "extension=rinit_error.so", "index.php"]
<?php phpinfo();
/* rinit_error extension for PHP */
#ifndef PHP_RINIT_ERROR_H
# define PHP_RINIT_ERROR_H
extern zend_module_entry rinit_error_module_entry;
# define phpext_rinit_error_ptr &rinit_error_module_entry
# define PHP_RINIT_ERROR_VERSION "0.1.0"
# if defined(ZTS) && defined(COMPILE_DL_RINIT_ERROR)
ZEND_TSRMLS_CACHE_EXTERN()
# endif
#endif /* PHP_RINIT_ERROR_H */
/* rinit_error extension for PHP */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "php_rinit_error.h"
#include <main/SAPI.h>
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(rinit_error)
{
#if defined(ZTS) && defined(COMPILE_DL_RINIT_ERROR)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
#define CT_HEADER "Content-type: text/plain"
sapi_header_line line = { .line = CT_HEADER, .line_len = strlen(CT_HEADER) };
(void) sapi_header_op(SAPI_HEADER_REPLACE, &line TSRMLS_CC);
SG(sapi_headers).http_response_code = 200;
#define BODY "OK\r\n"
(void) php_output_write(BODY, strlen(BODY) TSRMLS_CC);
zend_error_noreturn(E_ERROR, "Failing RINIT");
return SUCCESS;
}
/* }}} */
/* {{{ rinit_error_functions[]
*/
static const zend_function_entry rinit_error_functions[] = {
PHP_FE_END
};
/* }}} */
/* {{{ rinit_error_module_entry
*/
zend_module_entry rinit_error_module_entry = {
STANDARD_MODULE_HEADER,
"rinit_error", /* Extension name */
rinit_error_functions, /* zend_function_entry */
NULL, /* PHP_MINIT - Module initialization */
NULL, /* PHP_MSHUTDOWN - Module shutdown */
PHP_RINIT(rinit_error), /* PHP_RINIT - Request initialization */
NULL, /* PHP_RSHUTDOWN - Request shutdown */
NULL, /* PHP_MINFO - Module info */
PHP_RINIT_ERROR_VERSION, /* Version */
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_RINIT_ERROR
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
ZEND_GET_MODULE(rinit_error)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment