mirror of
https://github.com/openwrt/packages.git
synced 2026-10-14 14:17:12 +04:00
netopeer2: update to 2.8.7
Requires the libyang 5.x / libnetconf2 4.x / sysrepo 5.x stack the previous commits introduce, so DEPENDS moves back to +libyang and the legacy staging prefix override is dropped. Rewrite the three uci-defaults scripts against 2.8.x: modules now come from both netopeer2 and libnetconf2, sysrepoctl lost -a, and the keystore and netconf-server models changed. Add test.sh and a test-version.sh override for the version-flag-less cli. Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
This commit is contained in:
1 parent
b9191b85ee
commit
f1603ffa9d
6 files changed
+167
-178
No files matched your search
@@ -10,12 +10,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=netopeer2
|
||||
PKG_VERSION:=2.4.5
|
||||
PKG_VERSION:=2.8.7
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/CESNET/Netopeer2/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=63d42493752062e7dfb3d3aca9c4157f49298401bdc5cd5166975f2cbc5f6f1b
|
||||
PKG_HASH:=15fc71bc79e0dd69d741b1c396615260971cf418029183456ece55ae68b4897f
|
||||
|
||||
PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
@@ -29,7 +29,7 @@ define Package/netopeer2-server
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=NETCONF server
|
||||
URL:=https://github.com/CESNET/Netopeer2
|
||||
DEPENDS:=+libcurl +libpthread +libyang-legacy +libnetconf2 +libsysrepo +sysrepocfg +sysrepoctl +sysrepo
|
||||
DEPENDS:=+libcurl +libpthread +libyang +libnetconf2 +libsysrepo +sysrepocfg +sysrepoctl +sysrepo
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
@@ -38,7 +38,7 @@ define Package/netopeer2-cli
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Netopeer2 cli tool
|
||||
URL:=https://github.com/CESNET/Netopeer2
|
||||
DEPENDS:=+libpthread +libyang-legacy +libnetconf2 +libopenssl
|
||||
DEPENDS:=+libpthread +libyang +libnetconf2 +libopenssl
|
||||
endef
|
||||
|
||||
define Package/netopeer2/description
|
||||
@@ -51,8 +51,7 @@ endef
|
||||
CMAKE_OPTIONS += \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
|
||||
-DCMAKE_BUILD_TYPE:STRING=Release \
|
||||
-DSYSREPO_SETUP:BOOL=OFF \
|
||||
-DCMAKE_PREFIX_PATH=$(STAGING_DIR)/usr/lib/libyang-legacy
|
||||
-DSYSREPO_SETUP:BOOL=OFF
|
||||
|
||||
define Package/netopeer2-server/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
|
||||
@@ -2,56 +2,49 @@
|
||||
|
||||
set -e
|
||||
|
||||
# avoid problems with sudo path
|
||||
SYSREPOCFG=`which sysrepocfg`
|
||||
KS_KEY_NAME=genkey
|
||||
SYSREPOCFG=$(which sysrepocfg)
|
||||
|
||||
# check that there is no listen/Call Home configuration yet
|
||||
SERVER_CONFIG=`$SYSREPOCFG -X -x "/ietf-netconf-server:netconf-server/listen/endpoint[1]/name | /ietf-netconf-server:netconf-server/call-home/netconf-client[1]/name"`
|
||||
if [ -z "$SERVER_CONFIG" ]; then
|
||||
SERVER_CONFIG=$($SYSREPOCFG -X -x "/ietf-netconf-server:netconf-server/listen/endpoints/endpoint | /ietf-netconf-server:netconf-server/call-home/netconf-client")
|
||||
if [ -n "$SERVER_CONFIG" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# import default config
|
||||
CONFIG="<netconf-server xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-server\">
|
||||
<listen>
|
||||
<endpoint>
|
||||
<name>default-ssh</name>
|
||||
<ssh>
|
||||
<tcp-server-parameters>
|
||||
<local-address>::</local-address>
|
||||
<keepalives>
|
||||
<idle-time>1</idle-time>
|
||||
<max-probes>10</max-probes>
|
||||
<probe-interval>5</probe-interval>
|
||||
</keepalives>
|
||||
</tcp-server-parameters>
|
||||
<ssh-server-parameters>
|
||||
<server-identity>
|
||||
<host-key>
|
||||
<name>default-key</name>
|
||||
<public-key>
|
||||
<keystore-reference>$KS_KEY_NAME</keystore-reference>
|
||||
</public-key>
|
||||
</host-key>
|
||||
</server-identity>
|
||||
<client-authentication>
|
||||
<supported-authentication-methods>
|
||||
<publickey/>
|
||||
<passsword/>
|
||||
<other>interactive</other>
|
||||
</supported-authentication-methods>
|
||||
<users/>
|
||||
</client-authentication>
|
||||
</ssh-server-parameters>
|
||||
</ssh>
|
||||
</endpoint>
|
||||
<endpoints>
|
||||
<endpoint>
|
||||
<name>default-ssh</name>
|
||||
<ssh>
|
||||
<tcp-server-parameters>
|
||||
<local-bind>
|
||||
<local-address>::</local-address>
|
||||
</local-bind>
|
||||
</tcp-server-parameters>
|
||||
<ssh-server-parameters>
|
||||
<server-identity>
|
||||
<host-key>
|
||||
<name>default-key</name>
|
||||
<public-key>
|
||||
<central-keystore-reference>genkey</central-keystore-reference>
|
||||
</public-key>
|
||||
</host-key>
|
||||
</server-identity>
|
||||
<client-authentication>
|
||||
<users>
|
||||
<user>
|
||||
<name>root</name>
|
||||
<keyboard-interactive xmlns=\"urn:cesnet:libnetconf2-netconf-server\">
|
||||
<use-system-auth/>
|
||||
</keyboard-interactive>
|
||||
</user>
|
||||
</users>
|
||||
</client-authentication>
|
||||
</ssh-server-parameters>
|
||||
</ssh>
|
||||
</endpoint>
|
||||
</endpoints>
|
||||
</listen>
|
||||
</netconf-server>"
|
||||
TMPFILE=`mktemp -u`
|
||||
printf -- "$CONFIG" > $TMPFILE
|
||||
# apply it to startup and running
|
||||
$SYSREPOCFG --edit=$TMPFILE -d startup -f xml -m ietf-netconf-server -v2
|
||||
$SYSREPOCFG -C startup -m ietf-netconf-server -v2
|
||||
# remove the tmp file
|
||||
rm $TMPFILE
|
||||
|
||||
fi
|
||||
echo "$CONFIG" | $SYSREPOCFG --edit -d startup -f xml -m ietf-netconf-server -v2
|
||||
$SYSREPOCFG -C startup -m ietf-netconf-server -v2
|
||||
@@ -2,46 +2,36 @@
|
||||
|
||||
set -e
|
||||
|
||||
# avoid problems with sudo path
|
||||
SYSREPOCFG=`which sysrepocfg`
|
||||
OPENSSL=`which openssl`
|
||||
SYSREPOCFG=$(which sysrepocfg)
|
||||
OPENSSL=$(which openssl)
|
||||
|
||||
# check that there is no SSH key with this name yet
|
||||
KEYSTORE_KEY=`$SYSREPOCFG -X -x "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='genkey']/name"`
|
||||
if [ -z "$KEYSTORE_KEY" ]; then
|
||||
KEYSTORE_KEY=$($SYSREPOCFG -X -x "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='genkey']")
|
||||
if [ -n "$KEYSTORE_KEY" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# generate a new key
|
||||
PRIVPEM=`$OPENSSL genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -outform PEM 2>/dev/null`
|
||||
# remove header/footer
|
||||
PRIVKEY=`grep -v -- "-----" - <<STDIN
|
||||
$PRIVPEM
|
||||
STDIN`
|
||||
# get public key
|
||||
PUBPEM=`$OPENSSL rsa -pubout 2>/dev/null <<STDIN
|
||||
$PRIVPEM
|
||||
STDIN`
|
||||
# remove header/footer
|
||||
PUBKEY=`grep -v -- "-----" - <<STDIN
|
||||
$PUBPEM
|
||||
STDIN`
|
||||
OLD_UMASK=$(umask)
|
||||
umask 077
|
||||
PRIVPEM=$($OPENSSL genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -outform PEM 2>/dev/null)
|
||||
umask "$OLD_UMASK"
|
||||
|
||||
if [ -z "$PRIVPEM" ]; then
|
||||
echo "Failed to generate RSA key with openssl." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PRIVKEY=$(echo "$PRIVPEM" | grep -v -- "-----" | tr -d "\n")
|
||||
|
||||
# generate edit config
|
||||
CONFIG="<keystore xmlns=\"urn:ietf:params:xml:ns:yang:ietf-keystore\">
|
||||
<asymmetric-keys>
|
||||
<asymmetric-key>
|
||||
<name>genkey</name>
|
||||
<algorithm>rsa2048</algorithm>
|
||||
<public-key>$PUBKEY</public-key>
|
||||
<private-key>$PRIVKEY</private-key>
|
||||
<public-key-format xmlns:ct=\"urn:ietf:params:xml:ns:yang:ietf-crypto-types\">ct:ssh-public-key-format</public-key-format>
|
||||
<private-key-format xmlns:ct=\"urn:ietf:params:xml:ns:yang:ietf-crypto-types\">ct:rsa-private-key-format</private-key-format>
|
||||
<cleartext-private-key>${PRIVKEY}</cleartext-private-key>
|
||||
</asymmetric-key>
|
||||
</asymmetric-keys>
|
||||
</keystore>"
|
||||
TMPFILE=`mktemp -u`
|
||||
printf -- "$CONFIG" > $TMPFILE
|
||||
# apply it to startup and running
|
||||
$SYSREPOCFG --edit=$TMPFILE -d startup -f xml -m ietf-keystore -v2
|
||||
$SYSREPOCFG -C startup -m ietf-keystore -v2
|
||||
# remove the tmp file
|
||||
rm $TMPFILE
|
||||
|
||||
fi
|
||||
echo "$CONFIG" | $SYSREPOCFG --edit -d startup -f xml -m ietf-keystore -v2
|
||||
$SYSREPOCFG -C startup -m ietf-keystore -v2
|
||||
@@ -2,105 +2,80 @@
|
||||
|
||||
# Warning, problems can occur if the device restarts in the middle of this uci-default script
|
||||
|
||||
# install YANG modules
|
||||
SYSREPOCTL=`which sysrepoctl`
|
||||
MODDIR="/etc/netopeer2/modules"
|
||||
SYSREPOCTL=$(which sysrepoctl)
|
||||
PERMS=600
|
||||
OWNER=root
|
||||
GROUP=root
|
||||
|
||||
# array of modules to install
|
||||
MODULES="\
|
||||
ietf-netconf-acm@2018-02-14.yang
|
||||
ietf-netconf@2013-09-29.yang -e writable-running -e candidate -e rollback-on-error -e validate -e startup -e url -e xpath
|
||||
ietf-netconf-monitoring@2010-10-04.yang
|
||||
ietf-netconf-nmda@2019-01-07.yang -e origin -e with-defaults
|
||||
nc-notifications@2008-07-14.yang
|
||||
notifications@2008-07-14.yang
|
||||
NP2_MODDIR=/etc/netopeer2/modules
|
||||
LN2_MODDIR=/etc/netconf2/modules
|
||||
|
||||
LN2_MODULES="iana-ssh-encryption-algs@2024-10-16.yang
|
||||
iana-ssh-key-exchange-algs@2024-10-16.yang
|
||||
iana-ssh-mac-algs@2024-10-16.yang
|
||||
iana-ssh-public-key-algs@2024-10-16.yang
|
||||
iana-tls-cipher-suite-algs@2024-10-16.yang
|
||||
ietf-x509-cert-to-name@2014-12-10.yang
|
||||
ietf-crypto-types@2019-07-02.yang
|
||||
ietf-keystore@2019-07-02.yang -e keystore-supported
|
||||
ietf-truststore@2019-07-02.yang -e truststore-supported -e x509-certificates
|
||||
ietf-tcp-common@2019-07-02.yang -e keepalives-supported
|
||||
ietf-ssh-server@2019-07-02.yang -e local-client-auth-supported
|
||||
ietf-tls-server@2019-07-02.yang -e local-client-auth-supported
|
||||
ietf-netconf-server@2019-07-02.yang -e ssh-listen -e tls-listen -e ssh-call-home -e tls-call-home"
|
||||
iana-crypt-hash@2014-04-04.yang -e crypt-hash-md5 -e crypt-hash-sha-256 -e crypt-hash-sha-512
|
||||
ietf-crypto-types@2024-10-10.yang -e cleartext-passwords -e cleartext-private-keys
|
||||
ietf-keystore@2024-10-10.yang -e central-keystore-supported -e inline-definitions-supported -e asymmetric-keys
|
||||
ietf-truststore@2024-10-10.yang -e central-truststore-supported -e inline-definitions-supported -e certificates -e public-keys
|
||||
ietf-tcp-common@2024-10-10.yang -e keepalives-supported
|
||||
ietf-tcp-server@2024-10-10.yang -e tcp-server-keepalives
|
||||
ietf-tcp-client@2024-10-10.yang -e local-binding-supported -e tcp-client-keepalives
|
||||
ietf-ssh-common@2024-10-10.yang -e algorithm-discovery -e transport-params
|
||||
ietf-ssh-server@2024-10-10.yang -e local-users-supported -e local-user-auth-publickey -e local-user-auth-password -e local-user-auth-none
|
||||
ietf-tls-common@2024-10-10.yang -e algorithm-discovery -e tls12 -e tls13 -e hello-params
|
||||
ietf-tls-server@2024-10-10.yang -e server-ident-x509-cert -e client-auth-supported -e client-auth-x509-cert
|
||||
ietf-netconf-server@2025-04-24.yang -e ssh-listen -e tls-listen -e ssh-call-home -e tls-call-home -e central-netconf-server-supported
|
||||
libnetconf2-netconf-server@2026-04-17.yang"
|
||||
|
||||
# functions
|
||||
INSTALL_MODULE() {
|
||||
local module=`echo "$1" | sed 's/\s.*$//'`
|
||||
$SYSREPOCTL -a -i $MODDIR/$module -s $MODDIR -p $PERMS -o $OWNER -g $GROUP -v2
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
exit $rc
|
||||
fi
|
||||
NP2_MODULES="ietf-interfaces@2018-02-20.yang
|
||||
ietf-ip@2018-02-22.yang
|
||||
ietf-netconf@2013-09-29.yang -e writable-running -e candidate -e rollback-on-error -e validate -e startup -e url -e xpath -e confirmed-commit
|
||||
ietf-netconf-nmda@2019-01-07.yang -e origin -e with-defaults
|
||||
notifications@2008-07-14.yang
|
||||
nc-notifications@2008-07-14.yang
|
||||
ietf-netconf-monitoring@2010-10-04.yang
|
||||
ietf-network-instance@2019-01-21.yang
|
||||
ietf-subscribed-notifications@2019-09-09.yang -e encode-xml -e replay -e subtree -e xpath
|
||||
ietf-yang-push@2019-09-09.yang -e on-change
|
||||
netopeer-notifications@2026-01-05.yang
|
||||
ietf-system-capabilities@2022-02-17.yang
|
||||
ietf-notification-capabilities@2022-02-17.yang
|
||||
ietf-netconf-private-candidate@2026-02-03.yang -e private-candidate"
|
||||
|
||||
SCTL_MODULES=$($SYSREPOCTL -l)
|
||||
|
||||
setup_modules() {
|
||||
_dir=$1
|
||||
_list=/tmp/netopeer2-modules.$$
|
||||
printf '%s\n' "$2" > "$_list"
|
||||
|
||||
while read -r _file _features; do
|
||||
[ -n "$_file" ] || continue
|
||||
_name=${_file%%@*}
|
||||
|
||||
if echo "$SCTL_MODULES" | grep -q "^$_name \+|[^|]*| I"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! $SYSREPOCTL -i "$_dir/$_file" -s "$_dir" -p $PERMS -v2; then
|
||||
rm -f "$_list"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for _feature in $_features; do
|
||||
[ "$_feature" = "-e" ] && continue
|
||||
if ! $SYSREPOCTL -c "$_name" -e "$_feature" -v2; then
|
||||
rm -f "$_list"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done < "$_list"
|
||||
|
||||
rm -f "$_list"
|
||||
}
|
||||
|
||||
UPDATE_MODULE() {
|
||||
$SYSREPOCTL -a -U $MODDIR/$1 -s $MODDIR -p $PERMS -o $OWNER -g $GROUP -v2
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
|
||||
ENABLE_FEATURE() {
|
||||
$SYSREPOCTL -a -c $1 -e $2 -v2
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
|
||||
ENABLE_FEATURES() {
|
||||
# parse sysrepoctl features and add extra space at the end for easier matching
|
||||
local sctl_features="`echo "$SCTL_MODULE" | sed 's/\([^|]*|\)\{6\}\(.*\)/\2/'` "
|
||||
# parse features we want to enable
|
||||
local features=`echo "$1" | sed 's/[^ ]* \(.*\)/\1/'`
|
||||
while [ "${features:0:3}" = "-e " ]; do
|
||||
# skip "-e "
|
||||
features=${features:3}
|
||||
# parse feature
|
||||
local feature=`echo "$features" | sed 's/\([^[:space:]]*\).*/\1/'`
|
||||
|
||||
# enable feature if not already
|
||||
sctl_feature=`echo "$sctl_features" | grep " ${feature} "`
|
||||
if [ -z "$sctl_feature" ]; then
|
||||
# enable feature
|
||||
ENABLE_FEATURE $name $feature
|
||||
fi
|
||||
|
||||
# next iteration, skip this feature
|
||||
features=`echo "$features" | sed 's/[^[:space:]]* \(.*\)/\1/'`
|
||||
done
|
||||
}
|
||||
|
||||
# get current modules
|
||||
SCTL_MODULES=`$SYSREPOCTL -l`
|
||||
|
||||
IFS=$'\n'
|
||||
for i in $MODULES; do
|
||||
name=`echo "$i" | sed 's/\([^@]*\).*/\1/'`
|
||||
|
||||
SCTL_MODULE=`echo "$SCTL_MODULES" | grep "^$name \+|[^|]*| I"`
|
||||
if [ -z "$SCTL_MODULE" ]; then
|
||||
# install module
|
||||
INSTALL_MODULE "$i"
|
||||
ENABLE_FEATURES "$i"
|
||||
continue
|
||||
fi
|
||||
|
||||
sctl_revision=`echo "$SCTL_MODULE" | sed 's/[^|]*| \([^ ]*\).*/\1/'`
|
||||
revision=`echo "$i" | sed 's/[^@]*@\([^\.]*\).*/\1/'`
|
||||
if [ "$sctl_revision" \< "$revision" ]; then
|
||||
# update module without any features
|
||||
file=`echo "$i" | cut -d' ' -f 1`
|
||||
UPDATE_MODULE $file
|
||||
fi
|
||||
|
||||
ENABLE_FEATURES "$i"
|
||||
done
|
||||
|
||||
unset IFS
|
||||
setup_modules "$LN2_MODDIR" "$LN2_MODULES"
|
||||
setup_modules "$NP2_MODDIR" "$NP2_MODULES"
|
||||
|
||||
exit 0
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# shellcheck shell=busybox
|
||||
|
||||
# netopeer2-cli has no -V flag; test.sh covers both subpackages.
|
||||
case "$PKG_NAME" in
|
||||
netopeer2-server|netopeer2-cli)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Untested package: $PKG_NAME" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
netopeer2-server)
|
||||
netopeer2-server -V | grep -F "$2"
|
||||
;;
|
||||
netopeer2-cli)
|
||||
# Interactive shell, no -V flag; only presence can be checked.
|
||||
[ -x /usr/bin/netopeer2-cli ] || {
|
||||
echo "netopeer2-cli not found" >&2
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported test target: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user