From e718abc23fe095d6c6f687086b1e0f0f532c23d1 Mon Sep 17 00:00:00 2001 From: Morgan Christiansson Date: Mon, 19 Jun 2023 19:34:48 +0200 Subject: [PATCH] ser2net: update to 4.5.0 (closes #21409) This major update not only updates the ser2net daemon version, but also migrates the UCI configuration handling to the newer YAML configuration file format. If you only configured ser2net using UCI, then there should be no noticable difference and your configuration should still work as before. If you modified /etc/ser2net.conf before, or used custom adaptions etc., then you must migrate to newer /etc/ser2net.yaml on your own and/or double-check your installation - there is no automatic migration logic during package upgrade path. Signed-off-by: Morgan Christiansson Signed-off-by: Michael Heimpold --- net/ser2net/Makefile | 10 +- net/ser2net/files/ser2net.conf | 70 ------ net/ser2net/files/ser2net.init | 218 +++++++++++------- net/ser2net/files/ser2net.yaml | 10 + .../patches/001-fix-disabling-pam.patch | 11 - 5 files changed, 149 insertions(+), 170 deletions(-) delete mode 100644 net/ser2net/files/ser2net.conf create mode 100644 net/ser2net/files/ser2net.yaml delete mode 100644 net/ser2net/patches/001-fix-disabling-pam.patch diff --git a/net/ser2net/Makefile b/net/ser2net/Makefile index d3723073ac..6c6058ed31 100644 --- a/net/ser2net/Makefile +++ b/net/ser2net/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ser2net -PKG_VERSION:=4.3.6 -PKG_RELEASE:=2 +PKG_VERSION:=4.5.0 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/ser2net -PKG_HASH:=65515c7e9a5289167ae64c4032450904449a87ce20653241022af4f5db2e9510 +PKG_HASH:=6ee1b217aad026948fd17ea00c5ecf6e982de822384c4349118461ad83caa0da PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE_FILES:=COPYING @@ -44,7 +44,7 @@ endef define Package/ser2net/conffiles /etc/config/ser2net -/etc/ser2net.conf +/etc/ser2net.yaml endef define Package/ser2net/install @@ -52,7 +52,7 @@ define Package/ser2net/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ser2net $(1)/usr/sbin/ $(INSTALL_DIR) $(1)/etc - $(INSTALL_CONF) ./files/ser2net.conf $(1)/etc/ + $(INSTALL_CONF) ./files/ser2net.yaml $(1)/etc/ $(INSTALL_DIR) $(1)/etc/config $(INSTALL_CONF) ./files/ser2net.config $(1)/etc/config/ser2net diff --git a/net/ser2net/files/ser2net.conf b/net/ser2net/files/ser2net.conf deleted file mode 100644 index 2c9605bb4f..0000000000 --- a/net/ser2net/files/ser2net.conf +++ /dev/null @@ -1,70 +0,0 @@ -# -# This is a minimal example configuration file for ser2net. For a version with -# detailed comments and all possible configuration directives, please visit: -# https://github.com/cminyard/ser2net/blob/master/ser2net.conf -# -# On OpenWrt/LEDE systems, this configuration serves as a base configuration. -# During boot of the system, the UCI configuration file /etc/config/ser2net is -# parsed and converted to additional configuration lines which are _appended_ -# to this file. The ser2net daemon is then started with the combined -# configuration file /tmp/ser2net.conf. -# -# A basic service configuration line has the following format: -# :::: -# network port -# Name or number of the port to accept connections -# from for this device. A port number may be of the form -# [ipv4,|ipv6,][tcp,|udp,][host,]port, such as -# 127.0.0.1,2000 or ipv4,tcp,localhost,2000. If the host is -# specified, it will only bind to the IP address -# specified. Otherwise it will bind to all the ports on the -# machine. If ipv4 or ipv6 is specified, it will only bind -# to that network type. -# -# state -# Either raw or rawlp or telnet or off. off disables -# the port from accepting connections. It can be -# turned on later from the control port. raw enables -# the port and transfers all data as-is between the -# port and the long. rawlp enables the port and -# transfers all input data to device, device is open -# without any termios setting. It allow to use -# /dev/lpX devices and printers connected to them. -# telnet enables the port and runs the telnet proto- -# col on the port to set up telnet parameters. This -# is most useful for using telnet. -# -# timeout -# The time (in seconds) before the port will be dis- -# connected if there is no activity on it. A zero -# value disables this function. -# -# device -# The name of the device to connect to. This -# must be in the form of /dev/. -# -# options -# Sets operational parameters for the serial port. -# For a serial device (not IPMI SOL): -# Options 300, 1200, 2400, 4800, 9600, 19200, 38400, -# 57600, 115200 set the various baud rates. EVEN, -# ODD, NONE (MARK and SPACE if supported) set the parity. -# Note that MARK and SPACE are not available on all systems -# or hardware, if it is not supported then it will be -# silently set to ODD or EVEN parity. -# 1STOPBIT, 2STOPBITS set -# the number of stop bits. 5DATABITS, 6DATABITS, -# 7DATABITS, 8DATABITS set the number of data bits. -# [-]XONXOFF turns on (- off) XON/XOFF support. -# [-]RTSCTS turns on (- off) hardware flow control, -# [-]LOCAL turns off (- on) monitoring of the modem lines, -# and [-]HANGUP_WHEN_DONE turns on (- off) lowering the -# modem control lines when the connection is done. -# [-]NOBREAK disables automatic setting of the break -# setting of the serial port. -# -# The "[-]remctl" option allow remote control (ala RFC -# 2217) of serial-port configuration. -# -# Example: -# 5000:telnet:0:/dev/ttyAPP0:115200 8DATABITS NONE 1STOPBIT -XONXOFF -LOCAL -RTSCTS remctl diff --git a/net/ser2net/files/ser2net.init b/net/ser2net/files/ser2net.init index ca9915b908..5453ca380a 100644 --- a/net/ser2net/files/ser2net.init +++ b/net/ser2net/files/ser2net.init @@ -7,55 +7,71 @@ STOP=10 USE_PROCD=1 PROG=/usr/sbin/ser2net -STATICCFGFILE="/etc/ser2net.conf" -DYNAMICCFGFILE="/tmp/ser2net.conf" +STATICCFGFILE="/etc/ser2net.yaml" +DYNAMICCFGFILE="/tmp/ser2net.yaml" list_cb_append() { local var="$2" local value="$1" - local sep="${3:- }" + local sep="${3:-,}" eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\"" } -append_bool() { - local var="$1" - local key="$2" - local val="$3" - local uc="$4" - local s="" - - [ "$uc" -eq 1 ] && key=`echo "$key" | tr '[a-z]' '[A-Z]'` - [ "$val" -eq 0 ] && s="-" - - append "$var" "$s$key" -} - ser2net_default() { local cfg="$1" local key val + local baudrate parity databits stopbits - for key in speed baudrate databits stopbits parity chardelay_scale chardelay_min; do - config_get val "$cfg" "$key" - [ -n "$val" ] || continue - - case "$key" in - baudrate) key="speed" ;; - hangup_when_done) ;; - telnet_brk_on_sync) ;; - deassert_CTS_DCD_DSR_on_connect) ;; - *) key=`echo "$key" | tr '_' '-'` + config_get baudrate "$cfg" speed + if [ -n "$baudrate" ]; then + config_get parity "$cfg" parity + case "$parity" in + [Nn]one) parity=n ;; + [Oo]dd) parity=o ;; + [Ee]ven) parity=e ;; + "") ;; + *) return 1 esac - echo "DEFAULT:$key:$val" + if [ -n "$parity" ]; then + config_get databits "$cfg" databits 8 + [ "$databits" -ge 5 ] && [ "$databits" -le 9 ] || return 1 + + config_get stopbits "$cfg" stopbits 1 + case "$stopbits" in + 1) ;; + 2) ;; + *) return 1 + esac + fi + + echo "default:" + echo " name: speed" + echo " value: $baudrate${parity:+$parity$databits$stopbits}" + fi + + for key in chardelay_scale chardelay_min; do + config_get val "$cfg" "$key" + [ -n "$val" ] || continue + key=`echo "$key" | tr '_' '-'` + echo "default:" + echo " name: $key" + echo " value: $val" done for key in chardelay deassert_CTS_DCD_DSR_on_connect hangup_when_done kickolduser \ local nobreak remctl rtscts telnet_brk_on_sync xonxoff; do + case "$key" in + remctl) key=rfc2217 ;; + esac config_get_bool val "$cfg" "$key" [ -n "$val" ] || continue + key=`echo "$key" | tr '_' '-'` [ "$val" -eq 0 ] && val="false" || val="true" - echo "DEFAULT:$key:$val" + echo "default:" + echo " name: $key" + echo " value: $val" done echo @@ -70,8 +86,12 @@ ser2net_controlport() { config_get host "$cfg" host config_get port "$cfg" port + [ "$port" -ge 1 ] && [ "$port" -le 65535 ] || return 1 - echo -e "CONTROLPORT:${host:+$host,}$port\n" + echo "admin:" + echo " accepter: tcp,${host:+$host,}$port" + + echo } ser2net_led() { @@ -80,84 +100,114 @@ ser2net_led() { config_get driver "$cfg" driver sysfs config_get device "$cfg" device - config_get state "$cfg" state 1 - config_get duration "$cfg" duration 20 + [ -z "$device" ] && return 1 + config_get duration "$cfg" duration + config_get state "$cfg" state - echo -e "LED:$cfg:$driver:device=$device state=$state duration=$duration\n" + echo "led: &$cfg" + echo " driver: $driver" + echo " options:" + echo " device: \"$device\"" + [ -n "$duration" ] && echo " duration: $duration" + [ -n "$state" ] && echo " state: $state" + + echo } ser2net_proxy() { local cfg="$1" local enabled port protocol timeout device baudrate databits parity stopbits - local led_tx led_rx key boolval options + local key boolval options custom_options + local echo_options=1 config_get_bool enabled "$cfg" enabled 0 - [ "$enabled" -eq 0 ] && return 0 - config_get port "$cfg" port - [ "$port" -le 0 -o "$port" -gt 65535 ] && return 1 - - config_get protocol "$cfg" protocol - case "$protocol" in - raw|rawlp|telnet|off) ;; - *) return 1 - esac - - config_get timeout "$cfg" timeout 0 config_get device "$cfg" device [ -z "$device" ] && return 1 - config_get baudrate "$cfg" baudrate - [ -n "$baudrate" ] && append options "$baudrate" + config_get port "$cfg" port + [ "$port" -ge 1 ] && [ "$port" -le 65535 ] || return 1 - config_get databits "$cfg" databits - if [ -n "$databits" ]; then - [ "$databits" -lt 5 -o "$databits" -gt 8 ] && return 1 - append options "${databits}DATABITS" + config_get protocol "$cfg" protocol + case "$protocol" in + raw) + protocol="tcp" + ;; + rawlp) + protocol="tcp" + options="wronly" + ;; + telnet) + protocol="telnet,tcp" + + config_get_bool boolval "$cfg" remctl 0 + [ "$boolval" -eq 1 ] && protocol="telnet(rfc2217),tcp" + ;; + off) + enabled=0 + ;; + *) return 1 + esac + + config_get baudrate "$cfg" baudrate + if [ -n "$baudrate" ]; then + config_get parity "$cfg" parity + case "$parity" in + [Nn]one) parity=n ;; + [Oo]dd) parity=o ;; + [Ee]ven) parity=e ;; + "") ;; + *) return 1 + esac + + if [ -n "$parity" ]; then + config_get databits "$cfg" databits 8 + [ "$databits" -ge 5 ] && [ "$databits" -le 9 ] || return 1 + + config_get stopbits "$cfg" stopbits 1 + case "$stopbits" in + 1) ;; + 2) ;; + *) return 1 + esac + fi fi - config_get parity "$cfg" parity - parity=`echo "$parity" | tr '[a-z]' '[A-Z]'` - case "$parity" in - EVEN|ODD|NONE|MARK|SPACE) append options "$parity" ;; - "") ;; - *) return 1 - esac - - config_get stopbits "$cfg" stopbits - case "$stopbits" in - 1) append options "${stopbits}STOPBIT" ;; - 2) append options "${stopbits}STOPBITS" ;; - "") ;; - *) return 1 - esac - - config_get led_tx "$cfg" led_tx - [ -n "$led_tx" ] && append options "led-tx=$led_tx" - - config_get led_rx "$cfg" led_rx - [ -n "$led_rx" ] && append options "led-rx=$led_rx" + config_get timeout "$cfg" timeout 0 for key in rtscts local xonxoff nobreak hangup_when_done; do config_get_bool boolval "$cfg" "$key" [ -n "$boolval" ] || continue - append_bool options "$key" "$boolval" 1 + key=`echo "$key" | tr '_' '-'` + options="${options:+$options,}$key" + [ "$boolval" -eq 0 ] && options="$options=false" done - for key in chardelay telnet_brk_on_sync kickolduser remctl; do + config_list_foreach "$cfg" options list_cb_append custom_options + + echo "connection: &$cfg" + echo " accepter: $protocol,$port" + echo " timeout: $timeout" + [ "$enabled" -eq 0 ] && echo " enable: off" + echo " connector: serialdev,$device${baudrate:+,$baudrate${parity:+$parity$databits$stopbits}}${options:+,$options}${custom_options:+,$custom_options}" + + for key in led_tx led_rx; do + config_get val "$cfg" "$key" + [ -n "$val" ] || continue + [ "$echo_options" -eq 1 ] && echo " options:" && echo_options=0 + key=`echo "$key" | tr '_' '-'` + echo " $key: *$val" + done + + for key in chardelay telnet_brk_on_sync kickolduser; do config_get_bool boolval "$cfg" "$key" [ -n "$boolval" ] || continue - append_bool options "$key" "$boolval" 0 + [ "$echo_options" -eq 1 ] && echo " options:" && echo_options=0 + key=`echo "$key" | tr '_' '-'` + echo " $key: $boolval" done - config_list_foreach "$cfg" options list_cb_append options - - if [ "`echo "$device" | sed 's/://g'`" != "$device" ]; then - echo "DEVICE:$cfg:$device" - device="$cfg" - fi - - echo -e "$port:$protocol:$timeout:$device:$options\n" + echo } start_service() { @@ -169,15 +219,15 @@ start_service() { [ "$enabled" -gt 0 ] || return 0 cat "$STATICCFGFILE" - 2>/dev/null <<-EOF > "$DYNAMICCFGFILE" - + # # Following part is auto-generated from UCI settings in /etc/config/ser2net # EOF - config_foreach ser2net_controlport controlport >> "$DYNAMICCFGFILE" config_foreach ser2net_default default >> "$DYNAMICCFGFILE" config_foreach ser2net_led led >> "$DYNAMICCFGFILE" + config_foreach ser2net_controlport controlport >> "$DYNAMICCFGFILE" config_foreach ser2net_proxy proxy >> "$DYNAMICCFGFILE" procd_open_instance diff --git a/net/ser2net/files/ser2net.yaml b/net/ser2net/files/ser2net.yaml new file mode 100644 index 0000000000..8a46ef011a --- /dev/null +++ b/net/ser2net/files/ser2net.yaml @@ -0,0 +1,10 @@ +# This is a minimal example configuration file for ser2net. For a version with +# detailed comments and all possible configuration directives, please visit: +# https://github.com/cminyard/ser2net/blob/master/ser2net.yaml +# +# On OpenWrt/LEDE systems, this configuration serves as a base configuration. +# During boot of the system, the UCI configuration file /etc/config/ser2net is +# parsed and converted to additional configuration lines which are _appended_ +# to this file. The ser2net daemon is then started with the combined +# configuration file /tmp/ser2net.yaml. + diff --git a/net/ser2net/patches/001-fix-disabling-pam.patch b/net/ser2net/patches/001-fix-disabling-pam.patch deleted file mode 100644 index 02417d9253..0000000000 --- a/net/ser2net/patches/001-fix-disabling-pam.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/configure.ac -+++ b/configure.ac -@@ -39,7 +39,7 @@ AC_ARG_WITH(pam, - fi, - ) - --if test "use_pam" != "no"; then -+if test "$use_pam" != "no"; then - have_pam=yes - AC_CHECK_HEADER(security/pam_appl.h, [], [have_pam=no]) - if test "$have_pam" = "yes"; then