From 6c68e92d38a3aeb7a4b05165efe55bd7918c4f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 13 Feb 2018 15:04:22 +0100 Subject: [PATCH] Add search for utempter helper This resolves Bug 2841 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit a14adb9ab9c50cbcd95a2d2e3f42c41fecf73fb0) --- CMakeLists.txt | 21 ++++++++++++++++++++- config.h.cmake | 1 + kdecore/kpty.cpp | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0789e6f..9f79200d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -578,7 +578,26 @@ endif( HAVE_LIBMAGIC ) if( WITH_UTEMPTER ) check_include_file( utempter.h HAVE_UTEMPTER_H ) check_library_exists( utempter addToUtmp "" HAVE_ADDTOUTEMP ) - if( HAVE_UTEMPTER_H AND HAVE_ADDTOUTEMP ) + if( NOT DEFINED UTEMPTER_HELPER ) + message( STATUS "Looking for utempter helper" ) + find_program( UTEMPTER_HELPER utempter + PATHS + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/utempter + /usr/lib/utempter + /usr/libexec/utempter + /usr/libexec + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/utempter + /usr/local/lib/utempter + /usr/local/libexec/utempter + /usr/local/libexec + ) + if( UTEMPTER_HELPER ) + message( STATUS "Looking for utempter helper - found" ) + else( ) + message( STATUS "Looking for utempter helper - not found" ) + endif( ) + endif( ) + if( HAVE_UTEMPTER_H AND HAVE_ADDTOUTEMP AND UTEMPTER_HELPER ) set( HAVE_UTEMPTER 1 ) set( UTEMPTER_LIBRARY utempter ) else( ) diff --git a/config.h.cmake b/config.h.cmake index bc2046175..56e28ba6a 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -702,6 +702,7 @@ /* Define if you have the utempter helper for utmp managment */ #cmakedefine HAVE_UTEMPTER 1 +#cmakedefine UTEMPTER_HELPER "@UTEMPTER_HELPER@" /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UTIL_H 1 diff --git a/kdecore/kpty.cpp b/kdecore/kpty.cpp index c0c7c9756..035ca530a 100644 --- a/kdecore/kpty.cpp +++ b/kdecore/kpty.cpp @@ -453,7 +453,7 @@ void KPty::login(const char *user, const char *remotehost) #ifdef HAVE_UTEMPTER KProcess_Utmp utmp; utmp.cmdFd = d->masterFd; - utmp << "/usr/lib/utempter/utempter" << "add"; + utmp << UTEMPTER_HELPER << "add"; if (remotehost) utmp << remotehost; utmp.start(KProcess::Block); @@ -498,7 +498,7 @@ void KPty::logout() #ifdef HAVE_UTEMPTER KProcess_Utmp utmp; utmp.cmdFd = d->masterFd; - utmp << "/usr/lib/utempter/utempter" << "del"; + utmp << UTEMPTER_HELPER << "del"; utmp.start(KProcess::Block); #elif defined(USE_LOGIN) const char *str_ptr = d->ttyName.data();