Date: Thu, 21 Sep 2000 15:43:52 +0200 (CEST) From: Philipp Mergenthaler <p@i609.hadiko.de> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/21449: [PATCH] Sysinstall, installing via HTTP proxy: Fix locating the release directory; fix server name resolving Message-ID: <200009211343.e8LDhq802141@i609.hadiko.de>
next in thread | raw e-mail | index | archive | help
>Number: 21449 >Category: bin >Synopsis: [PATCH] Sysinstall, installing via HTTP proxy: Fix locating the release directory; fix server name resolving >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 21 06:50:03 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Philipp Mergenthaler >Release: FreeBSD 5.0-CURRENT i386 >Organization: University of Karlsruhe >Environment: http.c as of 2000-09-21 $FreeBSD: src/release/sysinstall/media.c,v 1.111 2000/08/03 02:51:45 jkh Exp $ $FreeBSD: src/release/sysinstall/sysinstall.h,v 1.194 2000/07/24 18:00:16 jkh Exp $ >Description: 1) Installing via HTTP proxy ( mediaSetHTTP() ) relies on mediaSetFTP(). It's broken right now because the method of looking up the correct directory on the FTP server was changed in version 1.39 of ftp.c. This has to be changed in http.c, too. I only look for one path (pub/FreeBSD/releases/MACHINE), though. 2) The issue that the FTP server's name should be resolved by the proxy: The current fix unsets VAR_NAMESERVER before calling mediaSetFTP(). But in a normal install, the network hasn't been set up at this time. Therefore, mediaSetFTP() will call tcpDeviceSelect() which sets VAR_NAMESERVER. Therefore the unwanted lookup takes place. >How-To-Repeat: 1) Try to install via an HTTP proxy. 2) Select "HTTP proxy" as installation medium. _Don't_ skip over the network setup, do it (again). Note the "Looking up host" message. >Fix: 0) In media.c and sysinstall.h, change VAR_HTTP_PATH to VAR_HTTP_PROXY (it holds the proxy's name and port). VAR_HTTP_PATH is now analogous to VAR_FTP_PATH. 1) In http.c, correct setting the path. Check if it's actually found on the FTP server. 2) In media.c, introduce a variable to explicitly signal that the server's name shouldn't be resolved. diff -ru -2 sysinstall/http.c sysinstall.new/http.c --- sysinstall/http.c Fri Jul 14 10:33:08 2000 +++ sysinstall.new/http.c Thu Sep 21 14:39:00 2000 @@ -19,6 +19,6 @@ int rv, s, af; - bool el; /* end of header line */ - char *cp, buf[PATH_MAX], req[BUFSIZ]; + bool el, found=FALSE; /* end of header line */ + char *cp, *rel, buf[PATH_MAX], req[BUFSIZ]; struct addrinfo hints, *res, *res0; @@ -49,6 +49,21 @@ return FALSE; } + /* If the release is specified as "__RELEASE" or "none", then just + * assume that the path the user gave is ok. + */ + rel = variable_get(VAR_RELNAME); + /* + msgConfirm("rel: -%s-", rel); + */ + if (strcmp(rel, "__RELEASE") && strcmp(rel, "none")) { + sprintf(req, "%s/pub/FreeBSD/releases/"MACHINE"/%s", + variable_get(VAR_FTP_PATH), rel); + variable_set2(VAR_HTTP_PATH, req, 0); + } else { + variable_set2(VAR_HTTP_PATH, variable_get(VAR_FTP_PATH), 0); + } - sprintf(req,"GET / HTTP/1.0\r\n\r\n"); + msgNotify("Checking access to\n %s", variable_get(VAR_HTTP_PATH)); + sprintf(req,"HEAD %s/ HTTP/1.0\r\n\r\n", variable_get(VAR_HTTP_PATH)); write(s,req,strlen(req)); /* @@ -64,4 +79,10 @@ if ((*cp == '\012') && el) { /* reached end of a header line */ + if (!strncmp(buf,"HTTP",4)) { + if (strtol((char *)(buf+9),0,0) == 200) { + found = TRUE; + } + } + if (!strncmp(buf,"Server: ",8)) { if (!strncmp(buf,"Server: Squid",13)) { @@ -86,5 +107,8 @@ } close(s); - return TRUE; + if (!found) + msgConfirm("No such directory: %s\n" + "please check the URL and try again.", variable_get(VAR_HTTP_PATH)); + return found; } @@ -126,7 +150,6 @@ } - sprintf(req,"GET %s/%s/%s%s HTTP/1.0\r\n\r\n", - variable_get(VAR_FTP_PATH), variable_get(VAR_RELNAME), - file, variable_get(VAR_HTTP_FTP_MODE)); + sprintf(req,"GET %s/%s%s HTTP/1.0\r\n\r\n", + variable_get(VAR_HTTP_PATH), file, variable_get(VAR_HTTP_FTP_MODE)); if (isDebug()) { diff -ru -2 sysinstall/media.c sysinstall.new/media.c --- sysinstall/media.c Thu Sep 21 13:54:07 2000 +++ sysinstall.new/media.c Thu Sep 21 15:32:42 2000 @@ -51,4 +51,5 @@ static Boolean got_intr = FALSE; +static Boolean ftp_skip_resolve = FALSE; /* timeout handler */ @@ -393,5 +394,5 @@ msgDebug("port # = `%d'\n", FtpPort); } - if (variable_get(VAR_NAMESERVER)) { + if (!ftp_skip_resolve && variable_get(VAR_NAMESERVER)) { msgNotify("Looking up host %s.", hostname); if (isDebug()) @@ -453,20 +454,20 @@ int mediaSetHTTP(dialogMenuItem *self) { + Boolean tmp; int result; - char *cp, *idx, hbuf[MAXHOSTNAMELEN], *hostname, *var_hostname; + char *cp, *idx, hbuf[MAXHOSTNAMELEN], *hostname; int HttpPort; int what = DITEM_RESTORE; - var_hostname = variable_get(VAR_NAMESERVER); - variable_unset(VAR_NAMESERVER); + tmp = ftp_skip_resolve; + ftp_skip_resolve = TRUE; result = mediaSetFTP(self); - if (var_hostname) - variable_set2(VAR_NAMESERVER, var_hostname, 0); + ftp_skip_resolve = tmp; if (DITEM_STATUS(result) != DITEM_SUCCESS) return result; - cp = variable_get_value(VAR_HTTP_PATH, + cp = variable_get_value(VAR_HTTP_PROXY, "Please enter the address of the HTTP proxy in this format:\n" " hostname:port (the ':port' is optional, default is 3128)",0); diff -ru -2 sysinstall/sysinstall.h sysinstall.new/sysinstall.h --- sysinstall/sysinstall.h Thu Jul 27 10:38:54 2000 +++ sysinstall.new/sysinstall.h Thu Sep 21 14:39:00 2000 @@ -113,4 +113,5 @@ #define VAR_FTP_HOST "ftpHost" #define VAR_HTTP_PATH "_httpPath" +#define VAR_HTTP_PROXY "httpProxy" #define VAR_HTTP_PORT "httpPort" #define VAR_HTTP_HOST "httpHost" >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009211343.e8LDhq802141>