cmake: Avoid using absolute paths in dlopen() #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This encodes absolutes paths currently, via LIB_SSL which is detected in cmake and then passed to compiler via a define in src/server/CMakeLists.txt#L19
ADD_DEFINITIONS(-DSSL_LIB="${SSL_LIB}")
This define is then used by a dlopen() call in
src/server/shttpd/shttpd.c#L1514
if ((lib = dlopen(SSL_LIB, RTLD_LAZY)) == NULL) {
This ends up emitting absolute path into openwsmand binary
It breaks reproducible builds, especially in cross-build e.g. yocto, where build time install dir will never be same as runtime install dir, this absolute path will be
non-existent on targets and this call will fail.
Removing path element and leaving libssl.so which will/can be in /usr/lib on targets
This approach makes your binary more portable
since it doesn't hardcode absolute paths.