From 7ec94d00be14347c3957c59ad478314ccdb63448 Mon Sep 17 00:00:00 2001 From: jkh Date: Tue, 4 Jan 2000 04:50:07 +0000 Subject: Add support for FTP installation via HTTP proxies. Submitted by: Philipp Mergenthaler PR: 11316 --- usr.sbin/sysinstall/Makefile | 2 +- usr.sbin/sysinstall/dispatch.c | 1 + usr.sbin/sysinstall/media.c | 43 ++++++++++++++++++++++++++++++++++++++++ usr.sbin/sysinstall/menus.c | 2 ++ usr.sbin/sysinstall/sysinstall.h | 10 ++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) (limited to 'usr.sbin/sysinstall') diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile index 609ef7b..f6dc252 100644 --- a/usr.sbin/sysinstall/Makefile +++ b/usr.sbin/sysinstall/Makefile @@ -11,7 +11,7 @@ CLEANFILES+= keymap.tmp keymap.h pccard_conf.h SRCS= anonFTP.c cdrom.c command.c config.c devices.c dhcp.c kget.c \ disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \ - ftp.c globals.c index.c install.c installUpgrade.c keymap.c \ + ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \ label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \ msg.c network.c nfs.c options.c package.c pccard.c \ system.c tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \ diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c index 15c6c27..811bae5 100644 --- a/usr.sbin/sysinstall/dispatch.c +++ b/usr.sbin/sysinstall/dispatch.c @@ -99,6 +99,7 @@ static struct _word { { "mediaSetFTP", mediaSetFTP }, { "mediaSetFTPActive", mediaSetFTPActive }, { "mediaSetFTPPassive", mediaSetFTPPassive }, + { "mediaSetHTTP", mediaSetHTTP }, { "mediaSetUFS", mediaSetUFS }, { "mediaSetNFS", mediaSetNFS }, { "mediaSetFTPUserPass", mediaSetFTPUserPass }, diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 2ca3ea5..960e669 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -433,6 +433,49 @@ mediaSetFTPPassive(dialogMenuItem *self) return mediaSetFTP(self); } +int mediaSetHTTP(dialogMenuItem *self) +{ + int result; + char *cp, *idx, hostname[MAXHOSTNAMELEN]; + extern int HttpPort; + int what = DITEM_RESTORE; + + + result = mediaSetFTP(self); + if (DITEM_STATUS(result) != DITEM_SUCCESS) + return result; + + variable_set2(VAR_HTTP_PATH, "", 0); + cp = variable_get_value(VAR_HTTP_PATH, + "Please enter the address of the HTTP proxy in this format:\n" + " hostname:port (the ':port' is optional, default is 3128)",0); + if (!cp) + return DITEM_FAILURE; + SAFE_STRCPY(hostname, cp); + if (!(idx = index(hostname, ':'))) + HttpPort = 3128; /* try this as default */ + else { + *(idx++) = '\0'; + HttpPort = strtol(idx, 0, 0); + } + + variable_set2(VAR_HTTP_HOST, hostname, 0); + variable_set2(VAR_HTTP_PORT, itoa(HttpPort), 0); + msgDebug("VAR_HTTP_HOST, _PORT: %s:%s",variable_get(VAR_HTTP_HOST), + variable_get(VAR_HTTP_PORT)); + + msgDebug("VAR_FTP_HOST, _PORT: %s:%s", variable_get(VAR_FTP_HOST), + variable_get(VAR_FTP_PORT)); + + /* mediaDevice has been set by mediaSetFTP(), overwrite partly: */ + mediaDevice->type = DEVICE_TYPE_HTTP; + mediaDevice->init = mediaInitHTTP; + mediaDevice->get = mediaGetHTTP; + mediaDevice->shutdown = dummyShutdown; + return DITEM_SUCCESS | DITEM_LEAVE_MENU | what; +} + + int mediaSetUFS(dialogMenuItem *self) { diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c index edc1413..0633145 100644 --- a/usr.sbin/sysinstall/menus.c +++ b/usr.sbin/sysinstall/menus.c @@ -290,6 +290,7 @@ DMenu MenuIndex = { { " Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS }, { " Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP }, { " Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive }, + { " Media, HTTP", "Select FTP via HTTP proxy installation media.", NULL, mediaSetHTTP }, { " Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect }, { " Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking }, { " NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" }, @@ -769,6 +770,7 @@ DMenu MenuMedia = { { { "1 CDROM", "Install from a FreeBSD CDROM", NULL, mediaSetCDROM }, { "2 FTP", "Install from an FTP server", NULL, mediaSetFTPActive }, { "3 FTP Passive", "Install from an FTP server through a firewall", NULL, mediaSetFTPPassive }, + { "3b HTTP", "Install from an FTP server through a http proxy", NULL, mediaSetHTTP }, { "4 DOS", "Install from a DOS partition", NULL, mediaSetDOS }, { "5 NFS", "Install over NFS", NULL, mediaSetNFS }, { "6 File System", "Install from an existing filesystem", NULL, mediaSetUFS }, diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 13a65c6..2a4c618 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -110,6 +110,10 @@ #define VAR_FTP_STATE "ftpState" #define VAR_FTP_USER "ftpUser" #define VAR_FTP_HOST "ftpHost" +#define VAR_HTTP_PATH "_httpPath" +#define VAR_HTTP_PORT "httpPort" +#define VAR_HTTP_HOST "httpHost" +#define VAR_HTTP_FTP_MODE "httpFtpMode" #define VAR_GATEWAY "defaultrouter" #define VAR_GEOMETRY "geometry" #define VAR_HOSTNAME "hostname" @@ -235,6 +239,7 @@ typedef enum { DEVICE_TYPE_UFS, DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, + DEVICE_TYPE_HTTP, } DeviceType; /* CDROM mount codes */ @@ -530,6 +535,10 @@ extern Boolean mediaInitFTP(Device *dev); extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe); extern void mediaShutdownFTP(Device *dev); +/* http.c */ +extern Boolean mediaInitHTTP(Device *dev); +extern FILE *mediaGetHTTP(Device *dev, char *file, Boolean probe); + /* globals.c */ extern void globalsInit(void); @@ -600,6 +609,7 @@ extern int mediaSetTape(dialogMenuItem *self); extern int mediaSetFTP(dialogMenuItem *self); extern int mediaSetFTPActive(dialogMenuItem *self); extern int mediaSetFTPPassive(dialogMenuItem *self); +extern int mediaSetHTTP(dialogMenuItem *self); extern int mediaSetUFS(dialogMenuItem *self); extern int mediaSetNFS(dialogMenuItem *self); extern int mediaSetFTPUserPass(dialogMenuItem *self); -- cgit v1.1