diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 739fe7c32b..563dc0da02 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -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 # diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index cba6e062e6..89913c881d 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -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 diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index e76e285414..4fa77ea21f 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -40,7 +40,7 @@ #include #include #endif -#ifdef HAVE_DLADDR +#ifdef HAVE_DLGET #include #endif #include @@ -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;