From patchwork Mon Nov 20 11:36:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3458 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:50e4:b0:f2:62eb:61c1 with SMTP id r4csp2204025dyd; Mon, 20 Nov 2023 03:37:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHHL/PS8mswxCa+AX2Zp6uBpd84U5HKV5Zce6ooXDWPMVm+Mp7McLpVNNosuyt2P/lI85m X-Received: by 2002:a05:6830:3547:b0:6bd:6d51:e9e5 with SMTP id bf7-20020a056830354700b006bd6d51e9e5mr6012510otb.0.1700480219885; Mon, 20 Nov 2023 03:36:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700480219; cv=none; d=google.com; s=arc-20160816; b=MaPNSFOgEtTQyKtsxVLNKrAqQm6AJ1uHDXawkTCqoqdcvLGJv0Nz2aVGwQY8T4PWdW +3UESpHFuUfOH5rHqk733+hBZe8DbccoinHEqKcVmeuxFYkYd5o/F5jdKQoRqNHZ5hvp i5sHu5nr/x47DzGFmN61Ip18d+0HcGzqPn/Pk0k0qNicGdoa/7y/PEFcm5vD+apS39QI 3LvVUSwwJYy/FPXMpuD09gld4Nn2UnFjB086XYtkJBNN+rDv57MKsjJfjairiB9oz9FN CGs6XRqeWxfqJt4JcbcS4+t4shOP3+QkIzkHNfa37U6THEYRfSNsSnPSLVgVn1f6qj8L 3EPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=s3BahIEoy4qKdAOd8tVfrOUehyxaMn2g8X0Wcywa+Vo=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=jwzCF4Y2+xRsxmZBRJTZVa4eEh65qB1FLcylvskAaz7cxmqZed1Si1ELF6dJ0dSxkx gioeQ+TcgbXu/E9ROVa7sjWGkkc+peYUee6yIxWOmfmTW0fj4ArsRs+86c3nu+GmwA5+ PfOgsErZimwtm51M9tl3hExABY3VyC1mAFnGe0q6oQoqr9zCnt64TnktTlByhjO92i8f OizL/e+gz/5Foc/9BhRRbBor+P1+46JHhFgQ/udoTwEtWJgonbhXKlfgyJ8WloFRS/Kw ftfl0OUb5+p6K21ySVjNRsjyQadRCut7zqPs1upj1PV6agQsEcG6k4OAmFRe9h26F38k YIYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=mwyJ3cnF; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XAvML+Lz; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=KEsdvSLV; 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=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 15-20020a63144f000000b005c200b11b96si7357993pgu.190.2023.11.20.03.36.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 03:36:59 -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=mwyJ3cnF; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=XAvML+Lz; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=KEsdvSLV; 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=openvpn.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 1r52Zx-0004Fc-Gb; Mon, 20 Nov 2023 11:36:36 +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 1r52Zw-0004FW-RT for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 11:36:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jP5PiLjMC0kzkz4oEV6sfDRZFNaoCKWlgcYzB4k71sY=; b=mwyJ3cnFfBh5oNNvSQ8+Tw6Pqa B5XjxD1eHsLXiw6l1asWcj7ylx8pZIx64UP0tazF28ftkcYfkxUPxoJ4bVtBeq4HMKCWLc6o/6SZm PSqvhZnq64fqu4zqJhqKhfwZiMo/GPNvjg5xYpk5DaoJvR+ZsvzMvH9ICP7U/imi8z7A=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=jP5PiLjMC0kzkz4oEV6sfDRZFNaoCKWlgcYzB4k71sY=; b=X AvML+LzmW5kxtHVm57OkjuqSGGixlLRSfsmV/mf/ECrmJEGGyOqcyFZJbpA/f/NCeoicTkkhEXxV2 Gt2LdCAHn8zizwMHzWU05qZDzEIO3opsCpIbMmegAd44I0AatSlhK7zJKnBOAzZuevfBmhyGC9mWF TIZOVqTVblkrWzPc=; Received: from mail-wm1-f46.google.com ([209.85.128.46]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r52Zr-00Axe3-Br for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 11:36:35 +0000 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-408382da7f0so16258435e9.0 for ; Mon, 20 Nov 2023 03:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1700480184; x=1701084984; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=jP5PiLjMC0kzkz4oEV6sfDRZFNaoCKWlgcYzB4k71sY=; b=KEsdvSLVplM5uugyaqVRUW8OzN60q5XKo8THqhBCfUODzhPUD/GG1qrTCXMaLFlvpg Hv3mFDUcfGDFKTo2hYbitykVT+H2C9QQk0dXRQoM83utTWZYDFr+sVqp1U+MJMOBjWyr k2KFvwBDh+EKaKLl9YZhGdoQuoccEjQPo44GvQAEzTac9vX0aYULJb6AzgxZ1wRkWDtw fb6HT3KLk4+pYzM4NjEu0FQJJaTgROLfeSNb8zEVWHqRt33OjZpGv1qVPxlnCK3idx9m biY34KkvzqC8hBQSzkoJLqxFH4jEL9nbB3QA9wfiTelteFGYsT5gZwMY93KsGlrYnd2q +p2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700480184; x=1701084984; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jP5PiLjMC0kzkz4oEV6sfDRZFNaoCKWlgcYzB4k71sY=; b=CZz5Zc579JHM8SU1ITHMLDuyuad8eze+Ke8TwrGOnk7t72pJ0nrGGpUvK7IeM4OzFW Td9ySboOPxwU3ES+oZacr4tZA8kSbr9EzERW9Y8WieJylU1Ae5C/wR/5I8CgAcd+9jJQ nI6WX48OSKSFFJwvTUAeqiL3BoDt5gqe3MvqkVurtLVpeK4GzIYwUF9AAcbwiJ+k0K9P nfzVElx9e7LUqRxqUCImVblh8pGjom5p3Aan1BRyIWPbirD6SdTU4ezbVnfX50q0fwr7 BtPjumRNgcFYDe9L6/mxLOsMuKH9R2fQMFp6ta0XG8y3zENC6bERPGVugqpXLpMOX31q XY+g== X-Gm-Message-State: AOJu0YzNWPbCNu/hCdgr+/O8L7b+NWmXGhKmxu+fFSjtDLaj5HMg40dx e44TUsyFc0JLduvz3JO5zPwOd6McqyAPybLOuAg= X-Received: by 2002:a05:600c:4f82:b0:40a:42dd:c82c with SMTP id n2-20020a05600c4f8200b0040a42ddc82cmr5508010wmq.27.1700480184663; Mon, 20 Nov 2023 03:36:24 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id n4-20020a5d4004000000b003316b3d69b3sm10110284wrp.46.2023.11.20.03.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:36:24 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 20 Nov 2023 11:36:23 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I91f739f5cb43386b2ce767cf3603a76e6b93e216 X-Gerrit-Change-Number: 450 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: da38c4f869830fcded9e7f09d1cb0d59298a522f References: Message-ID: <27edbc35477fa10a89a73be7eadba0fc3b71d705-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.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: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.46 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.46 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1r52Zr-00Axe3-Br Subject: [Openvpn-devel] [S] Change in openvpn[master]: 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: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1783082746940834970?= X-GMAIL-MSGID: =?utf-8?q?1783082746940834970?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/450?usp=email to review the following change. Change subject: Introduce report_command_status helper function ...................................................................... Introduce report_command_status helper function Instead of repeating near identical code several times in manage.c, use a small helper function instead. Change-Id: I91f739f5cb43386b2ce767cf3603a76e6b93e216 --- M src/openvpn/manage.c 1 file changed, 21 insertions(+), 24 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/450/1 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 {