Try to fetch opcache.so path relative to binary

While the cwd-relative lookup worked for the oss-fuzz docker images,
it doesn't seem to work on the cluster infrastructure. Try finding
opcache.so relative to the binary instead.
This commit is contained in:
Nikita Popov 2021-09-23 16:42:24 +02:00
parent ac34648cf6
commit b732b6d06f

View file

@ -126,7 +126,18 @@ ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
}
ZEND_ATTRIBUTE_UNUSED char *get_opcache_path(void) {
// TODO: Make this more general.
char *opcache_path = "modules/opcache.so";
return realpath(opcache_path, NULL);
/* Try relative to cwd. */
char *p = realpath("modules/opcache.so", NULL);
if (p) {
return p;
}
/* Try relative to binary location. */
char path[MAXPATHLEN];
if (readlink("/proc/self/exe", path, sizeof(path)) < 0) {
ZEND_ASSERT(0 && "Failed to get binary path");
return NULL;
}
strlcat(path, "/modules/opcache.so", sizeof(path));
return realpath(path, NULL);
}