From d6d9b56bb9c96eb15329b5530b41e742cef04dde Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Mon, 11 Mar 2019 15:56:06 +0100 Subject: [PATCH] cmake,options: Allow to set global bind config file This allows the global bind configuration file path to be set in configuration time by defining the GLOBAL_BIND_CONFIG when calling cmake. If no value is defined, the default path is set as "/etc/ssh/libssh_server_config". usage example: $ cmake -DGLOBAL_BIND_CONFIG=/etc/my/custom/path .. Signed-off-by: Anderson Toshiyuki Sasaki Reviewed-by: Andreas Schneider --- CMakeLists.txt | 3 +++ DefineOptions.cmake | 4 ++++ config.h.cmake | 3 +++ src/options.c | 3 +-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbd7d771..6bffbc6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,5 +243,8 @@ message(STATUS "Benchmarks: ${WITH_BENCHMARKS}") message(STATUS "Symbol versioning: ${WITH_SYMBOL_VERSIONING}") message(STATUS "Allow ABI break: ${WITH_ABI_BREAK}") message(STATUS "Release is final: ${WITH_FINAL}") +if (WITH_SERVER) +message(STATUS "Global bind config: ${GLOBAL_BIND_CONFIG}") +endif() message(STATUS "********************************************") diff --git a/DefineOptions.cmake b/DefineOptions.cmake index 84ccd96d..5af58977 100644 --- a/DefineOptions.cmake +++ b/DefineOptions.cmake @@ -49,3 +49,7 @@ endif (WITH_NACL) if (WITH_ABI_BREAK) set(WITH_SYMBOL_VERSIONING ON) endif (WITH_ABI_BREAK) + +if (NOT GLOBAL_BIND_CONFIG) + set(GLOBAL_BIND_CONFIG "/etc/ssh/libssh_server_config") +endif (NOT GLOBAL_BIND_CONFIG) diff --git a/config.h.cmake b/config.h.cmake index 918ad437..404c0168 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -12,6 +12,9 @@ #cmakedefine BINARYDIR "${BINARYDIR}" #cmakedefine SOURCEDIR "${SOURCEDIR}" +/* Global bind configuration file path */ +#cmakedefine GLOBAL_BIND_CONFIG "${GLOBAL_BIND_CONFIG}" + /************************** HEADER FILES *************************/ /* Define to 1 if you have the header file. */ diff --git a/src/options.c b/src/options.c index fda73d62..a5e0f31a 100644 --- a/src/options.c +++ b/src/options.c @@ -2018,8 +2018,7 @@ int ssh_bind_options_parse_config(ssh_bind sshbind, const char *filename) /* If the global default configuration hasn't been processed yet, process it * before the provided configuration. */ if (!(sshbind->config_processed)) { - rc = ssh_bind_config_parse_file(sshbind, - "/etc/ssh/libssh_server_config"); + rc = ssh_bind_config_parse_file(sshbind, GLOBAL_BIND_CONFIG); if (rc != 0) { return rc; }