From patchwork Fri Oct 25 10:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3911 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:3a4c:b0:5b9:581e:f939 with SMTP id n12csp899042mao; Fri, 25 Oct 2024 03:36:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNqY1fdWexsncd7VRRvdU31rwG3uob/zVO1ySV5eIS7Fraxhc820BTzm4paKEEThru3Z9jBOtdRHw=@openvpn.net X-Google-Smtp-Source: AGHT+IGolSvq1l8ojnH91cgpdmihbNsbTnWFsvKqJ5GrtveBl69OP758hA8sHcJ7fv1amTpcXo2/ X-Received: by 2002:a05:6e02:1786:b0:3a0:4e2b:9ab9 with SMTP id e9e14a558f8ab-3a4de77a2c0mr63823415ab.5.1729852618031; Fri, 25 Oct 2024 03:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729852618; cv=none; d=google.com; s=arc-20240605; b=BA27T2mADV7AF4HOAPOso0K9bFvAwBj+5oGzTQMQVRL2czwVHWN1v7NJM45f/lNF8j of8ece05DCybV5aAVgIvonc0BMVUhmcpGiWj4TcbvTEdHj5+Q0ZwbPlQWGk6CBCWKDff 619ssYUMTn/KI5fagGg5RxvANqwB428/YmzqRuK3uEs5SC7OV1TZGIsBf9HIBsd40UIh WfO9Eb6r5v/NjKO+g53piEb0CjjrW2ks3IwVIfAHV/O2mvdAbKSoGEiJh9ZBO4TB0CAg ZB2Pci8Z+eNYfnDeH3sU9L9ueVjQkmMTEfb/SyoJj2Oy1R8JlBmwAJ+Y1TOjw8SlW4ZH MCmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=P995lY3XdK+jl2PGjaP05zm0IVVitgiXCYLKdp5Mhfw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=IdZ8Zdw7Z/k6eFF7F6bxxW31eqqWCOxYct41x7t+xi05zCl3pEC5K8gny8o9GWl8Hx 4PHuuuTD2rUX+vdTecNVXaMWasbcVseiKlhDFNA8sHGs6xNpNHX/TCJSOAZDlZcsIomJ bxbxzQDFZIY4c/LGe4FUr5m2wERUKxjYRuocGiPEEkjzN1yZKKMF40W7+Mc09affR+Pz /uHyX5iQ5Bywri7rcld0lTNObu0FXMQ3Ykh7lUgifQMa6JPy5tupdsIyeVwyKKe/GRUR VlHVtzcHV54EduBJVKPuZtTa3wTWhuuPplXJsCX66DHVQPj0zXGHAdGLi5fRuS5nUcEp z1Uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=fBJ7GFev; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ZvvzxN0D; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a4e6de5cfcsi3999545ab.59.2024.10.25.03.36.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2024 03:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=fBJ7GFev; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ZvvzxN0D; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t4HgW-00016U-Pf; Fri, 25 Oct 2024 10:36:48 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t4HgU-00016N-RY for openvpn-devel@lists.sourceforge.net; Fri, 25 Oct 2024 10:36:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NJ0fT2azL6MtqH7cz7h9ao5noRNLfc1rSp4xtbZkox8=; b=fBJ7GFevc8a36DHJSgha8kR+KP bBPO2bkjYgrZA51YwMdv6S2n5hLyRZ5CnY54RyzsrAHGjTmcUtkwFNRMy6QblsN+Kuxfs+Dv732z/ ejuQoDhc3Q8sFiBWbuskXL8FjW7GEcHQytq5ZoTqUJkcNXckTg7w2KV27id9tWN4LIVI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NJ0fT2azL6MtqH7cz7h9ao5noRNLfc1rSp4xtbZkox8=; b=ZvvzxN0DeSC+3Y6w9FpjpMV2D0 XiulROXdgNyzAfK2+WFLtKEOxeAcbhwvRupb0l4Z+dpmIoSkLa1mRBbrnW05oUmKRYWDez+y7R+Cj VVdN4KwZaV8uGc81Hkj+6Eirn2EZdy9QL3jvHfzFXJk3nuLXJtoArC8HurmnJ7J5i0SE=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t4HgS-0007Wc-RW for openvpn-devel@lists.sourceforge.net; Fri, 25 Oct 2024 10:36:46 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 49PAaX7j004424 for ; Fri, 25 Oct 2024 12:36:33 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 49PAaXAa004423 for openvpn-devel@lists.sourceforge.net; Fri, 25 Oct 2024 12:36:33 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 25 Oct 2024 12:36:31 +0200 Message-ID: <20241025103632.4413-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22util-spamd-2=2Ev13=2Elw=2Esourceforge=2Ecom=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Samuli_Sepp=C3=A4nen_=3Csamuli?= =?unknown-8bit?q?=2Eseppanen=40gmail=2Ecom=3E_Change-Id=3A?= =?unknown-8bit?q?_Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb_Signed-off-by=3A?= =?unknown-8bit?q?_Samuli_Sepp=C3=A4nen?= =?unknown-8bit?q?_=3Csamuli=2Eseppanen=40gmail=2Ecom=3E_Acked-by=3A_Gert_Doe?= =?unknown-8bit?q?ring_=3Cgert=40greenie=2Emuc=2Ede=3E?= =?unknown-8bit?q?_---_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-0=2E0_points=2C_6=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_-0=2E0_SPF=5FHELO=5FPASS__________SPF=3A_HELO_matches_SPF_?= =?unknown-8bit?q?record?= X-Headers-End: 1t4HgS-0007Wc-RW Subject: [Openvpn-devel] [PATCH v9] t_server_null: forcibly kill misbehaving servers X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1813881938708271398?= X-GMAIL-MSGID: =?utf-8?q?1813881938708271398?= From: Samuli Seppänen Change-Id: Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb Signed-off-by: Samuli Seppänen Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/775 This mail reflects revision 9 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh index d4311d4..3c0fc4b 100755 --- a/tests/t_server_null.sh +++ b/tests/t_server_null.sh @@ -71,4 +71,10 @@ # pre and post ifconfig output does not match. wait -exit $retval +. ./t_server_null_default.rc + +if [ -e $SERVER_KILL_FAIL_FILE ]; then + exit 1 +else + exit $retval +fi diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh index 846f790..2210e63 100755 --- a/tests/t_server_null_client.sh +++ b/tests/t_server_null_client.sh @@ -53,11 +53,11 @@ echo "PASS ${test_name} (test failure)" elif [ $exit_code -eq 0 ] && [ "${should_pass}" = "no" ]; then echo "FAIL ${test_name} (test failure)" - cat "${log}" + cat "${t_server_null_logdir}/${log}" retval=1 elif [ $exit_code -eq 1 ] && [ "${should_pass}" = "yes" ]; then echo "FAIL ${test_name}" - cat "${log}" + cat "${t_server_null_logdir}/${log}" retval=1 fi } diff --git a/tests/t_server_null_default.rc b/tests/t_server_null_default.rc index 825bb52..cbf4877 100755 --- a/tests/t_server_null_default.rc +++ b/tests/t_server_null_default.rc @@ -20,6 +20,10 @@ SERVER_KEY="${sample_keys}/server.key" TA="${sample_keys}/ta.key" +# Used to detect if graceful kill of any server instance failed during the test +# run +SERVER_KILL_FAIL_FILE=".t_server_null_server.kill_failed" + # Test server configurations MAX_CLIENTS="10" CLIENT_MATCH="Test-Client" diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh index f8ba3a3..ab01dd2 100755 --- a/tests/t_server_null_server.sh +++ b/tests/t_server_null_server.sh @@ -8,6 +8,9 @@ status="${server_name}.status" pid="${server_name}.pid" + # Allow reading this file even umask values are strict + touch "$log" + if [ -z "${RUN_SUDO}" ]; then "${server_exec}" \ $server_conf \ @@ -34,6 +37,9 @@ # Load local configuration, if any test -r ./t_server_null.rc && . ./t_server_null.rc +# Remove server kill failure marker file, if any +rm -f $SERVER_KILL_FAIL_FILE + # Launch test servers for SUF in $TEST_SERVER_LIST do @@ -75,6 +81,7 @@ # Make sure that the server processes are truly dead before exiting. If a # server process does not exit in 15 seconds assume it never will, move on and # hope for the best. + echo "Waiting for servers to exit" for PID_FILE in $server_pid_files do @@ -85,22 +92,25 @@ continue fi - if [ -z "${RUN_SUDO}" ]; then - $KILL_EXEC "${SERVER_PID}" - else - $RUN_SUDO $KILL_EXEC "${SERVER_PID}" - fi + # Attempt to kill the OpenVPN server gracefully with SIGTERM + $RUN_SUDO $KILL_EXEC "${SERVER_PID}" count=0 maxcount=75 while [ $count -le $maxcount ] do - ps -p "${SERVER_PID}" > /dev/null || break + $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break count=$(( count + 1)) sleep 0.2 done + # If server is still up send a SIGKILL if [ $count -ge $maxcount ]; then - echo "WARNING: could not kill server with pid ${SERVER_PID}!" + $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}" + SERVER_NAME=$(basename $PID_FILE|cut -d . -f 1) + echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!" + echo "Tail of server log:" + tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log" + touch $SERVER_KILL_FAIL_FILE fi done