mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: drop support for libutil with mismatching utmp/utmpx struct
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
502fefe674
commit
c1caca5927
4 changed files with 45 additions and 36 deletions
|
@ -13,6 +13,7 @@ include(CheckTypeSize)
|
|||
include(CheckStructHasMember)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckPrototypeDefinition)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
# The FindKDE4.cmake module sets _KDE4_PLATFORM_DEFINITIONS with
|
||||
# definitions like _GNU_SOURCE that are needed on each platform.
|
||||
|
@ -81,11 +82,8 @@ check_library_exists(nsl gethostbyname "" HAVE_NSL_LIBRARY)
|
|||
check_library_exists(socket connect "" HAVE_SOCKET_LIBRARY)
|
||||
|
||||
if (UNIX)
|
||||
|
||||
# for kpty
|
||||
|
||||
check_include_files("sys/types.h;libutil.h" HAVE_LIBUTIL_H)
|
||||
check_include_files(util.h HAVE_UTIL_H)
|
||||
check_include_files(termio.h HAVE_TERMIO_H)
|
||||
check_include_files(pty.h HAVE_PTY_H)
|
||||
check_include_files(sys/stropts.h HAVE_SYS_STROPTS_H)
|
||||
|
@ -93,27 +91,29 @@ if (UNIX)
|
|||
|
||||
set(UTIL_LIBRARY)
|
||||
|
||||
check_function_exists(login login_in_libc)
|
||||
if (NOT login_in_libc)
|
||||
check_library_exists(util login "" login_in_libutil)
|
||||
if (login_in_libutil)
|
||||
set(UTIL_LIBRARY util)
|
||||
endif (login_in_libutil)
|
||||
endif (NOT login_in_libc)
|
||||
check_function_exists(setutxent HAVE_UTMPX)
|
||||
check_symbol_exists(setutxent "utmpx.h" HAVE_UTMPX)
|
||||
if (HAVE_UTMPX)
|
||||
set(utmp utmpx)
|
||||
if (login_in_libutil)
|
||||
check_library_exists(util loginx "" HAVE_LOGINX)
|
||||
endif (login_in_libutil)
|
||||
else (HAVE_UTMPX)
|
||||
else ()
|
||||
set(utmp utmp)
|
||||
endif (HAVE_UTMPX)
|
||||
if (login_in_libc OR login_in_libutil)
|
||||
set(HAVE_LOGIN 1)
|
||||
else (login_in_libc OR login_in_libutil)
|
||||
set(HAVE_LOGIN)
|
||||
endif (login_in_libc OR login_in_libutil)
|
||||
endif ()
|
||||
|
||||
cmake_reset_check_state()
|
||||
set(CMAKE_REQUIRED_LIBRARIES "util")
|
||||
check_symbol_exists(loginx "util.h" HAVE_UTIL_LOGINX)
|
||||
cmake_reset_check_state()
|
||||
check_symbol_exists(login "${utmp}.h" HAVE_LOGIN)
|
||||
if (NOT HAVE_LOGIN)
|
||||
cmake_reset_check_state()
|
||||
set(CMAKE_REQUIRED_LIBRARIES "util")
|
||||
check_symbol_exists(login "util.h" HAVE_UTIL_LOGIN)
|
||||
cmake_reset_check_state()
|
||||
endif ()
|
||||
|
||||
if (HAVE_UTIL_LOGINX OR HAVE_UTIL_LOGIN)
|
||||
set(UTIL_LIBRARY "util")
|
||||
endif ()
|
||||
|
||||
check_struct_has_member("struct ${utmp}" "ut_user" "${utmp}.h" HAVE_STRUCT_UTMP_UT_USER)
|
||||
check_struct_has_member("struct ${utmp}" "ut_type" "${utmp}.h" HAVE_STRUCT_UTMP_UT_TYPE)
|
||||
check_struct_has_member("struct ${utmp}" "ut_pid" "${utmp}.h" HAVE_STRUCT_UTMP_UT_PID)
|
||||
|
@ -131,7 +131,7 @@ if (UNIX)
|
|||
if (openpty_in_libc OR openpty_in_libutil)
|
||||
set(HAVE_OPENPTY 1)
|
||||
else (openpty_in_libc OR openpty_in_libutil)
|
||||
set(HAVE_OPENPTY)
|
||||
set(HAVE_OPENPTY 0)
|
||||
|
||||
execute_process(
|
||||
COMMAND sh -c "
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* Defined to the path of the PTY multiplexer device, if any */
|
||||
#cmakedefine PTM_DEVICE "${PTM_DEVICE}"
|
||||
|
||||
#cmakedefine HAVE_LIBUTIL_H 1
|
||||
#cmakedefine HAVE_POSIX_OPENPT 1
|
||||
#cmakedefine HAVE_GRANTPT 1
|
||||
#cmakedefine HAVE_OPENPTY 1
|
||||
|
@ -10,16 +11,15 @@
|
|||
#cmakedefine HAVE_TCGETATTR
|
||||
#cmakedefine HAVE_TCSETATTR
|
||||
|
||||
#cmakedefine HAVE_LIBUTIL_H 1
|
||||
#cmakedefine HAVE_UTIL_H 1
|
||||
#cmakedefine HAVE_PTY_H 1
|
||||
#cmakedefine HAVE_TERMIO_H 1
|
||||
#cmakedefine HAVE_SYS_STROPTS_H 1
|
||||
#cmakedefine HAVE_SYS_FILIO_H 1
|
||||
|
||||
#cmakedefine HAVE_LOGIN 1
|
||||
#cmakedefine HAVE_UTMPX 1
|
||||
#cmakedefine HAVE_LOGINX 1
|
||||
#cmakedefine HAVE_UTIL_LOGINX 1
|
||||
#cmakedefine HAVE_LOGIN 1
|
||||
#cmakedefine HAVE_UTIL_LOGIN 1
|
||||
#cmakedefine HAVE_STRUCT_UTMP_UT_USER 1
|
||||
#cmakedefine HAVE_STRUCT_UTMP_UT_TYPE 1
|
||||
#cmakedefine HAVE_STRUCT_UTMP_UT_PID 1
|
||||
|
|
|
@ -44,7 +44,6 @@ install(
|
|||
|
||||
if(NOT HAVE_OPENPTY)
|
||||
add_executable(kgrantpty kgrantpty.c)
|
||||
# it needs only some fakes but they are part of kdecore now
|
||||
target_link_libraries(kgrantpty ${KDE4_KDECORE_LIBS})
|
||||
install(TARGETS kgrantpty DESTINATION ${LIBEXEC_INSTALL_DIR})
|
||||
endif()
|
||||
|
|
|
@ -45,12 +45,14 @@
|
|||
# include <pty.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBUTIL_H
|
||||
# include <libutil.h>
|
||||
#elif defined(HAVE_UTIL_H)
|
||||
#if defined(HAVE_UTIL_LOGINX) || defined(HAVE_UTIL_LOGIN)
|
||||
# include <util.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBUTIL_H)
|
||||
# include <libutil.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTMPX
|
||||
# include <utmpx.h>
|
||||
#else
|
||||
|
@ -491,7 +493,11 @@ void KPty::login(const char *user, const char *remotehost)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_UTMPX
|
||||
gettimeofday(&l_struct.ut_tv, 0);
|
||||
// due to binary hacks ut_tv members must be set explicitly
|
||||
struct timeval tod;
|
||||
gettimeofday(&tod, 0);
|
||||
l_struct.ut_tv.tv_sec = tod.tv_sec;
|
||||
l_struct.ut_tv.tv_usec = tod.tv_usec;
|
||||
#else
|
||||
l_struct.ut_time = time(0);
|
||||
#endif
|
||||
|
@ -509,9 +515,9 @@ void KPty::login(const char *user, const char *remotehost)
|
|||
l_struct.ut_session = getsid(0);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LOGINX)
|
||||
#if defined(HAVE_UTIL_LOGINX)
|
||||
::loginx(&l_struct);
|
||||
#elif defined(HAVE_LOGIN)
|
||||
#elif defined(HAVE_LOGIN) || defined(HAVE_UTIL_LOGIN)
|
||||
::login(&l_struct);
|
||||
#elif defined(HAVE_UTMPX)
|
||||
# ifdef _PATH_UTMPX
|
||||
|
@ -550,9 +556,9 @@ void KPty::logout()
|
|||
str_ptr = sl_ptr + 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_LOGINX)
|
||||
#if defined(HAVE_UTIL_LOGINX)
|
||||
::logoutx(str_ptr, 0, DEAD_PROCESS);
|
||||
#elif defined(HAVE_LOGIN)
|
||||
#elif defined(HAVE_LOGIN) || defined(HAVE_UTIL_LOGIN)
|
||||
::logout(str_ptr);
|
||||
#else
|
||||
# ifdef HAVE_UTMPX
|
||||
|
@ -590,7 +596,11 @@ void KPty::logout()
|
|||
ut->ut_type = DEAD_PROCESS;
|
||||
# endif
|
||||
# ifdef HAVE_UTMPX
|
||||
gettimeofday(&(ut->ut_tv), 0);
|
||||
// due to binary hacks ut_tv members must be set explicitly
|
||||
struct timeval tod;
|
||||
gettimeofday(&tod, 0);
|
||||
ut->ut_tv.tv_sec = tod.tv_sec;
|
||||
ut->ut_tv.tv_usec = tod.tv_usec;
|
||||
pututxline(ut);
|
||||
}
|
||||
endutxent();
|
||||
|
|
Loading…
Add table
Reference in a new issue