From patchwork Thu Jun 30 09:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 2569 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id SLbdN330vWKAFwAAIUCqbw (envelope-from ) for ; Thu, 30 Jun 2022 15:07:41 -0400 Received: from proxy18.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net with LMTP id 6PiWN330vWL3MQAAovjBpQ (envelope-from ) for ; Thu, 30 Jun 2022 15:07:41 -0400 Received: from smtp24.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.ord1d.rsapps.net with LMTPS id GFUzN330vWKUHQAATCaURg (envelope-from ) for ; Thu, 30 Jun 2022 15:07:41 -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: smtp24.gate.ord1d.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: e9bd99bc-f8a7-11ec-90bf-52540091a1c4-1-1 Received: from [216.105.38.7] ([216.105.38.7:42716] helo=lists.sourceforge.net) by smtp24.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 7C/85-19047-D74FDB26; Thu, 30 Jun 2022 15:07:41 -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.94.2) (envelope-from ) id 1o6zV1-0000Vv-2c; Thu, 30 Jun 2022 19:06:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o6zUz-0000Vj-Md for openvpn-devel@lists.sourceforge.net; Thu, 30 Jun 2022 19:06:45 +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=e9A4dRi8mFn/ufG/EwfZTXydRSytlkPI3uH75Udw5bM=; b=ST5oAnPdw/fDIZX+/86is/KtYb MsiBX9RzhwMb71YqiMHm4e96Ip1JgtbZuwmbe1fhjnos0jIEJj4nL+0X6EhfHrn0Sbx3erXxah/tH H5JYHgI4/Brsvxu44+eshVZxVv0vwGLgU5STjbGbYJ1E4GqjEc1rYoRYGnon2BpiHX9s=; 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=e9A4dRi8mFn/ufG/EwfZTXydRSytlkPI3uH75Udw5bM=; b=EGdU2aHTDjJZ3G71KVrR9w7tyY RL0OWZ5K8u3HG8Cbm9lLIAoE2oZ8HuWV+rgRD3DMJHv8TsVQAKRKHaUpCVJwzVn+AWAoEDADEIDsa 2cBwWlXqUQHkNynUXJ3zdIHXlt8HB7Tf0g6ehexuEmbMRis8jWLXFq9AYV0aw5Qm/qGk=; Received: from mail-qk1-f177.google.com ([209.85.222.177]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94.2) id 1o6zUu-0000d8-L7 for openvpn-devel@lists.sourceforge.net; Thu, 30 Jun 2022 19:06:44 +0000 Received: by mail-qk1-f177.google.com with SMTP id n10so11732854qkn.10 for ; Thu, 30 Jun 2022 12:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e9A4dRi8mFn/ufG/EwfZTXydRSytlkPI3uH75Udw5bM=; b=hR0P1iSU03eQFavc66WGX3mLnmzGDEvMF4naF8gjB9SVSuhOOBg0u3+TrV26NrIYPD 5QgPvRhJs6CqXojNq3WMJm0Q9okZvxEO0oIIa+6IGQexoiOI8842Oshwjj5i+54A9XSm NTIZib35+bY/Fi9xN6Qy76FDGWgBCWlx60j3JcpU8H1Pdxng/G58N5jyZ9m3Q2yuj1kA x4KltMb2jfODl2khGevevT77OzUEpnZK3JyfMDsm0q8jJqnaRDZiiAjJBbjHo6J2XfMd rj7RDscf8yMb7E+uY4a/EjbbpnEmJrTiYXHuIWqoPD5EAjfviEuDbWUuDzb1Nmvt7p41 DeOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e9A4dRi8mFn/ufG/EwfZTXydRSytlkPI3uH75Udw5bM=; b=Cz16YEyQvYhfygcbDmrxgHYQOP0hUFtvg0djIKuU4QByNQQwLzUsAeWYSvUDhxvp6j qBrVCxEyYKQK3WZr9qbM8i5mh/w3uh3TgCMT9UgSUn9EZhDyAGKGyCyykNlT6ESteQSv qcNjhlbuouHmf0Oui15p25A12Mhha9xwE3rDJxX5kETOiV9njqBr5xfUU5pM64LCWRXQ muHEoiWdfPbr/HriQuyIN7jNNj4IRoGsZCoU62IvkEjAp/UC9TH8JFyjJUPQq4Gf5gDo 3r0yO2gFZHGZ4RumfTqZa0zZXXFleDwpA+WkVj5aYiXYML/HPsn8jyj1h9ozhcyWOeHi TPFQ== X-Gm-Message-State: AJIora/HMEI3n0W7I65lhweU1k6oqJ3U2Bv+eAkLCTHlQKen/09jsP8/ 22fo0NgbdQwKftqa1OkHidGqLGJ/Y3I= X-Google-Smtp-Source: AGRyM1s4UNKBjHhY1oPeyyirDE57EUE7qJVHX2ri/mwRR0Syoya5rbvR2rAngJn4mMYwSY4vdGGDmA== X-Received: by 2002:a05:620a:4706:b0:6af:482e:b9eb with SMTP id bs6-20020a05620a470600b006af482eb9ebmr7763702qkb.46.1656615994592; Thu, 30 Jun 2022 12:06:34 -0700 (PDT) Received: from uranus.home.sansel.ca (bras-vprn-tnhlon4053w-lp130-02-70-51-223-194.dsl.bell.ca. [70.51.223.194]) by smtp.gmail.com with ESMTPSA id ey14-20020a05622a4c0e00b002fcb0d95f65sm13070640qtb.90.2022.06.30.12.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 12:06:34 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Thu, 30 Jun 2022 15:05:48 -0400 Message-Id: <20220630190549.16675-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630190549.16675-1-selva.nair@gmail.com> References: <20220630190549.16675-1-selva.nair@gmail.com> MIME-Version: 1.0 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: From: Selva Nair --management-client has an obscure and undocumented feature to take a file argument where the peer's address and port are recorded. This has become dead code over time. - reactivate the dead code - make it work with v6 addresses as well - do not exit on error in writing the record Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.222.177 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.222.177 listed in wl.mailspike.net] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1o6zUu-0000d8-L7 Subject: [Openvpn-devel] [PATCH 2/3] Reactivate record_peer_info in manage.c 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 --management-client has an obscure and undocumented feature to take a file argument where the peer's address and port are recorded. This has become dead code over time. - reactivate the dead code - make it work with v6 addresses as well - do not exit on error in writing the record Signed-off-by: Selva Nair --- Alternatively we could remove this "feature" and related code. src/openvpn/manage.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 21c7ccdd..548d3b9a 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -1621,23 +1621,19 @@ man_record_peer_info(struct management *man) if (man->settings.write_peer_info_file) { bool success = false; -#ifdef HAVE_GETSOCKNAME if (socket_defined(man->connection.sd_cli)) { - struct sockaddr_in addr; + struct sockaddr_storage addr; socklen_t addrlen = sizeof(addr); int status; - CLEAR(addr); status = getsockname(man->connection.sd_cli, (struct sockaddr *)&addr, &addrlen); - if (!status && addrlen == sizeof(addr)) + if (!status) { - const in_addr_t a = ntohl(addr.sin_addr.s_addr); - const int p = ntohs(addr.sin_port); FILE *fp = platform_fopen(man->settings.write_peer_info_file, "w"); if (fp) { - fprintf(fp, "%s\n%d\n", print_in_addr_t(a, 0, &gc), p); + fprintf(fp, "%s\n", print_sockaddr((struct sockaddr *)&addr, &gc)); if (!fclose(fp)) { success = true; @@ -1645,12 +1641,10 @@ man_record_peer_info(struct management *man) } } } -#endif /* ifdef HAVE_GETSOCKNAME */ if (!success) { msg(D_MANAGEMENT, "MANAGEMENT: failed to write peer info to file %s", man->settings.write_peer_info_file); - throw_signal_soft(SIGTERM, "management-connect-failed"); } } gc_free(&gc);