| Message ID | 20200903114455.29341-1-themiron@yandex-team.ru |
|---|---|
| State | Rejected, archived |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.27.255.8]) by backend41.mail.ord1d.rsapps.net with LMTP id qFXpGKTXUF8uYQAAqwncew for <patchwork@openvpn.net>; Thu, 03 Sep 2020 07:46:44 -0400 Received: from proxy7.mail.iad3a.rsapps.net ([172.27.255.8]) by director12.mail.ord1d.rsapps.net with LMTP id uKfNGKTXUF9aKgAAIasKDg (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Thu, 03 Sep 2020 07:46:44 -0400 Received: from smtp38.gate.iad3a ([172.27.255.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.iad3a.rsapps.net with LMTPS id mG+mEKTXUF+GcgAAnPvY+A (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Thu, 03 Sep 2020 07:46:44 -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=yandex-team.ru; dmarc=fail (p=none; dis=none) header.from=yandex-team.ru X-Suspicious-Flag: YES X-Classification-ID: 23018dd4-eddb-11ea-8fe6-525400000c92-1-1 Received: from [216.105.38.7] ([216.105.38.7:34790] helo=lists.sourceforge.net) by smtp38.gate.iad3a.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id D4/96-16071-3A7D05F5; Thu, 03 Sep 2020 07:46:43 -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 <openvpn-devel-bounces@lists.sourceforge.net>) id 1kDngQ-00066C-WF; Thu, 03 Sep 2020 11:45:39 +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 <themiron@yandex-team.ru>) id 1kDngN-00065W-84 for openvpn-devel@lists.sourceforge.net; Thu, 03 Sep 2020 11:45:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Dplh9s8iWVRaIrvwqa5c/Ayo+UCbGfqLjSieG+EAnAY=; b=DJ/au0wSqzDCV3W+qvknyO8/FJ QQHRluBGdOBO9zxyNs28nrXpcRWvyOdvtYVbitT6l1+kS1k0zZB0JCrg3ZYeoNQtPBWzxmJKPvJO2 0T53TLDGL6nADBAeq3QlPbrWYWwnZiYt9TpO4Z7zbY2j99ISrw8hYEgVQEJjcaXrd+aM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Dplh9s8iWVRaIrvwqa5c/Ayo+UCbGfqLjSieG+EAnAY=; b=IWHN5oALcjhWMEQZMJAk6CioCk WQc/j/EjYjijFT7q+CbpSb1P5euR7+7hsZQEThQO7lymhyt6CMIN5nFFOBm9clJrkZj3ycsyfOQFh EURMpe2m9En3M72cX5862Ymw46TLk7AapT6SVPtj2eUkpfxbWpGrtpHSKUFWpvc19bTc=; Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kDng9-00BLj2-S4 for openvpn-devel@lists.sourceforge.net; Thu, 03 Sep 2020 11:45:35 +0000 Received: from sas1-ec30c78b6c5b.qloud-c.yandex.net (sas1-ec30c78b6c5b.qloud-c.yandex.net [IPv6:2a02:6b8:c14:2704:0:640:ec30:c78b]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id E393D2E1709 for <openvpn-devel@lists.sourceforge.net>; Thu, 3 Sep 2020 14:45:09 +0300 (MSK) Received: from sas1-58a37b48fb94.qloud-c.yandex.net (sas1-58a37b48fb94.qloud-c.yandex.net [2a02:6b8:c08:1d1b:0:640:58a3:7b48]) by sas1-ec30c78b6c5b.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id 4GXqOr2wYB-j9wCoZ2S; Thu, 03 Sep 2020 14:45:09 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1599133509; bh=Dplh9s8iWVRaIrvwqa5c/Ayo+UCbGfqLjSieG+EAnAY=; h=Message-Id:Date:Subject:To:From; b=GEW/Xka1qZ03l9xtjvXUD/sL6Q0OxJ3ftoFk5BqHjqeOIZgnT5+TJVRvxrk2XaCfw e0MPJKTgTzSrndaHJ777dLUyE4Ec6q/JGgN9nrAhsKu6fTJHdkHSTDis29g5PqvgAY 3cunx827KHUoaKZGmwnEAb71rPjCsr1iRSc9WL2A= Received: from unknown (unknown [178.154.185.164]) by sas1-58a37b48fb94.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id f0LCuCgu0L-j9lWq3I0; Thu, 03 Sep 2020 14:45:09 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Vladislav Grishenko <themiron@yandex-team.ru> To: openvpn-devel@lists.sourceforge.net Date: Thu, 3 Sep 2020 16:44:55 +0500 Message-Id: <20200903114455.29341-1-themiron@yandex-team.ru> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: re.af] -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 X-Headers-End: 1kDng9-00BLj2-S4 Subject: [Openvpn-devel] [PATCH] Fix --remote protocol can't be set without port argument X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] Fix --remote protocol can't be set without port argument
|
|
Commit Message
Vladislav Grishenko
Sept. 3, 2020, 1:44 a.m. UTC
According client-options.rst additional argumets ``port`` and ``proto``
are both optional and it's allowed to have port absent and protocol set:
--remote args
Examples:
remote server.example.net tcp
But when protocol is set without preceeding port argument, it is being
misparsed as a port with subsequent error:
RESOLVE: Cannot resolve host address: server.example.net:tcp
(Servname not supported for ai_socktype)
Since protocol names are predefined and don't match service names, fix
this behavior by checking second argument for valid protocol first.
Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
---
src/openvpn/options.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
Comments
On 03/09/2020 13:44, Vladislav Grishenko wrote: > According client-options.rst additional argumets ``port`` and ``proto`` > are both optional and it's allowed to have port absent and protocol set: > --remote args > Examples: > remote server.example.net tcp > > But when protocol is set without preceeding port argument, it is being > misparsed as a port with subsequent error: > RESOLVE: Cannot resolve host address: server.example.net:tcp > (Servname not supported for ai_socktype) > > Since protocol names are predefined and don't match service names, fix > this behavior by checking second argument for valid protocol first. > > Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Uhm ... I'm leaning towards a NAK to this patch and would rather suggest updating the man page to be correct. This is a mistake from my side when converting the man page to .rst files. The example should be: remote server.example.net 1194 tcp The OpenVPN 2.4 and prior releases has this line: --remote host [port] [proto] But this syntax was not supported by rst2man, so it was replaced with "args" and the examples coming below; which carried an error.
Hi David, > -----Original Message----- > From: David Sommerseth <openvpn@sf.lists.topphemmelig.net> > Sent: Tuesday, September 8, 2020 6:23 PM > To: Vladislav Grishenko <themiron@yandex-team.ru>; openvpn- > devel@lists.sourceforge.net > Subject: Re: [Openvpn-devel] [PATCH] Fix --remote protocol can't be set without > port argument > > On 03/09/2020 13:44, Vladislav Grishenko wrote: > > According client-options.rst additional argumets ``port`` and > > ``proto`` are both optional and it's allowed to have port absent and protocol > set: > > --remote args > > Examples: > > remote server.example.net tcp > > > > But when protocol is set without preceeding port argument, it is being > > misparsed as a port with subsequent error: > > RESOLVE: Cannot resolve host address: server.example.net:tcp > > (Servname not supported for ai_socktype) > > > > Since protocol names are predefined and don't match service names, fix > > this behavior by checking second argument for valid protocol first. > > > Uhm ... I'm leaning towards a NAK to this patch and would rather suggest > updating the man page to be correct. This is a mistake from my side when > converting the man page to .rst files. The example should be: > > remote server.example.net 1194 tcp > Hum. Initially all variants were supported, by checking numeric port and taking it as proto, if not numeric. Later port became string servname and optional logic was lost. Man pages still has all of them since that time: remote server.exmaple.net remote server.exmaple.net 1194 remote server.exmaple.net tcp At first look there is no need for proto w/o port set, why it can be important? With support of server host & port discovery (DNS SRV RFC 2782), port info is not required, only host and protocol make sense. So I though about this one little step forward toward ~consistent syntax. Does it makes any sense? > The OpenVPN 2.4 and prior releases has this line: > > --remote host [port] [proto] > > But this syntax was not supported by rst2man, so it was replaced with "args" > and the examples coming below; which carried an error. > > > -- > kind regards, > > David Sommerseth > OpenVPN Inc >
On 08/09/2020 21:01, Vladislav Grishenko wrote: > Hi David, > >> -----Original Message----- >> From: David Sommerseth <openvpn@sf.lists.topphemmelig.net> >> Sent: Tuesday, September 8, 2020 6:23 PM >> To: Vladislav Grishenko <themiron@yandex-team.ru>; openvpn- >> devel@lists.sourceforge.net >> Subject: Re: [Openvpn-devel] [PATCH] Fix --remote protocol can't be set without >> port argument >> >> On 03/09/2020 13:44, Vladislav Grishenko wrote: >>> According client-options.rst additional argumets ``port`` and >>> ``proto`` are both optional and it's allowed to have port absent and protocol >> set: >>> --remote args >>> Examples: >>> remote server.example.net tcp >>> >>> But when protocol is set without preceeding port argument, it is being >>> misparsed as a port with subsequent error: >>> RESOLVE: Cannot resolve host address: server.example.net:tcp >>> (Servname not supported for ai_socktype) >>> >>> Since protocol names are predefined and don't match service names, fix >>> this behavior by checking second argument for valid protocol first. >>> >> Uhm ... I'm leaning towards a NAK to this patch and would rather suggest >> updating the man page to be correct. This is a mistake from my side when >> converting the man page to .rst files. The example should be: >> >> remote server.example.net 1194 tcp >> > > Hum. Initially all variants were supported, by checking numeric port and > taking it as proto, if not numeric. Later port became string servname and > optional logic was lost. The man page history disagrees ... even though, it doesn't say this order is explicit. 2.4 - <https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage#lbAG> 2.3 - <https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage#lbAG> 2.2 - <https://community.openvpn.net/openvpn/wiki/Openvpn22ManPage> 2.1 - <https://community.openvpn.net/openvpn/wiki/Openvpn21ManPage#lbAG> > Man pages still has all of them since that time: >> remote server.exmaple.net >> remote server.exmaple.net 1194 >> remote server.exmaple.net tcp These lines comes from this commit: <https://github.com/OpenVPN/openvpn/commit/f500c49c8e0a77ce665b11f6adbea4029cf3b85f> Where the last line (missing port number) is incorrect. I also don't see any commit changing the "remote" parsing in options.c in the way you describe. This section has just few changes over the years, but even back to changes 7-12 years ago, the second argument has always been processed as a port number and the third one protocol. Both causing an error if it is not a valid value. So putting protocol in the second argument would trigger an error in 2.1, 2.2, 2.3 and 2.4 as far as I can see. > > At first look there is no need for proto w/o port set, why it can be > important? With support of server host & port discovery (DNS SRV RFC 2782), > port info is not required, only host and protocol make sense. So I though > about this one little step forward toward ~consistent syntax. Does it makes > any sense? I don't see why OpenVPN's --remote parsing needs to comply with DNS SRV RFC standards. How is that related at all? I know we have patches for adding DNS SRV query support, but that doesn't imply passing this information via add_option(), does it? If you use --remote vpn.example.com --proto tcp .... that will already work. What will not work is --remote vpn.example.com tcp Also, this will work in config files: ------------------------------- port 5000 proto udp <connection> remote vpn1.example.com </connection> <connetion> remote vpn2.example.com proto tcp </connection> ------------------------------- All of these use cases makes sense, as it depends on a pre-set value. What does not make sense to me is to muddy a pretty clearly defined argument order which has been the standard since the beginning of OpenVPN.
Ok, thank you for clarification -- Best Regards, Vladislav Grishenko > -----Original Message----- > From: David Sommerseth <openvpn@sf.lists.topphemmelig.net> > Sent: Wednesday, September 9, 2020 10:49 PM > To: Vladislav Grishenko <themiron.ru@gmail.com>; openvpn- > devel@lists.sourceforge.net > Subject: Re: [Openvpn-devel] [PATCH] Fix --remote protocol can't be set without > port argument > > On 08/09/2020 21:01, Vladislav Grishenko wrote: > > Hi David, > > > >> -----Original Message----- > >> From: David Sommerseth <openvpn@sf.lists.topphemmelig.net> > >> Sent: Tuesday, September 8, 2020 6:23 PM > >> To: Vladislav Grishenko <themiron@yandex-team.ru>; openvpn- > >> devel@lists.sourceforge.net > >> Subject: Re: [Openvpn-devel] [PATCH] Fix --remote protocol can't be > >> set without port argument > >> > >> On 03/09/2020 13:44, Vladislav Grishenko wrote: > >>> According client-options.rst additional argumets ``port`` and > >>> ``proto`` are both optional and it's allowed to have port absent and > >>> protocol > >> set: > >>> --remote args > >>> Examples: > >>> remote server.example.net tcp > >>> > >>> But when protocol is set without preceeding port argument, it is > >>> being misparsed as a port with subsequent error: > >>> RESOLVE: Cannot resolve host address: server.example.net:tcp > >>> (Servname not supported for ai_socktype) > >>> > >>> Since protocol names are predefined and don't match service names, > >>> fix this behavior by checking second argument for valid protocol first. > >>> > >> Uhm ... I'm leaning towards a NAK to this patch and would rather > >> suggest updating the man page to be correct. This is a mistake from > >> my side when converting the man page to .rst files. The example should be: > >> > >> remote server.example.net 1194 tcp > >> > > > > Hum. Initially all variants were supported, by checking numeric port > > and taking it as proto, if not numeric. Later port became string > > servname and optional logic was lost. > > The man page history disagrees ... even though, it doesn't say this order is > explicit. > > 2.4 - > <https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage#lbAG> > 2.3 - > <https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage#lbAG> > 2.2 - <https://community.openvpn.net/openvpn/wiki/Openvpn22ManPage> > 2.1 - > <https://community.openvpn.net/openvpn/wiki/Openvpn21ManPage#lbAG> > > > Man pages still has all of them since that time: > >> remote server.exmaple.net > >> remote server.exmaple.net 1194 > >> remote server.exmaple.net tcp > > These lines comes from this commit: > <https://github.com/OpenVPN/openvpn/commit/f500c49c8e0a77ce665b11f6a > dbea4029cf3b85f> > > Where the last line (missing port number) is incorrect. > > I also don't see any commit changing the "remote" parsing in options.c in the > way you describe. This section has just few changes over the years, but even > back to changes 7-12 years ago, the second argument has always been > processed as a port number and the third one protocol. Both causing an error if > it is not a valid value. So putting protocol in the second argument would trigger > an error in 2.1, 2.2, 2.3 and 2.4 as far as I can see. > > > > > At first look there is no need for proto w/o port set, why it can be > > important? With support of server host & port discovery (DNS SRV RFC > > 2782), port info is not required, only host and protocol make sense. > > So I though about this one little step forward toward ~consistent > > syntax. Does it makes any sense? > I don't see why OpenVPN's --remote parsing needs to comply with DNS SRV RFC > standards. How is that related at all? I know we have patches for adding DNS > SRV query support, but that doesn't imply passing this information via > add_option(), does it? > > If you use --remote vpn.example.com --proto tcp .... that will already work. > What will not work is --remote vpn.example.com tcp > > Also, this will work in config files: > ------------------------------- > port 5000 > proto udp > > <connection> > remote vpn1.example.com > </connection> > <connetion> > remote vpn2.example.com > proto tcp > </connection> > ------------------------------- > > All of these use cases makes sense, as it depends on a pre-set value. What does > not make sense to me is to muddy a pretty clearly defined argument order which > has been the standard since the beginning of OpenVPN. > > > -- > kind regards, > > David Sommerseth > OpenVPN Inc >
diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 8bf82c57..02ac08d8 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5682,16 +5682,26 @@ add_option(struct options *options, re.remote = p[1]; if (p[2]) { - re.remote_port = p[2]; - if (p[3]) + /* Since port is optional, second parameter can be a protocol */ + int proto = ascii2proto(p[2]); + sa_family_t af = ascii2af(p[2]); + if (proto < 0) { - const int proto = ascii2proto(p[3]); - const sa_family_t af = ascii2af(p[3]); - if (proto < 0) + /* Second is not proto, port then. Protocol should be third */ + re.remote_port = p[2]; + if (p[3]) { - msg(msglevel, "remote: bad protocol associated with host %s: '%s'", p[1], p[3]); - goto err; + proto = ascii2proto(p[3]); + af = ascii2af(p[3]); + if (proto < 0) + { + msg(msglevel, "remote: bad protocol associated with host %s: '%s'", p[1], p[3]); + goto err; + } } + } + if (proto >= 0) + { re.proto = proto; re.af = af; }