From patchwork Tue Nov 21 10:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3467 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:53c1:b0:f2:62eb:61c1 with SMTP id u1csp271122dye; Tue, 21 Nov 2023 02:43:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGx7SaZiwAYsqnhUBXgPaQyZPJY8A6Us/73y+jGpk3ATqpAaEmYxb3RbmVZNHhmeEqgjM3q X-Received: by 2002:a05:6a00:4215:b0:68f:c8b3:3077 with SMTP id cd21-20020a056a00421500b0068fc8b33077mr9544778pfb.1.1700563403600; Tue, 21 Nov 2023 02:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700563403; cv=none; d=google.com; s=arc-20160816; b=Cr++h3DLKRt81+dV4LiDqq1r2lDDun11XwdcjPipV0cBKdNJR2jUN1yeROf8Tp4OAV i3aYXoMJPt+fjkHCoTOfwMN+NEwdHAu3Qy2dawJLflSyoFilO7n7aJ4u0kEw7Mv0QEhA 5h34EGfw8lHHWHKFIrUaM+ciGrjcwvawShYMwp9oV+vTWwPO2H6+hp6od/VA690TYN2v RZ70NdBAt44ZgQK49bSKKufcpkgrMFvwct60z0v820iOA6XgQ9cCgVqDTC6l+f/Iq2lp h/BU057ZQxjMK067Z7jBju25IbhVenH3++s1VaOgiB5cSP0ofKmj8VXzE453yJNyub8A 8idA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:dkim-signature; bh=40j8Z1cWtbTHSVtR2qqm8gf8RxWUHmRjULTzjevelXs=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=WVZ3bXnB6afBnvUFXMImt9UV92g0YR+nnlh34sQRxNmTEILcf+q+ieevwNmDJgB9xQ Z8QHBUJwZSO+83p9VHZHJ1g2zTK7MtUoXDly2QxAxtVpmPDDBQuwwBQpWFpz7BJTakJV IvgnuKuKs8NJR4SUBa82NOnw2kAwfh6xFoNSVwxUrFX6Kc1pq72iD5fbM8sChr4gDoKM GUAZFNr+BRB0DgtXjqfbhWfPVfnVM8khfQpoNgcN4ohxX1QB8ozLRI0xrDgy5UR+5l4F o4VdtHtwG5aoCyie+YkudjoZAkB7ea4W4OEukGbFXui4B2q08oElRbKinuS8vchGKsbX uUhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=UFt+p5qR; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=AjxRH2aS; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=M+5o52vW; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a190-20020a624dc7000000b006bbfc944748si9776025pfb.315.2023.11.21.02.43.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2023 02:43:23 -0800 (PST) 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=UFt+p5qR; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=AjxRH2aS; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=M+5o52vW; 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 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 1r5ODj-00057F-3j; Tue, 21 Nov 2023 10:43:06 +0000 Received: from [172.30.20.202] (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 1r5ODi-000578-Cs for openvpn-devel@lists.sourceforge.net; Tue, 21 Nov 2023 10:43:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=xUJUykDTAznVSenAzMkqD+PBgDXfa8YW1rMz9QKsqfM=; b=UFt+p5qRPz6urgH9rMlXZSHSQA N2Hbn0aIFt1kNwKsjfHcAnC8lejjchr34T+CuiHxzXGLvTYXxDmfVOKiot9UyAHgA7C5R2obDy6bC Y4yTPkiOgMLiYJ9nPDJR5c7+KgH8Iuuxq3FATNZyCgl6IyKEs2i+1Nw0awQcL28QYYAU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=xUJUykDTAznVSenAzMkqD+PBgDXfa8YW1rMz9QKsqfM=; b=AjxRH2aSTmfoX1r3lCRBhOOPIL 8COhpXFDwbgVNVzJKRn7E2zCraD1Qe54xgtLXqYaBkQAkQvKtH3l3MS0H0sFwQRARuizqLUteaUFL DTrbMW7zTlO0TQhuvQ38qq/ATPNsYCX5YBPTCbAJqF5ES8+qs7MJRRbhTbzPJuLvR+Ow=; Received: from mout-p-201.mailbox.org ([80.241.56.171]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1r5ODg-0001e6-8Q for openvpn-devel@lists.sourceforge.net; Tue, 21 Nov 2023 10:43:05 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4SZLYr0PB6z9scD; Tue, 21 Nov 2023 11:42:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1700563376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xUJUykDTAznVSenAzMkqD+PBgDXfa8YW1rMz9QKsqfM=; b=M+5o52vWWsUEaMtJalWrOQXtYU+ywaU+j/NHCsVLmceVSRYaO1OL5oJr46/mpPFPVr6Kgn 4RbW6pbxejld8lsiomDwW6PCS3LcNeaix5F/lDw9LBh6EaJjZdUML+zr07hGLi1zrtVeKP 2hBkDlPrgI2415rnHje/pjI926VbZtc4rxAd/m2FnzHZHWG+4KgwS4oEhKsIi2/zKBQ5OM pizL/f2zj6iZdOsL1viZkFbsYoSz07HTdFTCvRbDi5VHLeV2TiiTRbk3kf5hH9L4/0VBU2 lR0rbyqKS78Qwn2bt0gvTZymsMKDuAofE/ZNi31NDCQZrz1yggVQOfa17W/4RQ== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Tue, 21 Nov 2023 11:42:54 +0100 Message-Id: <20231121104254.15701-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4SZLYr0PB6z9scD X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arne Schwabe Instead of repeating near identical code several times in manage.c, use a small helper function instead. Change-Id: I91f739f5cb43386b2ce767cf3603a76e6b93e216 Acked-by: Frank Lichtenheld Signed-off-by: Arne Schwabe --- Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.171 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1r5ODg-0001e6-8Q Subject: [Openvpn-devel] [PATCH v1] Introduce report_command_status helper function 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?1783169971363365860?= X-GMAIL-MSGID: =?utf-8?q?1783169971363365860?= From: Arne Schwabe Instead of repeating near identical code several times in manage.c, use a small helper function instead. Change-Id: I91f739f5cb43386b2ce767cf3603a76e6b93e216 Acked-by: Frank Lichtenheld Signed-off-by: Arne Schwabe --- 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/+/450 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index feb62b2..3cf392a 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -284,6 +284,24 @@ #endif } + +/** + * Small function to report the success or failure of a command to + * the management interface + */ +static void +report_command_status(const bool status, const char *command) +{ + if (status) + { + msg(M_CLIENT, "SUCCESS: %s command succeeded", command); + } + else + { + msg(M_CLIENT, "ERROR: %s command failed", command); + } +} + static void man_delete_unix_socket(struct management *man) { @@ -974,14 +992,7 @@ NULL, man->connection.in_extra); man->connection.in_extra = NULL; - if (status) - { - msg(M_CLIENT, "SUCCESS: client-auth command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: client-auth command failed"); - } + report_command_status(status, "client_auth"); } else { @@ -1260,14 +1271,7 @@ if (man->persist.callback.proxy_cmd) { const bool status = (*man->persist.callback.proxy_cmd)(man->persist.callback.arg, p); - if (status) - { - msg(M_CLIENT, "SUCCESS: proxy command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: proxy command failed"); - } + report_command_status(status, "proxy"); } else { @@ -1281,14 +1285,7 @@ if (man->persist.callback.remote_cmd) { const bool status = (*man->persist.callback.remote_cmd)(man->persist.callback.arg, p); - if (status) - { - msg(M_CLIENT, "SUCCESS: remote command succeeded"); - } - else - { - msg(M_CLIENT, "ERROR: remote command failed"); - } + report_command_status(status, "remote"); } else {