Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cXjKL-0005pf-Ej for mharc-grub-devel@gnu.org; Sun, 29 Jan 2017 01:51:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXjKI-0005pS-WA for grub-devel@gnu.org; Sun, 29 Jan 2017 01:51:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXjKF-0005Bc-UQ for grub-devel@gnu.org; Sun, 29 Jan 2017 01:51:03 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:36140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXjKF-0005BV-Lg for grub-devel@gnu.org; Sun, 29 Jan 2017 01:50:59 -0500 Received: by mail-lf0-x243.google.com with SMTP id h65so28876368lfi.3 for ; Sat, 28 Jan 2017 22:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=/UrH4+ggmr2NWYONbW3z/P1wjbNO575DvvjPQnGJTZ0=; b=i8B5r/9h+Ed1AgCzFLFofvifwLi/SyMj021iC/JlQplG7S6IMemtH+2VHHF+2Zov22 RC1jmsVbqxnhShPODc5bnEYFKHYDxiRRgzw89UkVMCXfdHcsqyAAEwF4/JcpXp2V6W6M t3x8jXm5PWJQM9LKJA8RO9Fcl2f7RhsDWw3SiE9CZA3hC5aYnxMc5+HxhAmIBAWDrue9 KSR3m+cWa3MXZb1V5W5ejhgC7Mr1oBTH06EkW/agJJnqpqftfZEsvVeVStaB7syRrW+K jvGs+I+spTGg5t9hsoqYP089lgu49bO2Z8C8u3bXU/rPornBegIrfZBS5W2y86U2lFQx ZGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=/UrH4+ggmr2NWYONbW3z/P1wjbNO575DvvjPQnGJTZ0=; b=UYzBylxukJ16Tz9NE1HVHI3/voquNWmSAE6uvUofU7yQvaGWWhQphuKhAaIBa8J/f4 JKwehUeNNXQLyZxQKJGqZLboRQy75J4bUIiwP9lM6I74YUe0gRIbJLbdwuCYkgZMumdz u1KjHVoPSQ+NQSftEu13cJc9/XXmR2wJbp59VQsLmLu+lgNZY/PgnjMta73MP2eAYyUl 2uKQ7Db4j1Zc2+OLlX/lRH11iLOKl1ttxAlVsUsqyeVq3KH1hYxNRsc9MTJR3OAor95i G3m5SrvuDyLMu26gn1nFNJNr+s9UR9CaeltVZUKiCt6bSrQ6h+Qme1ANBjTp3W4OBAVr QADg== X-Gm-Message-State: AIkVDXIWCz8m0NSciU2p3gc58B1sdWdP2pN2G8290vI3j0u46soANMsRqz9cbfuEBOYlrA== X-Received: by 10.25.137.193 with SMTP id l184mr4431578lfd.31.1485672656783; Sat, 28 Jan 2017 22:50:56 -0800 (PST) Received: from [192.168.1.3] (ppp109-252-90-129.pppoe.spdop.ru. [109.252.90.129]) by smtp.gmail.com with ESMTPSA id 25sm2627934ljo.43.2017.01.28.22.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jan 2017 22:50:55 -0800 (PST) Subject: Re: [PATCH 1/4] Allow non-default ports for HTTP requests To: The development of GNU GRUB References: <20170124003601.24612-1-mjg59@coreos.com> <20170124003601.24612-2-mjg59@coreos.com> Cc: Matthew Garrett From: Andrei Borzenkov Message-ID: <8091b9ae-a898-b4a0-3a20-5d1d38ad3552@gmail.com> Date: Sun, 29 Jan 2017 09:50:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170124003601.24612-2-mjg59@coreos.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::243 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jan 2017 06:51:04 -0000 24.01.2017 03:35, Matthew Garrett пишет: > Add support for passing ports in HTTP requests. This takes the form of: > (http,serverip:portnum)/file > --- > grub-core/net/http.c | 8 ++++++-- > grub-core/net/net.c | 10 +++++++++- > include/grub/net.h | 1 + > 3 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/grub-core/net/http.c b/grub-core/net/http.c > index 5aa4ad3..389a78e 100644 > --- a/grub-core/net/http.c > +++ b/grub-core/net/http.c > @@ -309,7 +309,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) > { > http_data_t data = file->data; > grub_uint8_t *ptr; > - int i; > + int i, port; > struct grub_net_buff *nb; > grub_err_t err; > > @@ -390,8 +390,12 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) > grub_netbuff_put (nb, 2); > grub_memcpy (ptr, "\r\n", 2); > > + if (file->device->net->port) 0 is valid port number (at least I am not aware of any RFC that prohibits its use). > + port = file->device->net->port; > + else > + port = HTTP_PORT; > data->sock = grub_net_tcp_open (file->device->net->server, > - HTTP_PORT, http_receive, > + port, http_receive, > http_err, http_err, > file); > if (!data->sock) > diff --git a/grub-core/net/net.c b/grub-core/net/net.c > index 10773fc..585f4f7 100644 > --- a/grub-core/net/net.c > +++ b/grub-core/net/net.c > @@ -1261,7 +1261,7 @@ grub_net_open_real (const char *name) > grub_net_app_level_t proto; > const char *protname, *server; > grub_size_t protnamelen; > - int try; > + int try, port = 0; > > if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) > { > @@ -1278,7 +1278,14 @@ grub_net_open_real (const char *name) > else > { > const char *comma; > + char *colon; > comma = grub_strchr (name, ','); > + colon = grub_strchr (name, ':'); This conflicts with IPv6 addresses. Similar patches were already posted. I suggested using (proto,server,port). This also allows empty server and still using non-standard port. More general at some point we should hit authentication, and so may need to stuff user/password there. So we need to come up with extensible framework. Putting everything in "server" string may work, but then we need to support IPv6 literals here - [fe80::1]:444 - at least, this is the only way to use server:port I see. Also, we probably need to support escaping of colons. Finally, speaking about user/password, we may need to support user:password@[fe80::1]:456 May be using (net,proto=http,server=xxx,port=yyy,user=uuu,...) which allows adding arbitrary keywords at any time.