forked from osmocom/wireshark
Use dlget() and dlgetname() to get the executable path name on HP-UX.
That leaves only AIX (and, if we're looking at dead UN*Xes, IRIX and Tru64 UNIX) as platforms on which we can't fetch that. Change-Id: If7a6a425aba30e1abf82ecc66f6c28dc532a227c Reviewed-on: https://code.wireshark.org/review/27358 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
f447aa7dd7
commit
41445d0e97
|
@ -75,7 +75,15 @@ include(CheckSymbolExists)
|
|||
# Platform-specific functions used in platform-specific code.
|
||||
# We check for them only on the platform on which we use them.
|
||||
#
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
|
||||
#
|
||||
# HP-UX
|
||||
#
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
check_function_exists("dlget" HAVE_DLGET)
|
||||
cmake_pop_check_state()
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
|
||||
#
|
||||
# Solaris
|
||||
#
|
||||
|
|
|
@ -80,6 +80,12 @@
|
|||
/* Define if LIBSSH has ssh_userauth_agent() function */
|
||||
#cmakedefine HAVE_SSH_USERAUTH_AGENT 1
|
||||
|
||||
/* Define if you have the 'dlget' function. */
|
||||
#cmakedefine HAVE_DLGET 1
|
||||
|
||||
/* Define if you have the 'getexecname' function. */
|
||||
#cmakedefine HAVE_GETEXECNAME 1
|
||||
|
||||
/* Define if you have the 'floorl' function. */
|
||||
#cmakedefine HAVE_FLOORL 1
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_DLADDR
|
||||
#ifdef HAVE_DLGET
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#include <pwd.h>
|
||||
|
@ -416,8 +416,9 @@ get_executable_path(void)
|
|||
return NULL;
|
||||
executable_path[r] = '\0';
|
||||
return executable_path;
|
||||
#elif (defined(sun) || defined(__sun)) && defined(HAVE_GETEXECNAME)
|
||||
#elif defined(HAVE_GETEXECNAME)
|
||||
/*
|
||||
* Solaris, with getexecname().
|
||||
* It appears that getexecname() dates back to at least Solaris 8,
|
||||
* but /proc/{pid}/path is first documented in the Solaris 10 documentation,
|
||||
* so we use getexecname() if available, rather than /proc/self/path/a.out
|
||||
|
@ -425,6 +426,19 @@ get_executable_path(void)
|
|||
* executable image file).
|
||||
*/
|
||||
return getexecname();
|
||||
#elif defined(HAVE_DLGET)
|
||||
/*
|
||||
* HP-UX 11, with dlget(); use dlget() and dlgetname().
|
||||
* See
|
||||
*
|
||||
* https://web.archive.org/web/20081025174755/http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=88086d6e1de021106d6e1de02110275d6e10RCRD#two
|
||||
*/
|
||||
struct load_module_desc desc;
|
||||
|
||||
if (dlget(-2, &desc, sizeof(desc)) != NULL)
|
||||
return dlgetname(&desc, sizeof(desc), NULL, NULL, NULL);
|
||||
else
|
||||
return NULL;
|
||||
#else
|
||||
/* Fill in your favorite UN*X's code here, if there is something */
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue