xinetd rewrite
cover xinetd rewrite
Hi Alexey,
this sounds as a bad joke to rewrite tests for xinetd, which nobody uses now. I was surprised, that it's still in some distros (e.g. openSUSE, Debian, Gentoo). I can delete the test if we don't want LTP to be a museum.
Kind regards,
Petr
Petr Vorel (2):
xinetd: Rewrite into new API
xinetd: Fix pattern for NetKit telnet
testcases/network/xinetd/xinetd_tests.sh | 99 ++++++++---------------- 1 file changed, 33 insertions(+), 66 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 xinetd: Rewrite into new API
Also check for in.telnetd (the actual telnet daemon).
--- testcases/network/xinetd/xinetd_tests.sh | 99 ++++++++---------------- 1 file changed, 33 insertions(+), 66 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +33 -66
@@ -1,42 +1,27 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> # Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved. # Copyright (c) International Business Machines Corp., 2001 -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it would be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -TCID=xinetd -TST_TOTAL=2 + +TST_SETUP="setup" TST_CLEANUP="cleanup" +TST_NEEDS_CMDS="diff telnet in.telnetd xinetd" +TST_NEEDS_TMPDIR=1 +TST_TESTFUNC="do_test" +TST_CNT=2 . daemonlib.sh -TST_USE_LEGACY_API=1 . tst_net.sh setup() { [ -f "/usr/lib/systemd/system/telnet.socket" ] && \ - tst_brkm TCONF "xinetd doesn't manage telnet" - - tst_tmpdir - - tst_require_cmds xinetd diff telnet + tst_brk TCONF "xinetd doesn't manage telnet" check_addr="127.0.0.1" ip a | grep -q inet6 && check_addr="$check_addr ::1" - # Create custom xinetd.conf file. - # tst_xinetd.conf.1 config file has telnet service disabled. cat > tst_xinetd.conf.1 <<-EOF defaults {
@@ -70,76 +55,58 @@ service telnet flags = IPv6 } EOF - - # create a backup of the original xinetd.conf file. ROD mv /etc/xinetd.conf xinetd.conf.orig } cleanup() { - # restore the original xinetd.conf if a back up exits. [ -f xinetd.conf.orig ] && \ mv xinetd.conf.orig /etc/xinetd.conf - # restoring original services restart_daemon xinetd - - tst_rmdir } restart_xinetd() { - tst_resm TINFO "restart xinetd" - # restart xinetd to re-start the services + tst_res TINFO "restart xinetd" restart_daemon xinetd > tst_xinetd.out 2>&1 if [ $? -ne 0 ]; then cat tst_xinetd.out - tst_brkm TBROK "unable to restart service with telnet disabled" + tst_brk TBROK "unable to restart service with telnet disabled" fi - # even if xinetd restart has zero exit value, - # make certain there was no failure. grep -qi "fail" tst_xinetd.out && \ - tst_brkm TBROK "xinetd failed to restart" + tst_brk TBROK "xinetd failed to restart" } -# Description: - Test that xinetd reads the configuration file and starts or -# stops services. -# - restart xinetd with configuration file with telnet disabled. -# - telnet to locahost should fail. -# - restart xinetd with configuration file with telnet enabled. -# - telnet to locahost should work. -test01() +xinetd_test() { - tst_resm TINFO "install the new config file with telnet disabled" - ROD mv tst_xinetd.conf.1 /etc/xinetd.conf - restart_xinetd + local cnt=$1 + local desc="$2" + local pattern="$3" + local a p - for a in $check_addr; do - echo '' | telnet $a 2>&1 | grep -qi \ - "telnet: connect to address $a: Connection refused" - [ $? -ne 0 ] && \ - tst_brkm TFAIL "not expected output for 'telnet $a'" - done - - tst_resm TPASS "expected output with telnet disabled" - - tst_resm TINFO "install the xinetd config file with telnet enabled" - ROD mv tst_xinetd.conf.2 /etc/xinetd.conf + tst_res TINFO "install the new config file with telnet $desc" + ROD mv tst_xinetd.conf.$cnt /etc/xinetd.conf restart_xinetd for a in $check_addr; do - echo '' | telnet $a 2>&1 | grep -qi \ - "Connection closed by foreign host" + p=$(echo $pattern | sed "s/ADDR/$a/") + echo '' | telnet $a 2>&1 | grep -qi "$p" [ $? -ne 0 ] && \ - tst_brkm TFAIL "not expected output for 'telnet $a'" + tst_brk TFAIL "not expected output for 'telnet $a'" done - - tst_resm TPASS "expected output with telnet enabled" + tst_res TPASS "expected output with telnet $desc" } -setup - -test01 +do_test() +{ + case $1 in + 1) xinetd_test $1 "disabled" \ + "telnet: connect to address ADDR: Connection refused";; + 2) xinetd_test $1 "enabled" \ + "Connection closed by foreign host";; + esac +} -tst_exit +tst_run
Signature · 1 line
2.25.1
PATCH 2/2 xinetd: Fix pattern for NetKit telnet
In reply to Petr Vorel--- testcases/network/xinetd/xinetd_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +2 -2
@@ -92,7 +92,7 @@ xinetd_test() for a in $check_addr; do p=$(echo $pattern | sed "s/ADDR/$a/") - echo '' | telnet $a 2>&1 | grep -qi "$p" + echo '' | telnet $a 2>&1 | grep -qiE "$p" [ $? -ne 0 ] && \ tst_brk TFAIL "not expected output for 'telnet $a'" done
@@ -103,7 +103,7 @@ do_test() { case $1 in 1) xinetd_test $1 "disabled" \ - "telnet: connect to address ADDR: Connection refused";; + "telnet: (connect to address ADDR|Unable to connect to remote host): Connection refused";; 2) xinetd_test $1 "enabled" \ "Connection closed by foreign host";; esac
Signature · 1 line
2.25.1
cover xinetd rewrite
In reply to Petr VorelQuoted 7 lines · Petr Vorel
Hi Alexey,
this sounds as a bad joke to rewrite tests for xinetd, which nobody uses now. I was surprised, that it's still in some distros (e.g. openSUSE, Debian, Gentoo). I can delete the test if we don't want LTP to be a museum.
Hi Petr,
Perhaps, it is true for inetd, not for xinetd.
The changes look good, acked.
Quoted 10 lines
Kind regards,
PetrPetr Vorel (2):
xinetd: Rewrite into new API
xinetd: Fix pattern for NetKit telnettestcases/network/xinetd/xinetd_tests.sh | 99 ++++++++---------------- 1 file changed, 33 insertions(+), 66 deletions(-)
cover xinetd rewrite
Hi Alexey,
Quoted 5 lines
Hi Petr,
Perhaps, it is true for inetd, not for xinetd.
The changes look good, acked.
Thanks for your review!
Merged with your ack.
Kind regards,
Petr