Skip to content

Commit ab391d3

Browse files
committed
fix zif_dl pb (add -Wl,--no-as-needed flag + dlopen of libphpx.so)
1 parent 378055d commit ab391d3

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MODULE_NAME=@MODULE_NAME@
22
MODULE_OBJS=php_embeded.o GetPathDir.o $(MODULE_NAME).o
33
CFLAGS=-fPIC -I@ZABBIX_INC_DIR@ @CFLAGS@ -Wno-cpp
4-
LDFLAGS=@LDFLAGS@
4+
LDFLAGS=@LDFLAGS@ -Wl,--no-as-needed
55
LIBS=@LIBS@
66
CC=gcc
77

configure.ac

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ AC_CONFIG_HEADER(zbx_php_config.h)
4747
AC_OUTPUT(Makefile)
4848

4949
echo ""
50-
echo " Zabbix PHP laodable module install diretory = ${prefix}"
51-
echo " Embeded PHP base directory = ${PHP_PREFIX}"
52-
echo " Zabbix include directory = ${ZABBIX_INC_DIR}"
50+
echo " Zabbix PHP laodable module install diretory[prefix] = ${prefix}"
51+
echo " Embeded PHP base directory = ${PHP_PREFIX}"
52+
echo " Zabbix include directory = ${ZABBIX_INC_DIR}"

php_embeded.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int php_embed_execute(char *filename, zval *retval TSRMLS_DC)
123123
zfd.free_filename = 0;
124124
zfd.opened_path = NULL;
125125
zend_try {
126-
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd))
126+
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, retval, 1, &zfd))
127127
return SUCCESS;
128128
} zend_end_try();
129129
return FAILURE;

zbx_php.c

+9
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ int zbx_module_init()
156156
{
157157
TSRMLS_FETCH();
158158

159+
void *handle;
160+
char szPhpLib[256];
161+
snprintf(szPhpLib, sizeof szPhpLib, "%s%d%s", "libphp", PHP_MAJOR_VERSION, ".so");
162+
handle = dlopen (szPhpLib, RTLD_LAZY | RTLD_GLOBAL);
163+
if (!handle) {
164+
zabbix_log( LOG_LEVEL_ERR, ZBX_MODULE "load %s error!!!!\n%s",szPhpLib,dlerror());
165+
exit(1);
166+
}
167+
159168
// load zbx_php.cfg config file
160169
if (load_php_env_config()!=ZBX_MODULE_OK)
161170
{

zbx_php.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdio.h>
2727
#include <stdlib.h>
2828
#include <unistd.h>
29+
#include <dlfcn.h>
2930

3031
// this macro are defined in php and in zabbix
3132
// to avoid warning in redefiniting it they are undef her befor

0 commit comments

Comments
 (0)