Add an option to add the plugin and extension to rpath (#7425)

This commit is contained in:
akallabeth 2021-11-04 08:59:38 +01:00 committed by GitHub
parent 41d03143b8
commit 58b24f13fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 20 deletions

View File

@ -873,6 +873,7 @@ endif()
set(FREERDP_ADDIN_PATH "${FREERDP_PLUGIN_PATH}") set(FREERDP_ADDIN_PATH "${FREERDP_PLUGIN_PATH}")
# Path to put extensions # Path to put extensions
set(FREERDP_EXTENSION_REL_PATH "${CMAKE_INSTALL_LIBDIR}/freerdp${FREERDP_VERSION_MAJOR}/extensions")
set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp${FREERDP_VERSION_MAJOR}/extensions") set(FREERDP_EXTENSION_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/freerdp${FREERDP_VERSION_MAJOR}/extensions")
# Proxy plugins path # Proxy plugins path
@ -896,6 +897,10 @@ else (APPLE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (NOT FREEBSD) if (NOT FREEBSD)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..") set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..")
option(WITH_ADD_PLUGIN_TO_RPATH "Add extension and plugin path to RPATH" OFF)
if (WITH_ADD_PLUGIN_TO_RPATH)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${FREERDP_EXTENSION_REL_PATH}:\$ORIGIN/../${FREERDP_PLUGIN_PATH}:${CMAKE_INSTALL_RPATH}")
endif()
endif() endif()
endif(APPLE) endif(APPLE)

View File

@ -24,6 +24,7 @@
#cmakedefine AVRESAMPLE_FOUND #cmakedefine AVRESAMPLE_FOUND
/* Options */ /* Options */
#cmakedefine WITH_ADD_PLUGIN_TO_RPATH
#cmakedefine WITH_PROFILER #cmakedefine WITH_PROFILER
#cmakedefine WITH_GPROF #cmakedefine WITH_GPROF
#cmakedefine WITH_SSE2 #cmakedefine WITH_SSE2

View File

@ -992,7 +992,7 @@ static int test_MppcCompressBufferRdp5(void)
int rc = -1; int rc = -1;
int status; int status;
UINT32 Flags; UINT32 Flags;
BYTE* pSrcData; const BYTE* pSrcData;
UINT32 SrcSize; UINT32 SrcSize;
UINT32 DstSize; UINT32 DstSize;
BYTE* pDstData; BYTE* pDstData;
@ -1042,7 +1042,7 @@ static int test_MppcDecompressBufferRdp5(void)
int rc = -1; int rc = -1;
int status; int status;
UINT32 Flags; UINT32 Flags;
BYTE* pSrcData; const BYTE* pSrcData;
UINT32 SrcSize; UINT32 SrcSize;
UINT32 DstSize; UINT32 DstSize;
MPPC_CONTEXT* mppc; MPPC_CONTEXT* mppc;

View File

