diff options
author | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2020-02-03 09:59:28 +0300 |
---|---|---|
committer | Andrejs Kozlovs <andrejs.kozlovs@zabbix.com> | 2020-02-03 10:32:10 +0300 |
commit | e1ea0dcb6d2c72795c32809660e70462bc6172de (patch) | |
tree | ad8715d0cb703ae6a3bfa4e8ab869e7090c773ae /m4 | |
parent | 3d1732850ae674c75446b5feaf1ea3cfba031320 (diff) |
.......PS. [ZBXNEXT-5690] added support for libssh
* commit '7d09dce2c8388419e3fd932b32e4303ad73f0bc8':
.......... [ZBXNEXT-5690] added jenkins build target
.......... [ZBXNEXT-5690] improved bytecount logging for ssh_run
.......PS. [ZBXNEXT-5690] code review rework
.......PS. [ZBXNEXT-5690] code review rework
.......PS. [ZBXNEXT-5690] minor coding guideline fixes & typos
.......PS. [ZBXNEXT-5690] fixes for keyboard-interactive authentification
.......PS. [ZBXNEXT-5690] remove debug code
.......PS. [ZBXNEXT-5690] added support for libssh
(cherry picked from commit 0cc954dbed790d5dcc90061c2d120b11338440a0)
(cherry picked from commit 369599a35fdca3204efde1073ec3ef45a667c5c1)
Diffstat (limited to 'm4')
-rw-r--r-- | m4/libssh.m4 | 142 | ||||
-rw-r--r-- | m4/libssh2.m4 | 2 |
2 files changed, 143 insertions, 1 deletions
diff --git a/m4/libssh.m4 b/m4/libssh.m4 new file mode 100644 index 00000000000..251893b32f8 --- /dev/null +++ b/m4/libssh.m4 @@ -0,0 +1,142 @@ +# LIBSSH_CHECK_CONFIG ([DEFAULT-ACTION]) +# ---------------------------------------------------------- +# Alexander Vladishev Oct-26-2009 +# Dmitry Borovikov Feb-13-2010 +# --version control added (1.0.0) +# +# Checks for ssh. DEFAULT-ACTION is the string yes or no to +# specify whether to default to --with-ssh or --without-ssh. +# If not supplied, DEFAULT-ACTION is no. +# +# The minimal supported SSH library version is 0.6.0. +# +# This macro #defines HAVE_SSH if a required header files are +# found, and sets @SSH_LDFLAGS@, @SSH_CFLAGS@ and @SSH_LIBS@ +# to the necessary values. +# +# Users may override the detected values by doing something like: +# SSH_LIBS="-lssh" SSH_CFLAGS="-I/usr/myinclude" ./configure +# +# This macro is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +AC_DEFUN([LIBSSH_TRY_LINK], +[ +AC_TRY_LINK( +[ +#include <libssh/libssh.h> +], +[ + ssh_session my_ssh_session; + my_ssh_session = ssh_new(); +], +found_ssh="yes",) +])dnl + +AC_DEFUN([LIBSSH_ACCEPT_VERSION], +[ + # Zabbix minimal major supported version of libssh: + minimal_libssh_major_version=0 + minimal_libssh_minor_version=6 + + # get the major version + found_ssh_version_major=`cat $1 | $EGREP \#define.*'LIBSSH_VERSION_MAJOR ' | $AWK '{print @S|@3;}'` + found_ssh_version_minor=`cat $1 | $EGREP \#define.*'LIBSSH_VERSION_MINOR ' | $AWK '{print @S|@3;}'` + + if test $((found_ssh_version_major)) -gt $((minimal_libssh_major_version)); then + accept_ssh_version="yes" + elif test $((found_ssh_version_major)) -lt $((minimal_libssh_major_version)); then + accept_ssh_version="no" + elif test $((found_ssh_version_minor)) -ge $((minimal_libssh_minor_version)); then + accept_ssh_version="yes" + else + accept_ssh_version="no" + fi; +])dnl + +AC_DEFUN([LIBSSH_CHECK_CONFIG], +[ + AC_ARG_WITH(ssh,[ +If you want to use SSH based checks: +AC_HELP_STRING([--with-ssh@<:@=DIR@:>@],[use SSH package @<:@default=no@:>@, DIR is the SSH library install directory.])], + [ + if test "$withval" = "no"; then + want_ssh="no" + _libssh_dir="no" + elif test "$withval" = "yes"; then + want_ssh="yes" + _libssh_dir="no" + else + want_ssh="yes" + _libssh_dir=$withval + fi + accept_ssh_version="no" + ],[want_ssh=ifelse([$1],,[no],[$1])] + ) + + if test "x$want_ssh" = "xyes"; then + AC_MSG_CHECKING(for SSH support) + if test "x$_libssh_dir" = "xno"; then + if test -f /usr/include/libssh/libssh.h; then + SSH_CFLAGS=-I/usr/include + SSH_LDFLAGS=-L/usr/lib + SSH_LIBS="-lssh" + found_ssh="yes" + LIBSSH_ACCEPT_VERSION([/usr/include/libssh/libssh.h]) + elif test -f /usr/local/include/libssh/libssh.h; then + SSH_CFLAGS=-I/usr/local/include + SSH_LDFLAGS=-L/usr/local/lib + SSH_LIBS="-lssh" + found_ssh="yes" + LIBSSH_ACCEPT_VERSION([/usr/local/include/libssh/libssh.h]) + else #libraries are not found in default directories + found_ssh="no" + AC_MSG_RESULT(no) + fi # test -f /usr/include/libssh/libssh.h; then + else # test "x$_libssh_dir" = "xno"; then + if test -f $_libssh_dir/include/libssh/libssh.h; then + SSH_CFLAGS=-I$_libssh_dir/include + SSH_LDFLAGS=-L$_libssh_dir/lib + SSH_LIBS="-lssh" + found_ssh="yes" + LIBSSH_ACCEPT_VERSION([$_libssh_dir/include/libssh/libssh.h]) + else #if test -f $_libssh_dir/include/libssh/libssh.h; then + found_ssh="no" + AC_MSG_RESULT(no) + fi #test -f $_libssh_dir/include/libssh/libssh.h; then + fi #if test "x$_libssh_dir" = "xno"; then + fi # if test "x$want_ssh" != "xno"; then + + if test "x$found_ssh" = "xyes"; then + am_save_cflags="$CFLAGS" + am_save_ldflags="$LDFLAGS" + am_save_libs="$LIBS" + + CFLAGS="$CFLAGS $SSH_CFLAGS" + LDFLAGS="$LDFLAGS $SSH_LDFLAGS" + LIBS="$LIBS $SSH_LIBS" + + found_ssh="no" + LIBSSH_TRY_LINK([no]) + + CFLAGS="$am_save_cflags" + LDFLAGS="$am_save_ldflags" + LIBS="$am_save_libs" + + if test "x$found_ssh" = "xyes"; then + AC_DEFINE([HAVE_SSH], 1, [Define to 1 if you have the 'libssh' library (-lssh)]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + SSH_CFLAGS="" + SSH_LDFLAGS="" + SSH_LIBS="" + fi + fi + + AC_SUBST(SSH_CFLAGS) + AC_SUBST(SSH_LDFLAGS) + AC_SUBST(SSH_LIBS) + +])dnl diff --git a/m4/libssh2.m4 b/m4/libssh2.m4 index 7e93551fb71..6d92a0c95d0 100644 --- a/m4/libssh2.m4 +++ b/m4/libssh2.m4 @@ -15,7 +15,7 @@ # to the necessary values. # # Users may override the detected values by doing something like: -# SSH2_LIBS="-lssh2" SSH_CFLAGS="-I/usr/myinclude" ./configure +# SSH2_LIBS="-lssh2" SSH2_CFLAGS="-I/usr/myinclude" ./configure # # This macro is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of |