summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2000-12-06 00:47:54 +0000
committerjkh <jkh@FreeBSD.org>2000-12-06 00:47:54 +0000
commitd59144ac986fe8b15c85ac69762a63e26755f2b6 (patch)
tree29d0efaca3d6681aecd95c9dfee78bb548bf9aa1
parent2d9ab1884912c95652c1b52b3183db73d9451769 (diff)
downloadFreeBSD-src-d59144ac986fe8b15c85ac69762a63e26755f2b6.zip
FreeBSD-src-d59144ac986fe8b15c85ac69762a63e26755f2b6.tar.gz
Enable the same path deduction as for ftp install (great for snapshot tests)
Allow user to change proxy server Allow user to change ftp path Submitted by: pho
-rw-r--r--release/sysinstall/ftp.c2
-rw-r--r--release/sysinstall/http.c77
-rw-r--r--usr.sbin/sysinstall/ftp.c2
-rw-r--r--usr.sbin/sysinstall/http.c77
4 files changed, 120 insertions, 38 deletions
diff --git a/release/sysinstall/ftp.c b/release/sysinstall/ftp.c
index ef602d5..0adfcd2 100644
--- a/release/sysinstall/ftp.c
+++ b/release/sysinstall/ftp.c
@@ -49,7 +49,7 @@ static FILE *OpenConn;
int FtpPort;
/* List of sub directories to look for under a given FTP server. */
-static const char *ftp_dirs[] = { ".", "releases/"MACHINE, "snapshots/"MACHINE,
+const char *ftp_dirs[] = { ".", "releases/"MACHINE, "snapshots/"MACHINE,
"pub/FreeBSD", "pub/FreeBSD/releases/"MACHINE,
"pub/FreeBSD/snapshots/"MACHINE, NULL };
diff --git a/release/sysinstall/http.c b/release/sysinstall/http.c
index dc9d687..9db03dd 100644
--- a/release/sysinstall/http.c
+++ b/release/sysinstall/http.c
@@ -5,8 +5,10 @@
#include <sys/param.h>
#include <netdb.h>
+extern const char *ftp_dirs[]; /* defined in ftp.c */
+
Boolean
-mediaInitHTTP(Device *dev)
+checkAccess(Boolean proxyCheckOnly)
{
/*
* Some proxies fetch files with certain extensions in "ascii mode" instead
@@ -19,7 +21,7 @@ mediaInitHTTP(Device *dev)
int rv, s, af;
bool el, found=FALSE; /* end of header line */
- char *cp, *rel, buf[PATH_MAX], req[BUFSIZ];
+ char *cp, buf[PATH_MAX], req[BUFSIZ];
struct addrinfo hints, *res, *res0;
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
@@ -30,6 +32,7 @@ mediaInitHTTP(Device *dev)
if ((rv = getaddrinfo(variable_get(VAR_HTTP_HOST),
variable_get(VAR_HTTP_PORT), &hints, &res0)) != 0) {
msgConfirm("%s", gai_strerror(rv));
+ variable_unset(VAR_HTTP_HOST);
return FALSE;
}
s = -1;
@@ -46,21 +49,12 @@ mediaInitHTTP(Device *dev)
if (s == -1) {
msgConfirm("Couldn't connect to proxy %s:%s",
variable_get(VAR_HTTP_HOST),variable_get(VAR_HTTP_PORT));
+ variable_unset(VAR_HTTP_HOST);
return FALSE;
}
- /* If the release is specified as "__RELEASE" or "any", 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, "any")) {
- 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);
+ if (proxyCheckOnly) {
+ close(s);
+ return TRUE;
}
msgNotify("Checking access to\n %s", variable_get(VAR_HTTP_PATH));
@@ -71,6 +65,7 @@ mediaInitHTTP(Device *dev)
* this is extremely quick'n dirty
*
*/
+ bzero(buf, PATH_MAX);
cp=buf;
el=FALSE;
rv=read(s,cp,1);
@@ -106,12 +101,58 @@ mediaInitHTTP(Device *dev)
}
}
close(s);
- if (!found)
- msgConfirm("No such directory: %s\n"
- "please check the URL and try again.", variable_get(VAR_HTTP_PATH));
return found;
}
+Boolean
+mediaInitHTTP(Device *dev)
+{
+ bool found=FALSE; /* end of header line */
+ char *rel, req[BUFSIZ];
+ int fdir;
+
+ /*
+ * First verify the proxy access
+ */
+ checkAccess(TRUE);
+ while (variable_get(VAR_HTTP_HOST) == NULL) {
+ if (DITEM_STATUS(mediaSetHTTP(NULL)) == DITEM_FAILURE)
+ return FALSE;
+ checkAccess(TRUE);
+ }
+again:
+ /* If the release is specified as "__RELEASE" or "any", 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, "any")) {
+ for (fdir = 0; ftp_dirs[fdir]; fdir++) {
+ sprintf(req, "%s/%s/%s", variable_get(VAR_FTP_PATH),
+ ftp_dirs[fdir], rel);
+ variable_set2(VAR_HTTP_PATH, req, 0);
+ if (checkAccess(FALSE)) {
+ found = TRUE;
+ break;
+ }
+ }
+ } else {
+ variable_set2(VAR_HTTP_PATH, variable_get(VAR_FTP_PATH), 0);
+ found = checkAccess(FALSE);
+ }
+ if (!found) {
+ msgConfirm("No such directory: %s\n"
+ "please check the URL and try again.", variable_get(VAR_HTTP_PATH));
+ variable_unset(VAR_HTTP_PATH);
+ dialog_clear_norefresh();
+ clear();
+ if (DITEM_STATUS(mediaSetHTTP(NULL)) != DITEM_FAILURE) goto again;
+ }
+ return found;
+}
FILE *
mediaGetHTTP(Device *dev, char *file, Boolean probe)
diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c
index ef602d5..0adfcd2 100644
--- a/usr.sbin/sysinstall/ftp.c
+++ b/usr.sbin/sysinstall/ftp.c
@@ -49,7 +49,7 @@ static FILE *OpenConn;
int FtpPort;
/* List of sub directories to look for under a given FTP server. */
-static const char *ftp_dirs[] = { ".", "releases/"MACHINE, "snapshots/"MACHINE,
+const char *ftp_dirs[] = { ".", "releases/"MACHINE, "snapshots/"MACHINE,
"pub/FreeBSD", "pub/FreeBSD/releases/"MACHINE,
"pub/FreeBSD/snapshots/"MACHINE, NULL };
diff --git a/usr.sbin/sysinstall/http.c b/usr.sbin/sysinstall/http.c
index dc9d687..9db03dd 100644
--- a/usr.sbin/sysinstall/http.c
+++ b/usr.sbin/sysinstall/http.c
@@ -5,8 +5,10 @@
#include <sys/param.h>
#include <netdb.h>
+extern const char *ftp_dirs[]; /* defined in ftp.c */
+
Boolean
-mediaInitHTTP(Device *dev)
+checkAccess(Boolean proxyCheckOnly)
{
/*
* Some proxies fetch files with certain extensions in "ascii mode" instead
@@ -19,7 +21,7 @@ mediaInitHTTP(Device *dev)
int rv, s, af;
bool el, found=FALSE; /* end of header line */
- char *cp, *rel, buf[PATH_MAX], req[BUFSIZ];
+ char *cp, buf[PATH_MAX], req[BUFSIZ];
struct addrinfo hints, *res, *res0;
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
@@ -30,6 +32,7 @@ mediaInitHTTP(Device *dev)
if ((rv = getaddrinfo(variable_get(VAR_HTTP_HOST),
variable_get(VAR_HTTP_PORT), &hints, &res0)) != 0) {
msgConfirm("%s", gai_strerror(rv));
+ variable_unset(VAR_HTTP_HOST);
return FALSE;
}
s = -1;
@@ -46,21 +49,12 @@ mediaInitHTTP(Device *dev)
if (s == -1) {
msgConfirm("Couldn't connect to proxy %s:%s",
variable_get(VAR_HTTP_HOST),variable_get(VAR_HTTP_PORT));
+ variable_unset(VAR_HTTP_HOST);
return FALSE;
}
- /* If the release is specified as "__RELEASE" or "any", 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, "any")) {
- 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);
+ if (proxyCheckOnly) {
+ close(s);
+ return TRUE;
}
msgNotify("Checking access to\n %s", variable_get(VAR_HTTP_PATH));
@@ -71,6 +65,7 @@ mediaInitHTTP(Device *dev)
* this is extremely quick'n dirty
*
*/
+ bzero(buf, PATH_MAX);
cp=buf;
el=FALSE;
rv=read(s,cp,1);
@@ -106,12 +101,58 @@ mediaInitHTTP(Device *dev)
}
}
close(s);
- if (!found)
- msgConfirm("No such directory: %s\n"
- "please check the URL and try again.", variable_get(VAR_HTTP_PATH));
return found;
}
+Boolean
+mediaInitHTTP(Device *dev)
+{
+ bool found=FALSE; /* end of header line */
+ char *rel, req[BUFSIZ];
+ int fdir;
+
+ /*
+ * First verify the proxy access
+ */
+ checkAccess(TRUE);
+ while (variable_get(VAR_HTTP_HOST) == NULL) {
+ if (DITEM_STATUS(mediaSetHTTP(NULL)) == DITEM_FAILURE)
+ return FALSE;
+ checkAccess(TRUE);
+ }
+again:
+ /* If the release is specified as "__RELEASE" or "any", 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, "any")) {
+ for (fdir = 0; ftp_dirs[fdir]; fdir++) {
+ sprintf(req, "%s/%s/%s", variable_get(VAR_FTP_PATH),
+ ftp_dirs[fdir], rel);
+ variable_set2(VAR_HTTP_PATH, req, 0);
+ if (checkAccess(FALSE)) {
+ found = TRUE;
+ break;
+ }
+ }
+ } else {
+ variable_set2(VAR_HTTP_PATH, variable_get(VAR_FTP_PATH), 0);
+ found = checkAccess(FALSE);
+ }
+ if (!found) {
+ msgConfirm("No such directory: %s\n"
+ "please check the URL and try again.", variable_get(VAR_HTTP_PATH));
+ variable_unset(VAR_HTTP_PATH);
+ dialog_clear_norefresh();
+ clear();
+ if (DITEM_STATUS(mediaSetHTTP(NULL)) != DITEM_FAILURE) goto again;
+ }
+ return found;
+}
FILE *
mediaGetHTTP(Device *dev, char *file, Boolean probe)
OpenPOWER on IntegriCloud