@ -90,6 +90,9 @@ LPSTR freerdp_get_library_install_path(void)
LPSTR freerdp_get_dynamic_addin_install_path(void) LPSTR freerdp_get_dynamic_addin_install_path(void)
{ {
#if defined(WITH_ADD_PLUGIN_TO_RPATH)
return NULL;
#else
LPSTR pszPath; LPSTR pszPath;
size_t cchPath; size_t cchPath;
size_t cchAddinPath; size_t cchAddinPath;
@ -131,6 +134,7 @@ LPSTR freerdp_get_dynamic_addin_install_path(void)
WLog_DBG(TAG, "freerdp_get_dynamic_addin_install_path -> pszPath: %s", pszPath); WLog_DBG(TAG, "freerdp_get_dynamic_addin_install_path -> pszPath: %s", pszPath);
return pszPath; return pszPath;
#endif
} }
PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, PVIRTUALCHANNELENTRY freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath,
@ -245,60 +249,74 @@ PVIRTUALCHANNELENTRY freerdp_load_dynamic_channel_addin_entry(LPCSTR pszName, LP
PVIRTUALCHANNELENTRY entry; PVIRTUALCHANNELENTRY entry;
LPSTR pszFileName; LPSTR pszFileName;
const size_t cchBaseFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32; const size_t cchBaseFileName = sizeof(FREERDP_SHARED_LIBRARY_PREFIX) + 32;
LPCSTR pszExtension;
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
size_t nameLen = 0; size_t nameLen = 0;
size_t subsystemLen = 0; size_t subsystemLen = 0;
size_t typeLen = 0; size_t typeLen = 0;
size_t extensionLen = 0; size_t cchFileName = 0;
pszExtension = PathGetSharedLibraryExtensionA(0);
if (pszName) if (pszName)
nameLen = strnlen(pszName, MAX_PATH); nameLen = strnlen(pszName, MAX_PATH);
if (pszSubsystem) if (pszSubsystem)
subsystemLen = strnlen(pszSubsystem, MAX_PATH); subsystemLen = strnlen(pszSubsystem, MAX_PATH);
if (pszType) if (pszType)
typeLen = strnlen(pszType, MAX_PATH); typeLen = strnlen(pszType, MAX_PATH);
if (pszExtension)
extensionLen = strnlen(pszExtension, MAX_PATH);
if (pszName && pszSubsystem && pszType) if (pszName && pszSubsystem && pszType)
{ {
const size_t cchFileName = cchFileName =
cchBaseFileName + nameLen + subsystemLen + typeLen + extensionLen; cchBaseFileName + nameLen + subsystemLen + typeLen;
pszFileName = (LPSTR)malloc(cchFileName); pszFileName = (LPSTR)malloc(cchFileName);
if (!pszFileName) if (!pszFileName)
return NULL; return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s-%s.%s", pszPrefix, pszName, sprintf_s(pszFileName, cchFileName, "%s-client-%s-%s", pszName,
pszSubsystem, pszType, pszExtension); pszSubsystem, pszType);
} }
else if (pszName && pszSubsystem) else if (pszName && pszSubsystem)
{ {
const size_t cchFileName = cchBaseFileName + nameLen + subsystemLen + extensionLen; cchFileName = cchBaseFileName + nameLen + subsystemLen;
pszFileName = (LPSTR)malloc(cchFileName); pszFileName = (LPSTR)malloc(cchFileName);
if (!pszFileName) if (!pszFileName)
return NULL; return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client-%s.%s", pszPrefix, pszName, pszSubsystem, sprintf_s(pszFileName, cchFileName, "%s-client-%s", pszName, pszSubsystem );
pszExtension);
} }
else if (pszName) else if (pszName)
{ {
const size_t cchFileName = cchBaseFileName + nameLen + extensionLen; cchFileName = cchBaseFileName + nameLen ;
pszFileName = (LPSTR)malloc(cchFileName); pszFileName = (LPSTR)malloc(cchFileName);
if (!pszFileName) if (!pszFileName)
return NULL; return NULL;
sprintf_s(pszFileName, cchFileName, "%s%s-client.%s", pszPrefix, pszName, pszExtension); sprintf_s(pszFileName, cchFileName, "%s-client", pszName);
} }
else else
{ {
return NULL; return NULL;
} }
{
LPCSTR pszExtension = PathGetSharedLibraryExtensionA(0);
LPCSTR pszPrefix = FREERDP_SHARED_LIBRARY_PREFIX;
LPSTR tmp;
int rc;
if (pszPrefix)
cchFileName += strnlen(pszPrefix, MAX_PATH);
if (pszExtension)
cchFileName += strnlen(pszExtension, MAX_PATH) + 1;
tmp = calloc(cchFileName, sizeof(CHAR));
if (tmp)
rc = sprintf_s(tmp, cchFileName, "%s%s.%s", pszPrefix, pszFileName, pszExtension);
free(pszFileName);
pszFileName = tmp;
if (!pszFileName)
return NULL;
}
if (pszSubsystem) if (pszSubsystem)
{ {
LPSTR pszEntryName; LPSTR pszEntryName;

View File

@ -453,7 +453,7 @@ static BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
if (redirection->flags & LB_TARGET_NET_ADDRESSES) if (redirection->flags & LB_TARGET_NET_ADDRESSES)
{ {
int i; size_t i;
UINT32 count; UINT32 count;
UINT32 targetNetAddressesLength; UINT32 targetNetAddressesLength;
@ -470,7 +470,7 @@ static BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s)
WLog_DBG(TAG, "TargetNetAddressesCount: %" PRIu32 "", redirection->TargetNetAddressesCount); WLog_DBG(TAG, "TargetNetAddressesCount: %" PRIu32 "", redirection->TargetNetAddressesCount);
for (i = 0; i < (int)count; i++) for (i = 0; i < count; i++)
{ {
if (!rdp_redirection_read_unicode_string(s, &(redirection->TargetNetAddresses[i]), 80)) if (!rdp_redirection_read_unicode_string(s, &(redirection->TargetNetAddresses[i]), 80))
return FALSE; return FALSE;

View File

@ -129,7 +129,8 @@ HMODULE LoadLibraryA(LPCSTR lpLibFileName)
if (!library) if (!library)
{ {
WLog_ERR(TAG, "%s failed with %s", __FUNCTION__, dlerror()); const char* err = dlerror();
WLog_ERR(TAG, "%s failed with %s", __FUNCTION__, err);
return NULL; return NULL;
} }