Skip to content

Commit

Permalink
fix zif_dl pb (add -Wl,--no-as-needed flag + dlopen of libphpx.so)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarbonneaux committed Feb 20, 2021
1 parent 378055d commit ab391d3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MODULE_NAME=@MODULE_NAME@
MODULE_OBJS=php_embeded.o GetPathDir.o $(MODULE_NAME).o
CFLAGS=-fPIC -I@ZABBIX_INC_DIR@ @CFLAGS@ -Wno-cpp
LDFLAGS=@LDFLAGS@
LDFLAGS=@LDFLAGS@ -Wl,--no-as-needed
LIBS=@LIBS@
CC=gcc

Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ AC_CONFIG_HEADER(zbx_php_config.h)
AC_OUTPUT(Makefile)

echo ""
echo " Zabbix PHP laodable module install diretory = ${prefix}"
echo " Embeded PHP base directory = ${PHP_PREFIX}"
echo " Zabbix include directory = ${ZABBIX_INC_DIR}"
echo " Zabbix PHP laodable module install diretory[prefix] = ${prefix}"
echo " Embeded PHP base directory = ${PHP_PREFIX}"
echo " Zabbix include directory = ${ZABBIX_INC_DIR}"
2 changes: 1 addition & 1 deletion php_embeded.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int php_embed_execute(char *filename, zval *retval TSRMLS_DC)
zfd.free_filename = 0;
zfd.opened_path = NULL;
zend_try {
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd))
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, retval, 1, &zfd))
return SUCCESS;
} zend_end_try();
return FAILURE;
Expand Down
9 changes: 9 additions & 0 deletions zbx_php.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ int zbx_module_init()
{
TSRMLS_FETCH();

void *handle;
char szPhpLib[256];
snprintf(szPhpLib, sizeof szPhpLib, "%s%d%s", "libphp", PHP_MAJOR_VERSION, ".so");
handle = dlopen (szPhpLib, RTLD_LAZY | RTLD_GLOBAL);

This comment has been minimized.

Copy link
@Elbandi

Elbandi Feb 24, 2021

dlclose missing?

if (!handle) {
zabbix_log( LOG_LEVEL_ERR, ZBX_MODULE "load %s error!!!!\n%s",szPhpLib,dlerror());
exit(1);
}

// load zbx_php.cfg config file
if (load_php_env_config()!=ZBX_MODULE_OK)
{
Expand Down
1 change: 1 addition & 0 deletions zbx_php.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>

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

0 comments on commit ab391d3

Please sign in to comment.