2021-03-07 02:40:21 +02:00
|
|
|
# Try to find the PAM libraries, once done this will define:
|
2015-11-05 10:05:41 +02:00
|
|
|
#
|
|
|
|
# PAM_FOUND - system has pam
|
|
|
|
# PAM_INCLUDE_DIR - the pam include directory
|
|
|
|
# PAM_LIBRARIES - libpam library
|
2021-02-20 00:22:04 +02:00
|
|
|
# PAM_MESSAGE_CONST - libpam pam_message struct is const
|
2021-02-24 10:17:46 +02:00
|
|
|
#
|
2021-03-07 02:40:21 +02:00
|
|
|
# Copyright (c) 2021 Ivailo Monev <xakepa10@gmail.com>
|
2021-02-24 10:17:46 +02:00
|
|
|
#
|
|
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
|
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
2015-11-05 10:05:41 +02:00
|
|
|
|
2021-02-24 10:17:46 +02:00
|
|
|
find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h)
|
2015-11-05 10:05:41 +02:00
|
|
|
find_library(PAM_LIBRARY pam)
|
|
|
|
find_library(DL_LIBRARY dl)
|
|
|
|
|
2021-02-24 10:17:46 +02:00
|
|
|
if(DL_LIBRARY)
|
|
|
|
set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY})
|
|
|
|
else()
|
|
|
|
set(PAM_LIBRARIES ${PAM_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED PAM_MESSAGE_CONST)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
include(CMakePushCheckState)
|
|
|
|
cmake_reset_check_state()
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${PAM_INCLUDE_DIR}")
|
|
|
|
# XXX does this work with plain c?
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
#include <security/pam_appl.h>
|
2015-11-05 10:05:41 +02:00
|
|
|
|
|
|
|
static int PAM_conv(
|
2021-02-20 00:22:04 +02:00
|
|
|
int num_msg,
|
|
|
|
const struct pam_message **msg, /* this is the culprit */
|
|
|
|
struct pam_response **resp,
|
|
|
|
void *ctx)
|
2015-11-05 10:05:41 +02:00
|
|
|
{
|
2021-02-20 00:22:04 +02:00
|
|
|
return 0;
|
2015-11-05 10:05:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2021-02-20 00:22:04 +02:00
|
|
|
struct pam_conv PAM_conversation = {
|
|
|
|
&PAM_conv, /* this bombs out if the above does not match */
|
|
|
|
0
|
|
|
|
};
|
2015-11-05 10:05:41 +02:00
|
|
|
|
2021-02-20 00:22:04 +02:00
|
|
|
return 0;
|
2015-11-05 10:05:41 +02:00
|
|
|
}
|
|
|
|
" PAM_MESSAGE_CONST)
|
2021-09-19 05:37:33 +03:00
|
|
|
cmake_reset_check_state()
|
2021-02-24 10:17:46 +02:00
|
|
|
endif()
|
|
|
|
set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message")
|
2015-11-05 10:05:41 +02:00
|
|
|
|
2021-02-24 10:17:46 +02:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(PAM
|
|
|
|
REQUIRED_VARS PAM_LIBRARIES PAM_INCLUDE_DIR
|
|
|
|
)
|
2015-11-05 10:05:41 +02:00
|
|
|
|
|
|
|
mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST)
|