Open momala454 opened 2 years ago
also, what's the proper way to replace a library for libcurl in linux using /usr/local/lib ?
It looks like renaming to /usr/local/lib/libcurl.so.4 doesn't work, even after running ldconfig, it looks like it know it is "libcurl-impersonate" and not "libcurl".
Libcurl impersonate only works in conjonction of LD_LIBRARY_PATH or LD_PRELOAD, but that's not great. Do you know a better way using ldconfig ?
Directly replacing /usr/lib/x86_64-linux-gnu/libcurl.so.4 only works until a package is updated on the system
Actually, LD_PRELOAD doesn't work due to SONAME
LD_PRELOAD=/home/libcurl-impersonate.so php script.php
script.php content :
print_r(curl_version());
will show
[ssl_version] => OpenSSL/1.1.1n
if I replace /usr/lib/x86_64-linux-gnu/libcurl.so.4 with libcurl-impersonate.so (after renaming), it works
[ssl_version] => BoringSSL
instead of replacing /usr/lib/x86_64-linux-gnu/libcurl.so.4, i can do this :
LD_PRELOAD will only work if I do this before
patchelf --set-soname libcurl.so.4 /home/libcurl-impersonate.so
When using libcurl-impersonate.so (not sure which one to use, there is .so, .so.4, .so.4.7.0) compiled and replaced, curl will show an error with version not available
libcurl-impersonate is intentionally built without the version information. If I remember correctly, when I built it with version information it wouldn't work since the symbol version information contains the TLS library used. Then you get a mismatch (i.e OpenSSL vs. BoringSSL). I think it is better to leave libcurl-impersonate without versioning info, and I believe you can safely ignore this error.
Libcurl impersonate only works in conjonction of LD_LIBRARY_PATH or LD_PRELOAD, but that's not great. Do you know a better way using ldconfig ?
I think these methods should be preferred. I would consider them less hacky than replacing the system's libcurl, which is not really a good way to do this as you mentioned. LD_PRELOAD
exists for exactly these kind of situations :)
Actually, LD_PRELOAD doesn't work due to SONAME
LD_PRELOAD
definitely works even without changing the SONAME. Try doing LD_PRELOAD=/path/to/libcurl-impersonate-chrome.so curl --version
and it will output:
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 BoringSSL zlib/1.2.11 brotli/1.0.9 nghttp2/1.46.0
If I had to guess, what you are seeing is some PHP-specific quirk. My guess would be that PHP loads libcurl dynamically at runtime and somehow uses its symbols instead of libcurl-impersonate
Is it possible to use the libcurl soname so it will work for every situation without requiring to tweak with patchelf ?
is there any way to suppress this kind of error?
When using libcurl-impersonate.so (not sure which one to use, there is .so, .so.4, .so.4.7.0) compiled and replaced, curl will show an error with version not available. I'm not sure if I did something wrong ? I compiled it using the docker instructions.