Add SSH_BIN compile-time option

Clarify documentation of internal netconf message struct
This commit is contained in:
Olof hagsand 2022-12-07 11:28:45 +01:00
parent 407860ccc7
commit 100f15b699
9 changed files with 67 additions and 9 deletions

48
configure vendored
View file

@ -623,6 +623,7 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
EGREP
GREP
SSH_BIN
LEXLIB
LEX_OUTPUT_ROOT
LEX
@ -4563,6 +4564,53 @@ if test "$LEX" = ":"; then
as_fn_error $? "CLIXON does not find lex or flex." "$LINENO" 5
fi
# SSH binary path
# Extract the first word of "ssh", so it can be a program name with args.
set dummy ssh; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_SSH_BIN+:} false; then :
$as_echo_n "(cached) " >&6
else
case $SSH_BIN in
[\\/]* | ?:[\\/]*)
ac_cv_path_SSH_BIN="$SSH_BIN" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_SSH_BIN="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
SSH_BIN=$ac_cv_path_SSH_BIN
if test -n "$SSH_BIN"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SSH_BIN" >&5
$as_echo "$SSH_BIN" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
cat >>confdefs.h <<_ACEOF
#define SSH_BIN $SSH_BIN
_ACEOF
# Get "bison" from bison -y or other string
if test "$YACC" = "${YACC##bison}" ; then
as_fn_error $? "CLIXON does not find bison. There are several problems with yacc and byacc. Please install bison. YACC=\"$YACC\"" "$LINENO" 5

View file

@ -147,6 +147,10 @@ if test "$LEX" = ":"; then
AC_MSG_ERROR(CLIXON does not find lex or flex.)
fi
# SSH binary path
AC_PATH_PROG(SSH_BIN, ssh)
AC_DEFINE_UNQUOTED(SSH_BIN, $SSH_BIN, [SSH binary])
# Get "bison" from bison -y or other string
if test "$YACC" = "${YACC##bison}" ; then
AC_MSG_ERROR(CLIXON does not find bison. There are several problems with yacc and byacc. Please install bison. YACC="$YACC")

View file

@ -47,7 +47,7 @@ As CLI:
```
As netconf via stdin/stdout:
```
$ sudo docker exec -it clixon-system clixon_netconf
$ sudo docker exec -it clixon-system clixon_netconf -f /usr/local/etc/example.xml
```
As restconf using curl on exposed port 80:
```

View file

@ -14,7 +14,6 @@
* [Docker](#docker)
* [Plugins](#plugins)
## Background
The aim of the main clixon example is to illustrate common

View file

@ -153,6 +153,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* SSH binary */
#undef SSH_BIN
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

View file

@ -53,7 +53,7 @@ enum format_enum{
/* Protocol message header */
struct clicon_msg {
uint32_t op_len; /* length of message. network byte order. */
uint32_t op_len; /* length of whole message: body+header, network byte order. */
uint32_t op_id; /* session-id. network byte order. */
char op_body[0]; /* rest of message, actual data */
};

View file

@ -96,3 +96,5 @@ YANG_STANDARD_DIR=@YANG_STANDARD_DIR@
YANG_INSTALLDIR=@YANG_INSTALLDIR@
MIB_GENERATED_YANG_DIR=@MIB_GENERATED_YANG_DIR@
SSH_BIN=@SSH_BIN@

View file

@ -4,8 +4,10 @@
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Skip it if no openssh
if ! [ -x "$(command -v ssh)" ]; then
ssh_bin=${SSH_BIN}
# Skip it if no ssh bin
if ! [ -x "$ssh_bin" ]; then
echo "...ssh not installed"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
@ -142,9 +144,9 @@ HashKnownHosts no
EOF
new "Start Listener client"
echo "ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand=\"clixon_netconf_ssh_callhome_client -a 127.0.0.1\" . netconf"
echo "${ssh_bin} -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand=\"clixon_netconf_ssh_callhome_client -a 127.0.0.1\" . netconf"
#-F $sshcfg
expectpart "$(ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 0 "<hello $DEFAULTONLY><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability>.*</capabilities><session-id>2</session-id></hello>" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
expectpart "$(${ssh_bin} -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 0 "<hello $DEFAULTONLY><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability>.*</capabilities><session-id>2</session-id></hello>" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"
# Wait
wait

View file

@ -8,7 +8,7 @@
# o explicit
# Clixon supports explicit, but the testcases define the other cases as well
# in case others will be supported
# XXX I dont think this is correct. Or at least it is not complete.
# See test_yang_with_default for full RFC6243 tests
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi