Skip to content

Commit aa52639

Browse files
author
Pierre Carrier
committed
Zend: support relative paths for extensions
This would simplify greatly puppetization of Zend modules such as xdebug in heterogeneous environments. For example: zend_extension="/usr/lib/php5/20090626/xdebug.so" can become: zend_extension=xdebug.so
1 parent 66a6d1b commit aa52639

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Zend/zend_extensions.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/* $Id$ */
2121

2222
#include "zend_extensions.h"
23+
#include "php.h"
2324

2425
ZEND_API zend_llist zend_extensions;
2526
static int last_resource_number;
@@ -30,8 +31,28 @@ int zend_load_extension(const char *path)
3031
DL_HANDLE handle;
3132
zend_extension *new_extension;
3233
zend_extension_version_info *extension_version_info;
34+
char *normalized_path;
35+
char *extension_dir = INI_STR("extension_dir");
36+
int extension_dir_len = strlen(extension_dir);
37+
38+
if (strchr(path, '/') == NULL || strchr(path, DEFAULT_SLASH) == NULL) {
39+
if (extension_dir && extension_dir[0]) {
40+
if (IS_SLASH(extension_dir[extension_dir_len-1])) {
41+
spprintf(&normalized_path, 0, "%s%s", extension_dir, path);
42+
} else {
43+
spprintf(&normalized_path, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, path);
44+
}
45+
} else {
46+
return FAILURE;
47+
}
48+
} else {
49+
normalized_path = estrdup(path);
50+
}
51+
52+
handle = DL_LOAD(normalized_path);
53+
54+
efree(normalized_path);
3355

34-
handle = DL_LOAD(path);
3556
if (!handle) {
3657
#ifndef ZEND_WIN32
3758
fprintf(stderr, "Failed loading %s: %s\n", path, DL_ERROR());

0 commit comments

Comments
 (0)