From patchwork Wed Aug 25 11:02:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1921 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.57]) by backend30.mail.ord1d.rsapps.net with LMTP id 8EiHFzawJmHMRQAAIUCqbw (envelope-from ) for ; Wed, 25 Aug 2021 17:03:50 -0400 Received: from proxy8.mail.iad3a.rsapps.net ([172.27.255.57]) by director9.mail.ord1d.rsapps.net with LMTP id yN9oFzawJmHzNAAAalYnBA (envelope-from ) for ; Wed, 25 Aug 2021 17:03:50 -0400 Received: from smtp38.gate.iad3a ([172.27.255.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.iad3a.rsapps.net with LMTPS id 0PSxEDawJmGFBwAAsBr/qg (envelope-from ) for ; Wed, 25 Aug 2021 17:03:50 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp38.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: f1a2e56e-05e7-11ec-9a23-525400000c92-1-1 Received: from [216.105.38.7] ([216.105.38.7:48152] helo=lists.sourceforge.net) by smtp38.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 6F/4C-19860-530B6216; Wed, 25 Aug 2021 17:03:49 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mJ037-0001tz-IS; Wed, 25 Aug 2021 21:03:05 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJ036-0001tp-Vv for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 21:03:04 +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=H/PCp45t4u69MezYO6m1z5D5pL0wU8bqJYmUTGKxM5A=; b=VCTGeRmVPidgvjYtbLOULwNeH0 EoTuk/75wRKCSYFDGx9V3SlvkZGAhfAOiEGnhST4fwxe+7bWOUe0HTVgRnho8ZYujC1TJzKLfdufy qYyufCyMPscmLXsklb79YQe4l81g+CgBvaOHXd95x6w9QRJQQ5xTbVsiuultSdrjHu4w=; 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=H/PCp45t4u69MezYO6m1z5D5pL0wU8bqJYmUTGKxM5A=; b=G+ngDq4hzdN4beyu2E+vDWTOGT zj7vY64CMAcVeCD90fw0hmw5rIAdEdEOkoTdA6tn2P3t7ERUMZcr3KY8JU4I2Oxyy5nyAu/HHFMrb ldaOeWyiZezJcynqGZ8VUwwOq0fbzXArJbTcRQ4KJcqQw1Wlcosik43UQUV7pW1ODUlU=; Received: from mail-qt1-f176.google.com ([209.85.160.176]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1mJ02z-000612-VC for openvpn-devel@lists.sourceforge.net; Wed, 25 Aug 2021 21:03:04 +0000 Received: by mail-qt1-f176.google.com with SMTP id d2so655162qto.6 for ; Wed, 25 Aug 2021 14:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H/PCp45t4u69MezYO6m1z5D5pL0wU8bqJYmUTGKxM5A=; b=PN5ry1Q4cmg6eZF1GbdgL0G3nccfUs39NI3+uVgQdnjHyvl7EqdniwmYt3wlQkmfmy P5eQJUCO8g8zl8Vsm1tYK/Sto/Ig9zQbiYm6kDH6zvcl2bWWWVo9N9aHZjflUFQ037// +ovH1+z/7MA8TBwPVRg5ku/MiryMzI4UGJ0VU4Em6t7Hup9salH32/ged7MCqaTOF+yj ZZfAFCXhVXYFWQ5G9Ds7bMbLUMk7+gGcE4cY5pucLeAXRqUR+Ltbv7liNm/sNFWO5ARM XH7pcPcjsKtID+uqaaljCCW8evczvKUH2I4RG/OlX96jL8Ei32HdQpy9h0hXQc9oh67e TB/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H/PCp45t4u69MezYO6m1z5D5pL0wU8bqJYmUTGKxM5A=; b=TZ9lAOLgvNNqjK8rj4f285mU2d2D8QYwXmRDYCMUmwwqc6reM5F2a0vU/i768IKm5u gtuYmOimtHRWXVjbjNkcqiJ2oUdYQgsvfXuYlWJ7cbGUIfFB+k5l+r+pJVhlNceejCyt dLr5C30AHnu+KxSm46jgmZAYqZLLJfHAyTdQXQk/ByoSC9QwsdGhx6ncsDLaqcoDfkTc MgCRDOqRaA7IB2/PF6ztsZjskmZI3OgyQg4bWZSHlZ689RowLEBMVBbHZhvzrJJki6Nv haHXccR/zcA7zU/NLnOIegmsnhv6Nd1yjuBf/Rq318G7cUrX55kR7onmRC1LW2imk8it z7Dg== X-Gm-Message-State: AOAM5327ZxPIfrGTnUVkTi3MzJ0Ym2ETnNMzY4ESBK2Uo+tSf8W6IDD4 Dq2Bks24WX6iLEUWO1zQIPqPhqxnB45iRfUx X-Google-Smtp-Source: ABdhPJy8n0OeV1GcBIsFWdswfdG0G6mof66oab8s1dNw1us9MgsULLMkesCcHl89CYrxE0HVu7HGcA== X-Received: by 2002:a05:622a:10:: with SMTP id x16mr249242qtw.88.1629925371657; Wed, 25 Aug 2021 14:02:51 -0700 (PDT) Received: from uranus.home.sansel.ca (bras-vprn-tnhlon4053w-lp130-02-70-51-223-174.dsl.bell.ca. [70.51.223.174]) by smtp.gmail.com with ESMTPSA id o7sm527549qtw.87.2021.08.25.14.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 14:02:51 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Wed, 25 Aug 2021 17:02:32 -0400 Message-Id: <20210825210232.22509-3-selva.nair@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210825210232.22509-1-selva.nair@gmail.com> References: <20210825040122.14244-1-selva.nair@gmail.com> <20210825210232.22509-1-selva.nair@gmail.com> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (selva.nair[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.160.176 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.160.176 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.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1mJ02z-000612-VC Subject: [Openvpn-devel] [PATCH v2 3/3] Use a template for "unsupported management commands" error 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 From: Selva Nair The message "ERROR: The 'foo' commmand is not supported by current daemon mode" is repeatedly used in manage.c. Move it to a function for uniformity in messaging. Signed-off-by: Selva Nair Acked-By: Arne Schwabe --- src/openvpn/manage.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 214ea4be..7eff2dba 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -447,6 +447,12 @@ man_signal(struct management *man, const char *name) } } +static void +man_command_unsupported(const char *command_name) +{ + msg(M_CLIENT, "ERROR: The '%s' command is not supported by the current daemon mode", command_name); +} + static void man_status(struct management *man, const int version, struct status_output *so) { @@ -456,7 +462,7 @@ man_status(struct management *man, const int version, struct status_output *so) } else { - msg(M_CLIENT, "ERROR: The 'status' command is not supported by the current daemon mode"); + man_command_unsupported("status"); } } @@ -572,7 +578,7 @@ man_kill(struct management *man, const char *victim) } else { - msg(M_CLIENT, "ERROR: The 'kill' command is not supported by the current daemon mode"); + man_command_unsupported("kill"); } gc_free(&gc); @@ -777,7 +783,7 @@ man_net(struct management *man) } else { - msg(M_CLIENT, "ERROR: The 'net' command is not supported by the current daemon mode"); + man_command_unsupported("net"); } } @@ -799,7 +805,7 @@ man_send_cc_message(struct management *man, const char *message, const char *par } else { - msg(M_CLIENT, "ERROR: This command is not supported by the current daemon mode"); + man_command_unsupported("cr-repsonse"); } } #ifdef ENABLE_PKCS11 @@ -842,7 +848,7 @@ man_remote_entry_count(struct management *man) } else { - msg(M_CLIENT, "ERROR: The remote-entry-count command is not supported by the current daemon mode"); + man_command_unsupported("remote-entry-count"); } } @@ -865,7 +871,7 @@ man_remote_entry_get(struct management *man, unsigned int index) } else { - msg(M_CLIENT, "ERROR: The remote-entry command is not supported by the current daemon mode"); + man_command_unsupported("remote-entry-get"); } free(remote); @@ -956,7 +962,7 @@ in_extra_dispatch(struct management *man) } else { - msg(M_CLIENT, "ERROR: The client-auth command is not supported by the current daemon mode"); + man_command_unsupported("client-auth"); } break; @@ -980,7 +986,7 @@ in_extra_dispatch(struct management *man) } else { - msg(M_CLIENT, "ERROR: The client-pf command is not supported by the current daemon mode"); + man_command_unsupported("client-pf"); } break; @@ -1065,7 +1071,7 @@ man_client_pending_auth(struct management *man, const char *cid_str, } else { - msg(M_CLIENT, "ERROR: The client-pending-auth command is not supported by the current daemon mode"); + man_command_unsupported("client-pending-auth"); } } } @@ -1116,7 +1122,7 @@ man_client_deny(struct management *man, const char *cid_str, const char *kid_str } else { - msg(M_CLIENT, "ERROR: The client-deny command is not supported by the current daemon mode"); + man_command_unsupported("client-deny"); } } } @@ -1141,7 +1147,7 @@ man_client_kill(struct management *man, const char *cid_str, const char *kill_ms } else { - msg(M_CLIENT, "ERROR: The client-kill command is not supported by the current daemon mode"); + man_command_unsupported("client-kill"); } } } @@ -1156,7 +1162,7 @@ man_client_n_clients(struct management *man) } else { - msg(M_CLIENT, "ERROR: The nclients command is not supported by the current daemon mode"); + man_command_unsupported("nclients"); } } @@ -1280,7 +1286,7 @@ man_proxy(struct management *man, const char **p) } else { - msg(M_CLIENT, "ERROR: The proxy command is not supported by the current daemon mode"); + man_command_unsupported("proxy"); } } @@ -1301,7 +1307,7 @@ man_remote(struct management *man, const char **p) } else { - msg(M_CLIENT, "ERROR: The remote command is not supported by the current daemon mode"); + man_command_unsupported("remote"); } }