From 25e8002737c31072f7d2292a7bf085b4191c8f18 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 25 Aug 2014 16:07:47 +0200 Subject: [PATCH] fetch: hardcode HTTPS port and fallback to /etc/services for other unknown ports. --- NEWS | 3 +++ lib/fetch/common.c | 6 ++++-- lib/fetch/common.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index afea5829..8a4e3d82 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.38 (???): + * libxbps: the fetch code now is able to connect to HTTPS without the need of + /etc/services being available; We don't expect those ports to change anytime! + * xbps-uchroot(8) is now only built on linux, because it's not portable to other Operating Systems. diff --git a/lib/fetch/common.c b/lib/fetch/common.c index 60b13671..705c843a 100644 --- a/lib/fetch/common.c +++ b/lib/fetch/common.c @@ -201,12 +201,14 @@ fetch_default_port(const char *scheme) { struct servent *se; - if ((se = getservbyname(scheme, "tcp")) != NULL) - return (ntohs(se->s_port)); if (strcasecmp(scheme, SCHEME_FTP) == 0) return (FTP_DEFAULT_PORT); if (strcasecmp(scheme, SCHEME_HTTP) == 0) return (HTTP_DEFAULT_PORT); + if (strcasecmp(scheme, SCHEME_HTTPS) == 0) + return (HTTPS_DEFAULT_PORT); + if ((se = getservbyname(scheme, "tcp")) != NULL) + return (ntohs(se->s_port)); return (0); } diff --git a/lib/fetch/common.h b/lib/fetch/common.h index 63170907..2c363217 100644 --- a/lib/fetch/common.h +++ b/lib/fetch/common.h @@ -34,6 +34,7 @@ #define FTP_DEFAULT_PORT 21 #define HTTP_DEFAULT_PORT 80 +#define HTTPS_DEFAULT_PORT 443 #define FTP_DEFAULT_PROXY_PORT 21 #define HTTP_DEFAULT_PROXY_PORT 3128