Sync to latest ftp-capable sysinstall. We're getting there!

This commit is contained in:
Jordan K. Hubbard 1995-05-24 09:00:58 +00:00
parent 2f2a4e7a4a
commit bef6490904
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8722
32 changed files with 1082 additions and 640 deletions

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.2 1995/05/23 18:06:12 jkh Exp $
* $Id: config.c,v 1.3 1995/05/24 01:27:08 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -114,7 +114,7 @@ seq_num(Chunk *c1)
}
void
config_fstab(void)
configFstab(void)
{
Device **devs;
Disk *disk;
@ -183,13 +183,49 @@ config_fstab(void)
fclose(fstab);
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
config_sysconfig(void)
configSysconfig(void)
{
FILE *fp;
char *lines[5001]; /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
char line[256];
Variable *v;
int i, nlines = 0;
fp = fopen("/etc/sysconfig", "r");
if (!fp) {
msgConfirm("Unable to open /etc/sysconfig file! Things may work\nrather strangely as a result of this.");
return;
}
for (i = 0; i < 5000; i++) {
if (!fgets(line, 256, fp))
break;
lines[nlines++] = strdup(line);
}
lines[nlines] = NULL;
for (v = VarHead; v; v = v->next) {
for (i = 0; i < nlines; i++) {
}
}
}
int
configSaverTimeout(char *str)
{
char *val;
val = msgGetInput("60", "Enter time-out period in seconds for screen saver");
if (val)
variable_set2("blanktime", val);
return 0;
}
void
config_resolv(void)
configResolv(void)
{
static Boolean alreadyDone = FALSE;
FILE *fp;
@ -209,19 +245,28 @@ config_resolv(void)
}
fprintf(fp, "domain\t%s\n", getenv(VAR_DOMAINNAME));
fprintf(fp, "nameserver\t%s\n", getenv(VAR_NAMESERVER));
msgNotify("Wrote /etc/resolv.conf");
fclose(fp);
alreadyDone = TRUE;
}
int
config_packages(char *str)
configPackages(char *str)
{
if (!mediaDevice || mediaDevice->type != DEVICE_TYPE_CDROM) {
if (getpid() == 1) {
if (!mediaSetCDROM(NULL))
return 0;
else
vsystem("pkg_manage /cdrom");
}
}
vsystem("pkg_manage");
return 0;
}
int
config_ports(char *str)
configPorts(char *str)
{
return 0;
}

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.27 1995/05/21 18:24:32 jkh Exp $
* $Id: devices.c,v 1.28 1995/05/23 02:40:52 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -74,37 +74,38 @@ static struct {
char *name;
char *description;
} device_names[] = {
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ NULL },
};
@ -144,7 +145,8 @@ deviceDiskFree(Device *dev)
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
Boolean (*init)(Device *), int (*get)(char *), Boolean (*close)(Device *, int),
void (*shutdown)(Device *), void *private)
{
Device *newdev;
@ -158,12 +160,13 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->shutdown = shutdown;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -187,7 +190,7 @@ deviceGetAll(void)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
}
free(names);
@ -206,7 +209,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, NULL,
mediaShutdownCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -216,7 +220,7 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, NULL, mediaShutdownTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
}
break;
@ -226,7 +230,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, NULL,
mediaShutdownFloppy, NULL);
msgDebug("Found a device of type floppy named: %s\n", device_names[i].name);
}
break;
@ -237,7 +242,7 @@ deviceGetAll(void)
close(fd);
/* The only network devices that have fds associated are serial ones */
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
}
break;
@ -271,7 +276,7 @@ deviceGetAll(void)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: dist.c,v 1.16 1995/05/22 14:10:15 jkh Exp $
* $Id: dist.c,v 1.17 1995/05/23 02:40:53 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -231,7 +231,10 @@ distExtract(char *parent, Distribution *me)
fd = (*mediaDevice->get)(distname);
if (fd != -1) {
status = mediaExtractDist(distname, me[i].my_dir, fd);
close(fd);
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice, fd);
else
close(fd);
}
else {
if (getenv(NO_CONFIRMATION))
@ -246,8 +249,8 @@ distExtract(char *parent, Distribution *me)
}
}
}
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice);
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
mediaDevice = NULL;
return status;
}

View file

@ -1,3 +1,15 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -9,228 +21,292 @@
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "ftp.h"
#ifndef STANDALONE_FTP
#include "sysinstall.h"
#endif /*STANDALONE_FTP*/
static void
debug(FTP_t ftp, const char *fmt, ...)
{
char p[BUFSIZ];
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
#if 0
write(ftp->fd_debug,p,strlen(p));
char p[BUFSIZ];
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
#ifdef STANDALONE_FTP
write(ftp->fd_debug,p,strlen(p));
#else
msgDebug(p);
msgDebug(p);
#endif
}
static int
writes(int fd, char *s)
{
int i = strlen(s);
if (i != write(fd,s,i))
return errno ? errno : -1;
return 0;
int i = strlen(s);
if (i != write(fd,s,i))
return errno ? errno : -1;
return 0;
}
static char*
get_a_line(FTP_t ftp)
{
static char buf[BUFSIZ];
int i,j;
for(i=0;i<BUFSIZ;) {
j = read(ftp->fd_ctrl,buf+i,1);
if (j != 1)
return 0;
if (buf[i] == '\r' || buf[i] == '\n') {
if (!i)
continue;
buf[i] = '\0';
debug(ftp,"LIBFTP: received <%s>\n",buf);
return buf;
}
i++;
static char buf[BUFSIZ];
int i,j;
for(i=0;i<BUFSIZ;) {
j = read(ftp->fd_ctrl,buf+i,1);
if (j != 1)
return 0;
if (buf[i] == '\r' || buf[i] == '\n') {
if (!i)
continue;
buf[i] = '\0';
debug(ftp,"LIBFTP: received <%s>\n",buf);
return buf;
}
i++;
}
return buf;
}
int
get_a_number(FTP_t ftp)
static int
get_a_number(FTP_t ftp, char **q)
{
char *p;
while(1) {
p = get_a_line(ftp);
if (p[3] != ' ' && p[3] != ' ')
continue;
return atoi(p);
char *p;
int i = -1,j;
while(1) {
p = get_a_line(ftp);
if (!(isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2])))
continue;
if (i == -1 && p[3] == '-') {
i = atoi(p);
continue;
}
if (p[3] != ' ' && p[3] != '\t')
continue;
j = atoi(p);
if (i == -1) {
if (q) *q = p+4;
return j;
} else if (j == i) {
if (q) *q = p+4;
return j;
}
}
}
static int
botch(FTP_t ftp, char *func, char *state)
{
debug(ftp,"LIBFTP: Botch: %s called outside state %s\n",func,state);
writes(ftp->fd_ctrl,"QUIT\r\n");
close(ftp->fd_ctrl); ftp->fd_ctrl = -1;
close(ftp->fd_xfer); ftp->fd_xfer = -1;
ftp->state = init;
return -1;
}
static int
cmd(FTP_t ftp, const char *fmt, ...)
{
char p[BUFSIZ];
int i;
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
debug(ftp,"LIBFTP: send <%s>\n",p);
if (writes(ftp->fd_ctrl,p))
return -1;
if (writes(ftp->fd_ctrl,"\r\n"))
return -1;
i = get_a_number(ftp);
debug(ftp, "LIBFTP: got %d\n",i);
return i;
char p[BUFSIZ];
int i;
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
debug(ftp,"LIBFTP: send <%s>\n",p);
strcat(p,"\r\n");
if (writes(ftp->fd_ctrl,p))
return -1;
i = get_a_number(ftp,0);
debug(ftp, "LIBFTP: got %d\n",i);
return i;
}
FTP_t
FtpInit()
{
FTP_t ftp;
ftp = malloc(sizeof *ftp);
if (!ftp)
return ftp;
memset(ftp, 0, sizeof *ftp);
ftp->fd_ctrl = -1;
ftp->fd_debug = -1;
FTP_t ftp;
ftp = malloc(sizeof *ftp);
if (!ftp)
return ftp;
memset(ftp, 0, sizeof *ftp);
ftp->fd_ctrl = -1;
ftp->fd_debug = -1;
ftp->state = init;
return ftp;
}
#if 0
#ifdef STANDALONE_FTP
void
FtpDebug(FTP_t ftp, int i)
{
ftp->fd_debug = i;
ftp->fd_debug = i;
}
#endif
int
FtpOpen(FTP_t ftp, char *host, char *user, char *passwd)
{
struct hostent *he, hdef;
struct servent *se, sdef;
struct sockaddr_in sin;
int s;
char a,*p,buf[BUFSIZ];
unsigned long temp;
if (!user)
user = "ftp";
if (!passwd)
passwd = "??@??(FreeBSD:libftp)"; /* XXX */
msgDebug("FtpOpen(ftp, %s, %s, %s)\n", host, user, passwd);
temp = inet_addr(host);
if (temp != INADDR_NONE)
struct hostent *he = NULL;
struct sockaddr_in sin;
int s;
unsigned long temp;
extern unsigned long inet_addr(char *);
int i;
if (ftp->state != init)
return botch(ftp,"FtpOpen","init");
if (!user)
user = "ftp";
if (!passwd)
passwd = "??@??(FreeBSD:libftp)"; /* XXX */
debug(ftp,"FtpOpen(ftp, %s, %s, %s)\n", host, user, passwd);
temp = inet_addr(host);
if (temp != INADDR_NONE)
{
debug(ftp,"Using dotted IP address `%s'\n", host);
ftp->addrtype = sin.sin_family = AF_INET;
sin.sin_addr.s_addr = temp;
} else {
debug(ftp,"Trying to resolve `%s'\n", host);
he = gethostbyname(host);
if (!he)
{
msgDebug("Using dotted IP address `%s'\n", host);
ftp->addrtype = sin.sin_family = AF_INET;
sin.sin_addr.s_addr = temp;
} else {
msgDebug("Trying to resolve `%s'\n", host);
he = gethostbyname(host);
if (!he)
{
msgDebug("Lookup of `%s' failed!\n", host);
return ENOENT;
}
ftp->addrtype = sin.sin_family = he->h_addrtype;
bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
debug(ftp,"Lookup of `%s' failed!\n", host);
return ENOENT;
}
sin.sin_port = htons(21);
if ((s = socket(he->h_addrtype, SOCK_STREAM, 0)) < 0)
return s;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
return -1;
}
ftp->fd_ctrl = s;
debug(ftp, "LIBFTP: open (%d)\n",get_a_number(ftp));
cmd(ftp,"USER %s",user);
cmd(ftp,"PASS %s",passwd);
return 0;
fail:
close(ftp->fd_ctrl);
ftp->fd_ctrl = -1;
ftp->addrtype = sin.sin_family = he->h_addrtype;
bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
}
sin.sin_port = htons(21);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
{
debug("Socket open failed: %s (%i)\n", strerror(errno), errno);
return s;
}
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
debug("Connection failed: %s (%i)\n", strerror(errno), errno);
(void)close(s);
return -1;
}
ftp->fd_ctrl = s;
debug(ftp, "LIBFTP: open (%d)\n",get_a_number(ftp,0));
i = cmd(ftp,"USER %s",user);
i = cmd(ftp,"PASS %s",passwd);
ftp->state = isopen;
return 0;
fail:
close(ftp->fd_ctrl);
ftp->fd_ctrl = -1;
return -1;
}
void
FtpClose(FTP_t ftp)
{
if (ftp->state != isopen)
botch(ftp,"FtpClose","open");
writes(ftp->fd_ctrl,"QUIT\r\n");
close(ftp->fd_ctrl); ftp->fd_ctrl = -1;
close(ftp->fd_xfer); ftp->fd_xfer = -1;
ftp->state = init;
}
int
FtpChdir(FTP_t ftp, char *dir)
{
cmd(ftp,"CWD %s",dir);
return 0;
int i;
if (ftp->state != isopen)
return botch(ftp,"FtpChdir","open");
i = cmd(ftp,"CWD %s",dir);
return 0;
}
int
FtpGet(FTP_t ftp, char *file)
{
int fd,i,j,s;
char p[BUFSIZ],*q;
unsigned char addr[6];
struct sockaddr_in sin;
if(ftp->binary) {
cmd(ftp,"TYPE I");
} else {
return -1;
int i,s;
char *q;
unsigned char addr[6];
struct sockaddr_in sin;
if (ftp->state != isopen)
return botch(ftp,"FtpGet","open");
if(ftp->binary) {
i = cmd(ftp,"TYPE I");
if (i > 299)
return -1;
} else {
return -1;
}
if(ftp->passive) {
if (writes(ftp->fd_ctrl,"PASV\r\n"))
return -1;
i = get_a_number(ftp,&q);
if (i != 227)
return -1;
while (*q && !isdigit(*q))
q++;
if (!*q)
return -1;
q--;
for(i=0;i<6;i++) {
q++;
addr[i] = strtol(q,&q,10);
}
if(ftp->passive) {
if (writes(ftp->fd_ctrl,"PASV\r\n"))
return -1;
q = get_a_line(ftp);
if (strncmp(q,"227 ",4))
return -1;
q = strchr(q,'(');
if (!q)
return -1;
for(i=0;i<6;i++) {
q++;
addr[i] = strtol(q,&q,10);
debug(ftp,"ADDR[%d] = %d (%c)\n",i,addr[i],*q);
}
if (*q != ')')
return -1;
sin.sin_family = ftp->addrtype;
bcopy(addr, (char *)&sin.sin_addr, 4);
bcopy(addr+4, (char *)&sin.sin_port, 2);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
return -1;
debug(ftp,"Getsocket = %d\n",s);
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
debug(ftp,"connect, errno = %d\n",errno);
return -1;
}
cmd(ftp,"RETR %s",file);
return s;
} else {
return -1;
sin.sin_family = ftp->addrtype;
bcopy(addr, (char *)&sin.sin_addr, 4);
bcopy(addr+4, (char *)&sin.sin_port, 2);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
return -1;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
debug(ftp,"connect, errno = %d\n",errno);
return -1;
}
i = cmd(ftp,"RETR %s",file);
if (i > 299)
return -1;
ftp->state = xfer;
return s;
} else {
return -1;
}
}
int
FtpEOF(FTP_t ftp)
{
get_a_number(ftp);
if (ftp->state != xfer)
return botch(ftp,"FtpEOF","xfer");
ftp->state = isopen;
return get_a_number(ftp,0);
}
#ifdef STANDALONE_FTP
@ -240,25 +316,35 @@ FtpEOF(FTP_t ftp)
int
main(int argc, char **argv)
{
FTP_t ftp;
int i;
char c;
ftp = FtpInit();
if (!ftp) err(1,"FtpInit()");
FtpDebug(ftp,1);
i = FtpOpen(ftp, "ref", "ftp", "phk-libftp@");
if (i) err(1,"FtpOpen(%d)",i);
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"CTM");
i = FtpGet(ftp,"README_CTM_MOVED");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
return 0;
FTP_t ftp;
int i;
char c;
ftp = FtpInit();
if (!ftp) err(1,"FtpInit()");
FtpDebug(ftp,1);
i = FtpOpen(ftp, "ref.tfs.com", "ftp", "phk-libftp@");
if (i) err(1,"FtpOpen(%d)",i);
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"CTM");
i = FtpGet(ftp,"README_CTM_MOVED");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
FtpClose(ftp);
i = FtpOpen(ftp, "freefall.cdrom.com", "ftp", "phk-libftp@");
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"FreeBSD");
i = FtpGet(ftp,"README");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
return 0;
}
#endif /*STANDALONE_FTP*/

View file

@ -1,5 +1,7 @@
typedef struct {
enum {init, isopen, xfer} state;
int fd_ctrl;
int fd_xfer;
int fd_debug;
int binary;
int passive;
@ -12,12 +14,9 @@ FTP_t FtpInit();
int FtpOpen(FTP_t, char *host, char *user, char *passwd);
#define FtpBinary(ftp,bool) { (ftp)->binary = (bool); }
#define FtpPassive(ftp,bool) { (ftp)->passive = (bool); }
#ifndef STANDALONE_FTP
#define FtpDebug(ftp, bool) { (ftp)->fd_debug = (bool); }
/*
void FtpBinary(FTP_t, int);
void FtpPassive(FTP_t, int);
void FtpDebug(FTP_t, int);
*/
#endif
int FtpChdir(FTP_t, char *);
int FtpGet(FTP_t, char *);
int FtpEOF(FTP_t);

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.49 1995/05/23 18:06:13 jkh Exp $
* $Id: install.c,v 1.50 1995/05/24 01:27:10 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -208,9 +208,9 @@ installFinal(void)
if (alreadyDone)
return;
config_fstab();
config_sysconfig();
config_resolv();
configFstab();
configSysconfig();
configResolv();
do_final_setup();
alreadyDone = TRUE;
SystemWasInstalled = TRUE;
@ -346,7 +346,6 @@ cpio_extract(void)
int i, j, zpid, cpid, pfd[2];
Boolean onCDROM = FALSE;
#if 0
if (mediaDevice && mediaDevice->type == DEVICE_TYPE_CDROM) {
if (mediaDevice->init) {
if ((*mediaDevice->init)(mediaDevice)) {
@ -358,7 +357,7 @@ cpio_extract(void)
}
}
}
#endif
tryagain:
while (CpioFD == -1) {
msgConfirm("Please Insert CPIO floppy in floppy drive 0");

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: label.c,v 1.21 1995/05/22 14:10:20 jkh Exp $
* $Id: label.c,v 1.22 1995/05/23 02:41:07 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -560,6 +560,12 @@ diskLabelEditor(char *str)
p = get_mountpoint(label_chunk_info[here].c);
if (p) {
p->newfs = FALSE;
if (label_chunk_info[here].type == PART_FAT
&& (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
|| !strcmp(p->mountpoint, "/var"))) {
msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
strcpy(p->mountpoint, "/bogus");
}
record_label_chunks();
}
break;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id: main.c,v 1.7 1995/05/16 11:37:17 jkh Exp $
* $Id: main.c,v 1.8 1995/05/17 14:39:49 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -64,6 +64,9 @@ main(int argc, char **argv)
/* Default to English */
lang_set_English(NULL);
/* Default to passive mode ftp since it's the only thing we currently support :-( */
variable_set2("ftpPassive", "yes");
/* Begin user dialog at outer menu */
while (1) {
choice = scroll = curr = max = 0;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: media.c,v 1.14 1995/05/22 14:10:21 jkh Exp $
* $Id: media.c,v 1.15 1995/05/23 02:41:09 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -86,9 +86,7 @@ mediaSetCDROM(char *str)
/* This may need to be extended a little, but the basic idea is sound */
strcpy(bootCD.name, "bootCD");
bootCD.type = DEVICE_TYPE_CDROM;
bootCD.init = NULL;
bootCD.get = mediaGetCDROM;
bootCD.close = NULL;
mediaDevice = &bootCD;
return 1;
}
@ -197,7 +195,7 @@ mediaSetDOS(char *str)
if (c1->type == fat) {
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, mediaCloseDOS, NULL);
mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
@ -267,7 +265,7 @@ mediaSetFTP(char *str)
ftpDevice.type = DEVICE_TYPE_NETWORK;
ftpDevice.init = mediaInitFTP;
ftpDevice.get = mediaGetFTP;
ftpDevice.close = mediaCloseFTP;
ftpDevice.shutdown = mediaShutdownFTP;
ftpDevice.private = devp;
mediaDevice = &ftpDevice;
return 1;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: media_strategy.c,v 1.13 1995/05/23 18:06:14 jkh Exp $
* $Id: media_strategy.c,v 1.14 1995/05/24 01:27:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -68,7 +68,7 @@
#undef CD9660
#undef NFS
#define MAX_ATTRIBS 20
#define MAX_ATTRIBS 200
#define MAX_NAME 511
#define MAX_VALUE 4095
@ -189,10 +189,10 @@ attr_match(struct attribs *attr, char *name)
{
int n = 0;
while((strcmp(attr[n].name, name)!=0) && (n < num_attribs) && (n < 20))
while((strcasecmp(attr[n].name, name)!=0) && (n < num_attribs) && (n < 20))
n++;
if (strcmp(attr[n].name, name)==0)
if (strcasecmp(attr[n].name, name)==0)
return((const char *) attr[n].value);
return NULL;
@ -345,9 +345,9 @@ mediaGetCDROM(char *dist)
}
void
mediaCloseCDROM(Device *dev)
mediaShutdownCDROM(Device *dev)
{
msgDebug("In mediaCloseCDROM\n");
msgDebug("In mediaShutdownCDROM\n");
if (unmount("/cdrom", 0) != 0)
msgConfirm("Could not unmount the CDROM: %s\n", strerror(errno));
msgDebug("Unmount returned\n");
@ -388,7 +388,7 @@ mediaGetFloppy(char *dist)
}
void
mediaCloseFloppy(Device *dev)
mediaShutdownFloppy(Device *dev)
{
return;
}
@ -405,6 +405,7 @@ mediaInitNetwork(Device *dev)
int i;
char *rp;
configResolv();
if (!strncmp("cuaa", dev->name, 4)) {
if (tcpStartPPP()) {
msgConfirm("You have selected a serial device as your network installation device.\nThe PPP dialer is now running on the 3rd screen (type ALT-F3 to interact\nwith it) and should be used to establish the link BEFORE YOU HIT RETURN\nhere! Once you hit return in this screen (type ALT-F1 to return to this\nscreen from the PPP screen) the installation will assume that your link\nis set up and begin transfering the distributions over PPP.");
@ -432,12 +433,10 @@ mediaInitNetwork(Device *dev)
rp = getenv(VAR_GATEWAY);
if (!rp)
msgConfirm("No gateway has been set. You will not be able to access machines\n
msgConfirm("No gateway has been set. You will not be able to access hosts\n
not on the local network\n");
else
vsystem("route add default %s", rp);
config_resolv();
return TRUE;
}
@ -448,13 +447,13 @@ mediaGetTape(char *dist)
}
void
mediaCloseTape(Device *dev)
mediaShutdownTape(Device *dev)
{
return;
}
void
mediaCloseNetwork(Device *dev)
mediaShutdownNetwork(Device *dev)
{
return;
}
@ -465,7 +464,7 @@ Boolean
mediaInitFTP(Device *dev)
{
int i;
char *url, *hostname, *dir, *dir_p;
char *url, *hostname, *dir;
char *my_name, email[BUFSIZ];
Device *netDevice = (Device *)dev->private;
@ -498,6 +497,7 @@ mediaInitFTP(Device *dev)
*(dir++) = '\0';
msgDebug("hostname = `%s'\n", hostname);
msgDebug("dir = `%s'\n", dir);
msgNotify("Looking up %s..", hostname);
if ((gethostbyname(hostname) == NULL) && (inet_addr(hostname) == INADDR_NONE)) {
msgConfirm("Cannot resolve hostname `%s'!\n", hostname);
return FALSE;
@ -506,6 +506,7 @@ mediaInitFTP(Device *dev)
snprintf(email, BUFSIZ, "installer@%s", my_name);
msgDebug("Using fake e-mail `%s'\n", email);
msgNotify("Logging in as anonymous.");
if ((i = FtpOpen(ftp, hostname, "anonymous", email)) != 0) {
msgConfirm("Couldn't open FTP connection to %s: %s (%u)\n", hostname, strerror(i), i);
return FALSE;
@ -514,12 +515,10 @@ mediaInitFTP(Device *dev)
if (getenv("ftpPassive"))
FtpPassive(ftp, 1);
FtpBinary(ftp, 1);
FtpChdir(ftp, "/");
while ((dir_p = index(dir, '/')) != NULL) {
*dir_p = '\0';
msgNotify("CD to distribution in ~ftp/%s", dir ? dir : "");
if (*dir != '\0')
FtpChdir(ftp, dir);
dir = ++dir_p;
}
msgDebug("leaving mediaInitFTP!\n");
return TRUE;
}
@ -532,16 +531,19 @@ mediaGetFTP(char *dist)
const char *tmp;
struct attribs *dist_attr;
msgNotify("Attempting to get distribution `%s' over FTP\n", dist);
dist_attr = safe_malloc(sizeof(struct attribs) * MAX_ATTRIBS);
snprintf(buf, PATH_MAX, "/stand/info/%s.inf", dist);
msgDebug("Parsing attributes file\n");
if (attr_parse(&dist_attr, buf) == 0)
{
msgConfirm("Cannot load information file for distribution\n");
return -1;
}
msgDebug("Looking for attribute `pieces'\n");
tmp = attr_match(dist_attr, "pieces");
numchunks = atoi(tmp);
msgDebug("Attempting to extract distribution from %u files\n", numchunks);
@ -596,7 +598,7 @@ mediaGetFTP(char *dist)
}
void
mediaCloseFTP(Device *dev)
mediaShutdownFTP(Device *dev)
{
}
@ -612,7 +614,7 @@ mediaGetUFS(char *dist)
return -1;
}
/* UFS has no close routine since this is handled at the device level */
/* UFS has no Shutdown routine since this is handled at the device level */
Boolean
@ -628,6 +630,6 @@ mediaGetDOS(char *dist)
}
void
mediaCloseDOS(Device *dev)
mediaShutdownDOS(Device *dev)
{
}

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.25 1995/05/23 02:41:13 jkh Exp $
* $Id: menus.c,v 1.26 1995/05/24 01:27:12 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -644,17 +644,43 @@ your FreeBSD system more generally usable and which may be selected\n\
from the menu below. When you're done, select Cancel.",
"Press F1 for more information on these options",
"configure.hlp",
{ { "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Add User", "Add users to the system",
{ { "Add User", "Add users to the system",
DMENU_SYSTEM_COMMAND, "adduser", 0, 0 },
{ "Root Pass", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Packages", "Install extra FreeBSD packaged software",
DMENU_CALL, config_packages, 0, 1 },
DMENU_CALL, configPackages, 0, 1 },
{ "Ports", "Enable the FreeBSD Ports Collection from CD",
DMENU_CALL, config_ports, 0, 1 },
DMENU_CALL, configPorts, 0, 1 },
{ "Root Password", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Screen", "Customize system console behavior",
DMENU_SUBMENU, &MenuSyscons, 0, 0 },
{ "Sysconfig", "Edit the system configuration file (with vi)",
DMENU_SYSTEM_COMMAND, "vi /etc/sysconfig", 0, 0 },
{ "XFree86", "Configure XFree86 (if installed)",
DMENU_SYSTEM_COMMAND, "PATH=/usr/bin:/bin:/usr/X11R6/bin xf86config", 0, 0 },
{ NULL } },
};
DMenu MenuSyscons = {
DMENU_NORMAL_TYPE,
"System Console Configuration",
"The default system console driver for FreeBSD (syscons) has a\n\
number of configuration options which may be set according to\n\
your preference. When you are done setting configuration options,\n\
select Cancel.",
NULL,
NULL,
{ { "blank", "Screen-blanking saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Green", "\"green\" power saver (if supported by monitor)",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Snake", "\"snake\" screen saver",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Star", "\"twinkling stars\" screen saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Timeout", "Set screen saver timeout interval",
DMENU_CALL, configSaverTimeout, 0, 0 },
{ NULL } },
};

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.22 1995/05/22 14:10:25 jkh Exp $
* $Id: msg.c,v 1.23 1995/05/23 02:41:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -100,6 +100,7 @@ msgInfo(char *fmt, ...)
attrset(A_REVERSE);
mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, line);
attrset(attrs);
move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79);
refresh();
if (OnVTY) {
msgDebug("Information: `%s'\n", errstr);

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.28 1995/05/23 18:06:16 jkh Exp $
* $Id: sysinstall.h,v 1.29 1995/05/24 01:27:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -159,8 +159,9 @@ typedef struct _device {
DeviceType type;
Boolean enabled;
Boolean (*init)(struct _device *);
Boolean (*get)(char *fname);
void (*close)(struct _device *);
int (*get)(char *fname);
Boolean (*close)(struct _device *, int fd);
void (*shutdown)(struct _device *);
void *private;
} Device;
@ -216,6 +217,7 @@ extern DMenu MenuMediaFloppy; /* Floppy media menu */
extern DMenu MenuMediaFTP; /* FTP media menu */
extern DMenu MenuMediaTape; /* Tape media menu */
extern DMenu MenuNetworkDevice; /* Network device menu */
extern DMenu MenuSyscons; /* System console configuration menu */
extern DMenu MenuInstall; /* Installation menu */
extern DMenu MenuInstallType; /* Installation type menu */
extern DMenu MenuDistributions; /* Distribution menu */
@ -238,11 +240,12 @@ extern void command_shell_add(char *key, char *fmt, ...);
extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern void config_fstab(void);
extern void config_sysconfig(void);
extern void config_resolv(void);
extern int config_ports(char *str);
extern int config_packages(char *str);
extern void configFstab(void);
extern void configSysconfig(void);
extern void configResolv(void);
extern int configPorts(char *str);
extern int configPackages(char *str);
extern int configSaverTimeout(char *str);
/* decode.c */
extern DMenuItem *decode(DMenu *menu, char *name);
@ -256,8 +259,9 @@ extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
Boolean (*init)(Device *mediadev), int (*get)(char *distname),
Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev),
void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -338,12 +342,12 @@ extern int mediaGetFloppy(char *dist);
extern int mediaGetFTP(char *dist);
extern int mediaGetTape(char *dist);
extern int mediaGetUFS(char *dist);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseFTP(Device *dev);
extern void mediaCloseFloppy(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseTape(Device *dev);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.2 1995/05/23 18:06:12 jkh Exp $
* $Id: config.c,v 1.3 1995/05/24 01:27:08 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -114,7 +114,7 @@ seq_num(Chunk *c1)
}
void
config_fstab(void)
configFstab(void)
{
Device **devs;
Disk *disk;
@ -183,13 +183,49 @@ config_fstab(void)
fclose(fstab);
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
config_sysconfig(void)
configSysconfig(void)
{
FILE *fp;
char *lines[5001]; /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
char line[256];
Variable *v;
int i, nlines = 0;
fp = fopen("/etc/sysconfig", "r");
if (!fp) {
msgConfirm("Unable to open /etc/sysconfig file! Things may work\nrather strangely as a result of this.");
return;
}
for (i = 0; i < 5000; i++) {
if (!fgets(line, 256, fp))
break;
lines[nlines++] = strdup(line);
}
lines[nlines] = NULL;
for (v = VarHead; v; v = v->next) {
for (i = 0; i < nlines; i++) {
}
}
}
int
configSaverTimeout(char *str)
{
char *val;
val = msgGetInput("60", "Enter time-out period in seconds for screen saver");
if (val)
variable_set2("blanktime", val);
return 0;
}
void
config_resolv(void)
configResolv(void)
{
static Boolean alreadyDone = FALSE;
FILE *fp;
@ -209,19 +245,28 @@ config_resolv(void)
}
fprintf(fp, "domain\t%s\n", getenv(VAR_DOMAINNAME));
fprintf(fp, "nameserver\t%s\n", getenv(VAR_NAMESERVER));
msgNotify("Wrote /etc/resolv.conf");
fclose(fp);
alreadyDone = TRUE;
}
int
config_packages(char *str)
configPackages(char *str)
{
if (!mediaDevice || mediaDevice->type != DEVICE_TYPE_CDROM) {
if (getpid() == 1) {
if (!mediaSetCDROM(NULL))
return 0;
else
vsystem("pkg_manage /cdrom");
}
}
vsystem("pkg_manage");
return 0;
}
int
config_ports(char *str)
configPorts(char *str)
{
return 0;
}

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.27 1995/05/21 18:24:32 jkh Exp $
* $Id: devices.c,v 1.28 1995/05/23 02:40:52 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -74,37 +74,38 @@ static struct {
char *name;
char *description;
} device_names[] = {
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ NULL },
};
@ -144,7 +145,8 @@ deviceDiskFree(Device *dev)
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
Boolean (*init)(Device *), int (*get)(char *), Boolean (*close)(Device *, int),
void (*shutdown)(Device *), void *private)
{
Device *newdev;
@ -158,12 +160,13 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->shutdown = shutdown;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -187,7 +190,7 @@ deviceGetAll(void)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
}
free(names);
@ -206,7 +209,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, NULL,
mediaShutdownCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -216,7 +220,7 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, NULL, mediaShutdownTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
}
break;
@ -226,7 +230,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, NULL,
mediaShutdownFloppy, NULL);
msgDebug("Found a device of type floppy named: %s\n", device_names[i].name);
}
break;
@ -237,7 +242,7 @@ deviceGetAll(void)
close(fd);
/* The only network devices that have fds associated are serial ones */
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
}
break;
@ -271,7 +276,7 @@ deviceGetAll(void)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.49 1995/05/23 18:06:13 jkh Exp $
* $Id: install.c,v 1.50 1995/05/24 01:27:10 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -208,9 +208,9 @@ installFinal(void)
if (alreadyDone)
return;
config_fstab();
config_sysconfig();
config_resolv();
configFstab();
configSysconfig();
configResolv();
do_final_setup();
alreadyDone = TRUE;
SystemWasInstalled = TRUE;
@ -346,7 +346,6 @@ cpio_extract(void)
int i, j, zpid, cpid, pfd[2];
Boolean onCDROM = FALSE;
#if 0
if (mediaDevice && mediaDevice->type == DEVICE_TYPE_CDROM) {
if (mediaDevice->init) {
if ((*mediaDevice->init)(mediaDevice)) {
@ -358,7 +357,7 @@ cpio_extract(void)
}
}
}
#endif
tryagain:
while (CpioFD == -1) {
msgConfirm("Please Insert CPIO floppy in floppy drive 0");

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: label.c,v 1.21 1995/05/22 14:10:20 jkh Exp $
* $Id: label.c,v 1.22 1995/05/23 02:41:07 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -560,6 +560,12 @@ diskLabelEditor(char *str)
p = get_mountpoint(label_chunk_info[here].c);
if (p) {
p->newfs = FALSE;
if (label_chunk_info[here].type == PART_FAT
&& (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
|| !strcmp(p->mountpoint, "/var"))) {
msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
strcpy(p->mountpoint, "/bogus");
}
record_label_chunks();
}
break;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id: main.c,v 1.7 1995/05/16 11:37:17 jkh Exp $
* $Id: main.c,v 1.8 1995/05/17 14:39:49 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -64,6 +64,9 @@ main(int argc, char **argv)
/* Default to English */
lang_set_English(NULL);
/* Default to passive mode ftp since it's the only thing we currently support :-( */
variable_set2("ftpPassive", "yes");
/* Begin user dialog at outer menu */
while (1) {
choice = scroll = curr = max = 0;

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.25 1995/05/23 02:41:13 jkh Exp $
* $Id: menus.c,v 1.26 1995/05/24 01:27:12 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -644,17 +644,43 @@ your FreeBSD system more generally usable and which may be selected\n\
from the menu below. When you're done, select Cancel.",
"Press F1 for more information on these options",
"configure.hlp",
{ { "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Add User", "Add users to the system",
{ { "Add User", "Add users to the system",
DMENU_SYSTEM_COMMAND, "adduser", 0, 0 },
{ "Root Pass", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Packages", "Install extra FreeBSD packaged software",
DMENU_CALL, config_packages, 0, 1 },
DMENU_CALL, configPackages, 0, 1 },
{ "Ports", "Enable the FreeBSD Ports Collection from CD",
DMENU_CALL, config_ports, 0, 1 },
DMENU_CALL, configPorts, 0, 1 },
{ "Root Password", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Screen", "Customize system console behavior",
DMENU_SUBMENU, &MenuSyscons, 0, 0 },
{ "Sysconfig", "Edit the system configuration file (with vi)",
DMENU_SYSTEM_COMMAND, "vi /etc/sysconfig", 0, 0 },
{ "XFree86", "Configure XFree86 (if installed)",
DMENU_SYSTEM_COMMAND, "PATH=/usr/bin:/bin:/usr/X11R6/bin xf86config", 0, 0 },
{ NULL } },
};
DMenu MenuSyscons = {
DMENU_NORMAL_TYPE,
"System Console Configuration",
"The default system console driver for FreeBSD (syscons) has a\n\
number of configuration options which may be set according to\n\
your preference. When you are done setting configuration options,\n\
select Cancel.",
NULL,
NULL,
{ { "blank", "Screen-blanking saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Green", "\"green\" power saver (if supported by monitor)",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Snake", "\"snake\" screen saver",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Star", "\"twinkling stars\" screen saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Timeout", "Set screen saver timeout interval",
DMENU_CALL, configSaverTimeout, 0, 0 },
{ NULL } },
};

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.22 1995/05/22 14:10:25 jkh Exp $
* $Id: msg.c,v 1.23 1995/05/23 02:41:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -100,6 +100,7 @@ msgInfo(char *fmt, ...)
attrset(A_REVERSE);
mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, line);
attrset(attrs);
move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79);
refresh();
if (OnVTY) {
msgDebug("Information: `%s'\n", errstr);

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.28 1995/05/23 18:06:16 jkh Exp $
* $Id: sysinstall.h,v 1.29 1995/05/24 01:27:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -159,8 +159,9 @@ typedef struct _device {
DeviceType type;
Boolean enabled;
Boolean (*init)(struct _device *);
Boolean (*get)(char *fname);
void (*close)(struct _device *);
int (*get)(char *fname);
Boolean (*close)(struct _device *, int fd);
void (*shutdown)(struct _device *);
void *private;
} Device;
@ -216,6 +217,7 @@ extern DMenu MenuMediaFloppy; /* Floppy media menu */
extern DMenu MenuMediaFTP; /* FTP media menu */
extern DMenu MenuMediaTape; /* Tape media menu */
extern DMenu MenuNetworkDevice; /* Network device menu */
extern DMenu MenuSyscons; /* System console configuration menu */
extern DMenu MenuInstall; /* Installation menu */
extern DMenu MenuInstallType; /* Installation type menu */
extern DMenu MenuDistributions; /* Distribution menu */
@ -238,11 +240,12 @@ extern void command_shell_add(char *key, char *fmt, ...);
extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern void config_fstab(void);
extern void config_sysconfig(void);
extern void config_resolv(void);
extern int config_ports(char *str);
extern int config_packages(char *str);
extern void configFstab(void);
extern void configSysconfig(void);
extern void configResolv(void);
extern int configPorts(char *str);
extern int configPackages(char *str);
extern int configSaverTimeout(char *str);
/* decode.c */
extern DMenuItem *decode(DMenu *menu, char *name);
@ -256,8 +259,9 @@ extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
Boolean (*init)(Device *mediadev), int (*get)(char *distname),
Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev),
void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -338,12 +342,12 @@ extern int mediaGetFloppy(char *dist);
extern int mediaGetFTP(char *dist);
extern int mediaGetTape(char *dist);
extern int mediaGetUFS(char *dist);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseFTP(Device *dev);
extern void mediaCloseFloppy(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseTape(Device *dev);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: config.c,v 1.2 1995/05/23 18:06:12 jkh Exp $
* $Id: config.c,v 1.3 1995/05/24 01:27:08 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -114,7 +114,7 @@ seq_num(Chunk *c1)
}
void
config_fstab(void)
configFstab(void)
{
Device **devs;
Disk *disk;
@ -183,13 +183,49 @@ config_fstab(void)
fclose(fstab);
}
/*
* This sucks in /etc/sysconfig, substitutes anything needing substitution, then
* writes it all back out. It's pretty gross and needs re-writing at some point.
*/
void
config_sysconfig(void)
configSysconfig(void)
{
FILE *fp;
char *lines[5001]; /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
char line[256];
Variable *v;
int i, nlines = 0;
fp = fopen("/etc/sysconfig", "r");
if (!fp) {
msgConfirm("Unable to open /etc/sysconfig file! Things may work\nrather strangely as a result of this.");
return;
}
for (i = 0; i < 5000; i++) {
if (!fgets(line, 256, fp))
break;
lines[nlines++] = strdup(line);
}
lines[nlines] = NULL;
for (v = VarHead; v; v = v->next) {
for (i = 0; i < nlines; i++) {
}
}
}
int
configSaverTimeout(char *str)
{
char *val;
val = msgGetInput("60", "Enter time-out period in seconds for screen saver");
if (val)
variable_set2("blanktime", val);
return 0;
}
void
config_resolv(void)
configResolv(void)
{
static Boolean alreadyDone = FALSE;
FILE *fp;
@ -209,19 +245,28 @@ config_resolv(void)
}
fprintf(fp, "domain\t%s\n", getenv(VAR_DOMAINNAME));
fprintf(fp, "nameserver\t%s\n", getenv(VAR_NAMESERVER));
msgNotify("Wrote /etc/resolv.conf");
fclose(fp);
alreadyDone = TRUE;
}
int
config_packages(char *str)
configPackages(char *str)
{
if (!mediaDevice || mediaDevice->type != DEVICE_TYPE_CDROM) {
if (getpid() == 1) {
if (!mediaSetCDROM(NULL))
return 0;
else
vsystem("pkg_manage /cdrom");
}
}
vsystem("pkg_manage");
return 0;
}
int
config_ports(char *str)
configPorts(char *str)
{
return 0;
}

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: devices.c,v 1.27 1995/05/21 18:24:32 jkh Exp $
* $Id: devices.c,v 1.28 1995/05/23 02:40:52 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -74,37 +74,38 @@ static struct {
char *name;
char *description;
} device_names[] = {
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ DEVICE_TYPE_CDROM, "cd0a", "SCSI CDROM drive" },
{ DEVICE_TYPE_CDROM, "cd1a", "SCSI CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "mcd0a", "Mitsumi (old model) CDROM drive" },
{ DEVICE_TYPE_CDROM, "mcd1a", "Mitsumi (old model) CDROM drive (2nd unit)" },
{ DEVICE_TYPE_CDROM, "scd0a", "Sony CDROM drive - CDU31/33A type", },
{ DEVICE_TYPE_CDROM, "scd1a", "Sony CDROM drive - CDU31/33A type (2nd unit)" },
{ DEVICE_TYPE_CDROM, "matcd0a", "Matsushita CDROM ('sound blaster' type)" },
{ DEVICE_TYPE_CDROM, "matcd1a", "Matsushita CDROM (2nd unit)" },
{ DEVICE_TYPE_TAPE, "rst0", "SCSI tape drive" },
{ DEVICE_TYPE_TAPE, "rst1", "SCSI tape drive (2nd unit)" },
{ DEVICE_TYPE_TAPE, "ft0", "Floppy tape drive (QIC-02)" },
{ DEVICE_TYPE_TAPE, "wt0", "Wangtek tape drive" },
{ DEVICE_TYPE_DISK, "sd", "SCSI disk device" },
{ DEVICE_TYPE_DISK, "wd", "IDE/ESDI/MFM/ST506 disk device" },
{ DEVICE_TYPE_FLOPPY, "rfd0", "Floppy disk drive (unit A)" },
{ DEVICE_TYPE_FLOPPY, "rfd1", "Floppy disk drive (unit B)" },
{ DEVICE_TYPE_NETWORK, "cuaa0", "Serial port (COM1) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "cuaa1", "Serial port (COM2) - possible PPP device" },
{ DEVICE_TYPE_NETWORK, "lp0", "Parallel Port IP (PLIP) using laplink cable" },
{ DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
{ DEVICE_TYPE_NETWORK, "sl", "Serial-line IP (SLIP) interface" },
{ DEVICE_TYPE_NETWORK, "ppp", "Point-to-Point Protocol (PPP) interface" },
{ DEVICE_TYPE_NETWORK, "ed", "WD/SMC 80xx; Novell NE1000/2000; 3Com 3C503 cards" },
{ DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 interface card" },
{ DEVICE_TYPE_NETWORK, "el", "3Com 3C501 interface card" },
{ DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A Ethernet" },
{ DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
{ DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress" },
{ DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 and 3" },
{ DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet cards (Isolan/Novell NE2100/NE32-VL)" },
{ DEVICE_TYPE_NETWORK, "ze", "IBM/National Semiconductor PCMCIA ethernet" },
{ DEVICE_TYPE_NETWORK, "zp", "3Com PCMCIA Etherlink III" },
{ NULL },
};
@ -144,7 +145,8 @@ deviceDiskFree(Device *dev)
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), Boolean (*get)(char *), void (*close)(Device *), void *private)
Boolean (*init)(Device *), int (*get)(char *), Boolean (*close)(Device *, int),
void (*shutdown)(Device *), void *private)
{
Device *newdev;
@ -158,12 +160,13 @@ deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean e
newdev->init = init;
newdev->get = get;
newdev->close = close;
newdev->shutdown = shutdown;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
return newdev;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
@ -187,7 +190,7 @@ deviceGetAll(void)
msgFatal("Unable to open disk %s", names[i]);
(void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
mediaInitUFS, mediaGetUFS, deviceDiskFree, d);
mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d);
msgDebug("Found a device of type disk named: %s\n", names[i]);
}
free(names);
@ -206,7 +209,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
(void)deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, mediaCloseCDROM, NULL);
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM, NULL,
mediaShutdownCDROM, NULL);
msgDebug("Found a device of type CDROM named: %s\n", device_names[i].name);
}
break;
@ -216,7 +220,7 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaCloseTape, NULL);
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, NULL, mediaShutdownTape, NULL);
msgDebug("Found a device of type TAPE named: %s\n", device_names[i].name);
}
break;
@ -226,7 +230,8 @@ deviceGetAll(void)
if (fd >= 0) {
close(fd);
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, mediaCloseFloppy, NULL);
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy, NULL,
mediaShutdownFloppy, NULL);
msgDebug("Found a device of type floppy named: %s\n", device_names[i].name);
}
break;
@ -237,7 +242,7 @@ deviceGetAll(void)
close(fd);
/* The only network devices that have fds associated are serial ones */
deviceRegister(device_names[i].name, device_names[i].description, strdup(try),
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", device_names[i].name);
}
break;
@ -271,7 +276,7 @@ deviceGetAll(void)
|| !strncmp(ifptr->ifr_name, "lo0", 3))
continue;
deviceRegister(ifptr->ifr_name, ifptr->ifr_name, ifptr->ifr_name,
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, mediaCloseNetwork, NULL);
DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork, NULL, NULL, mediaShutdownNetwork, NULL);
msgDebug("Found a device of type network named: %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: dist.c,v 1.16 1995/05/22 14:10:15 jkh Exp $
* $Id: dist.c,v 1.17 1995/05/23 02:40:53 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -231,7 +231,10 @@ distExtract(char *parent, Distribution *me)
fd = (*mediaDevice->get)(distname);
if (fd != -1) {
status = mediaExtractDist(distname, me[i].my_dir, fd);
close(fd);
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice, fd);
else
close(fd);
}
else {
if (getenv(NO_CONFIRMATION))
@ -246,8 +249,8 @@ distExtract(char *parent, Distribution *me)
}
}
}
if (mediaDevice->close)
(*mediaDevice->close)(mediaDevice);
if (mediaDevice->shutdown)
(*mediaDevice->shutdown)(mediaDevice);
mediaDevice = NULL;
return status;
}

View file

@ -1,3 +1,15 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id$
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -9,228 +21,292 @@
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "ftp.h"
#ifndef STANDALONE_FTP
#include "sysinstall.h"
#endif /*STANDALONE_FTP*/
static void
debug(FTP_t ftp, const char *fmt, ...)
{
char p[BUFSIZ];
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
#if 0
write(ftp->fd_debug,p,strlen(p));
char p[BUFSIZ];
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
#ifdef STANDALONE_FTP
write(ftp->fd_debug,p,strlen(p));
#else
msgDebug(p);
msgDebug(p);
#endif
}
static int
writes(int fd, char *s)
{
int i = strlen(s);
if (i != write(fd,s,i))
return errno ? errno : -1;
return 0;
int i = strlen(s);
if (i != write(fd,s,i))
return errno ? errno : -1;
return 0;
}
static char*
get_a_line(FTP_t ftp)
{
static char buf[BUFSIZ];
int i,j;
for(i=0;i<BUFSIZ;) {
j = read(ftp->fd_ctrl,buf+i,1);
if (j != 1)
return 0;
if (buf[i] == '\r' || buf[i] == '\n') {
if (!i)
continue;
buf[i] = '\0';
debug(ftp,"LIBFTP: received <%s>\n",buf);
return buf;
}
i++;
static char buf[BUFSIZ];
int i,j;
for(i=0;i<BUFSIZ;) {
j = read(ftp->fd_ctrl,buf+i,1);
if (j != 1)
return 0;
if (buf[i] == '\r' || buf[i] == '\n') {
if (!i)
continue;
buf[i] = '\0';
debug(ftp,"LIBFTP: received <%s>\n",buf);
return buf;
}
i++;
}
return buf;
}
int
get_a_number(FTP_t ftp)
static int
get_a_number(FTP_t ftp, char **q)
{
char *p;
while(1) {
p = get_a_line(ftp);
if (p[3] != ' ' && p[3] != ' ')
continue;
return atoi(p);
char *p;
int i = -1,j;
while(1) {
p = get_a_line(ftp);
if (!(isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2])))
continue;
if (i == -1 && p[3] == '-') {
i = atoi(p);
continue;
}
if (p[3] != ' ' && p[3] != '\t')
continue;
j = atoi(p);
if (i == -1) {
if (q) *q = p+4;
return j;
} else if (j == i) {
if (q) *q = p+4;
return j;
}
}
}
static int
botch(FTP_t ftp, char *func, char *state)
{
debug(ftp,"LIBFTP: Botch: %s called outside state %s\n",func,state);
writes(ftp->fd_ctrl,"QUIT\r\n");
close(ftp->fd_ctrl); ftp->fd_ctrl = -1;
close(ftp->fd_xfer); ftp->fd_xfer = -1;
ftp->state = init;
return -1;
}
static int
cmd(FTP_t ftp, const char *fmt, ...)
{
char p[BUFSIZ];
int i;
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
debug(ftp,"LIBFTP: send <%s>\n",p);
if (writes(ftp->fd_ctrl,p))
return -1;
if (writes(ftp->fd_ctrl,"\r\n"))
return -1;
i = get_a_number(ftp);
debug(ftp, "LIBFTP: got %d\n",i);
return i;
char p[BUFSIZ];
int i;
va_list ap;
va_start(ap, fmt);
(void) vsnprintf(p, sizeof p, fmt, ap);
va_end(ap);
debug(ftp,"LIBFTP: send <%s>\n",p);
strcat(p,"\r\n");
if (writes(ftp->fd_ctrl,p))
return -1;
i = get_a_number(ftp,0);
debug(ftp, "LIBFTP: got %d\n",i);
return i;
}
FTP_t
FtpInit()
{
FTP_t ftp;
ftp = malloc(sizeof *ftp);
if (!ftp)
return ftp;
memset(ftp, 0, sizeof *ftp);
ftp->fd_ctrl = -1;
ftp->fd_debug = -1;
FTP_t ftp;
ftp = malloc(sizeof *ftp);
if (!ftp)
return ftp;
memset(ftp, 0, sizeof *ftp);
ftp->fd_ctrl = -1;
ftp->fd_debug = -1;
ftp->state = init;
return ftp;
}
#if 0
#ifdef STANDALONE_FTP
void
FtpDebug(FTP_t ftp, int i)
{
ftp->fd_debug = i;
ftp->fd_debug = i;
}
#endif
int
FtpOpen(FTP_t ftp, char *host, char *user, char *passwd)
{
struct hostent *he, hdef;
struct servent *se, sdef;
struct sockaddr_in sin;
int s;
char a,*p,buf[BUFSIZ];
unsigned long temp;
if (!user)
user = "ftp";
if (!passwd)
passwd = "??@??(FreeBSD:libftp)"; /* XXX */
msgDebug("FtpOpen(ftp, %s, %s, %s)\n", host, user, passwd);
temp = inet_addr(host);
if (temp != INADDR_NONE)
struct hostent *he = NULL;
struct sockaddr_in sin;
int s;
unsigned long temp;
extern unsigned long inet_addr(char *);
int i;
if (ftp->state != init)
return botch(ftp,"FtpOpen","init");
if (!user)
user = "ftp";
if (!passwd)
passwd = "??@??(FreeBSD:libftp)"; /* XXX */
debug(ftp,"FtpOpen(ftp, %s, %s, %s)\n", host, user, passwd);
temp = inet_addr(host);
if (temp != INADDR_NONE)
{
debug(ftp,"Using dotted IP address `%s'\n", host);
ftp->addrtype = sin.sin_family = AF_INET;
sin.sin_addr.s_addr = temp;
} else {
debug(ftp,"Trying to resolve `%s'\n", host);
he = gethostbyname(host);
if (!he)
{
msgDebug("Using dotted IP address `%s'\n", host);
ftp->addrtype = sin.sin_family = AF_INET;
sin.sin_addr.s_addr = temp;
} else {
msgDebug("Trying to resolve `%s'\n", host);
he = gethostbyname(host);
if (!he)
{
msgDebug("Lookup of `%s' failed!\n", host);
return ENOENT;
}
ftp->addrtype = sin.sin_family = he->h_addrtype;
bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
debug(ftp,"Lookup of `%s' failed!\n", host);
return ENOENT;
}
sin.sin_port = htons(21);
if ((s = socket(he->h_addrtype, SOCK_STREAM, 0)) < 0)
return s;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
return -1;
}
ftp->fd_ctrl = s;
debug(ftp, "LIBFTP: open (%d)\n",get_a_number(ftp));
cmd(ftp,"USER %s",user);
cmd(ftp,"PASS %s",passwd);
return 0;
fail:
close(ftp->fd_ctrl);
ftp->fd_ctrl = -1;
ftp->addrtype = sin.sin_family = he->h_addrtype;
bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
}
sin.sin_port = htons(21);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
{
debug("Socket open failed: %s (%i)\n", strerror(errno), errno);
return s;
}
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
debug("Connection failed: %s (%i)\n", strerror(errno), errno);
(void)close(s);
return -1;
}
ftp->fd_ctrl = s;
debug(ftp, "LIBFTP: open (%d)\n",get_a_number(ftp,0));
i = cmd(ftp,"USER %s",user);
i = cmd(ftp,"PASS %s",passwd);
ftp->state = isopen;
return 0;
fail:
close(ftp->fd_ctrl);
ftp->fd_ctrl = -1;
return -1;
}
void
FtpClose(FTP_t ftp)
{
if (ftp->state != isopen)
botch(ftp,"FtpClose","open");
writes(ftp->fd_ctrl,"QUIT\r\n");
close(ftp->fd_ctrl); ftp->fd_ctrl = -1;
close(ftp->fd_xfer); ftp->fd_xfer = -1;
ftp->state = init;
}
int
FtpChdir(FTP_t ftp, char *dir)
{
cmd(ftp,"CWD %s",dir);
return 0;
int i;
if (ftp->state != isopen)
return botch(ftp,"FtpChdir","open");
i = cmd(ftp,"CWD %s",dir);
return 0;
}
int
FtpGet(FTP_t ftp, char *file)
{
int fd,i,j,s;
char p[BUFSIZ],*q;
unsigned char addr[6];
struct sockaddr_in sin;
if(ftp->binary) {
cmd(ftp,"TYPE I");
} else {
return -1;
int i,s;
char *q;
unsigned char addr[6];
struct sockaddr_in sin;
if (ftp->state != isopen)
return botch(ftp,"FtpGet","open");
if(ftp->binary) {
i = cmd(ftp,"TYPE I");
if (i > 299)
return -1;
} else {
return -1;
}
if(ftp->passive) {
if (writes(ftp->fd_ctrl,"PASV\r\n"))
return -1;
i = get_a_number(ftp,&q);
if (i != 227)
return -1;
while (*q && !isdigit(*q))
q++;
if (!*q)
return -1;
q--;
for(i=0;i<6;i++) {
q++;
addr[i] = strtol(q,&q,10);
}
if(ftp->passive) {
if (writes(ftp->fd_ctrl,"PASV\r\n"))
return -1;
q = get_a_line(ftp);
if (strncmp(q,"227 ",4))
return -1;
q = strchr(q,'(');
if (!q)
return -1;
for(i=0;i<6;i++) {
q++;
addr[i] = strtol(q,&q,10);
debug(ftp,"ADDR[%d] = %d (%c)\n",i,addr[i],*q);
}
if (*q != ')')
return -1;
sin.sin_family = ftp->addrtype;
bcopy(addr, (char *)&sin.sin_addr, 4);
bcopy(addr+4, (char *)&sin.sin_port, 2);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
return -1;
debug(ftp,"Getsocket = %d\n",s);
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
debug(ftp,"connect, errno = %d\n",errno);
return -1;
}
cmd(ftp,"RETR %s",file);
return s;
} else {
return -1;
sin.sin_family = ftp->addrtype;
bcopy(addr, (char *)&sin.sin_addr, 4);
bcopy(addr+4, (char *)&sin.sin_port, 2);
if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0)
return -1;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
(void)close(s);
debug(ftp,"connect, errno = %d\n",errno);
return -1;
}
i = cmd(ftp,"RETR %s",file);
if (i > 299)
return -1;
ftp->state = xfer;
return s;
} else {
return -1;
}
}
int
FtpEOF(FTP_t ftp)
{
get_a_number(ftp);
if (ftp->state != xfer)
return botch(ftp,"FtpEOF","xfer");
ftp->state = isopen;
return get_a_number(ftp,0);
}
#ifdef STANDALONE_FTP
@ -240,25 +316,35 @@ FtpEOF(FTP_t ftp)
int
main(int argc, char **argv)
{
FTP_t ftp;
int i;
char c;
ftp = FtpInit();
if (!ftp) err(1,"FtpInit()");
FtpDebug(ftp,1);
i = FtpOpen(ftp, "ref", "ftp", "phk-libftp@");
if (i) err(1,"FtpOpen(%d)",i);
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"CTM");
i = FtpGet(ftp,"README_CTM_MOVED");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
return 0;
FTP_t ftp;
int i;
char c;
ftp = FtpInit();
if (!ftp) err(1,"FtpInit()");
FtpDebug(ftp,1);
i = FtpOpen(ftp, "ref.tfs.com", "ftp", "phk-libftp@");
if (i) err(1,"FtpOpen(%d)",i);
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"CTM");
i = FtpGet(ftp,"README_CTM_MOVED");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
FtpClose(ftp);
i = FtpOpen(ftp, "freefall.cdrom.com", "ftp", "phk-libftp@");
FtpBinary(ftp,1);
FtpPassive(ftp,1);
FtpChdir(ftp,"/pub");
FtpChdir(ftp,"FreeBSD");
i = FtpGet(ftp,"README");
while(1 == read(i,&c,1))
putchar(c);
FtpEOF(ftp);
return 0;
}
#endif /*STANDALONE_FTP*/

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: install.c,v 1.49 1995/05/23 18:06:13 jkh Exp $
* $Id: install.c,v 1.50 1995/05/24 01:27:10 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -208,9 +208,9 @@ installFinal(void)
if (alreadyDone)
return;
config_fstab();
config_sysconfig();
config_resolv();
configFstab();
configSysconfig();
configResolv();
do_final_setup();
alreadyDone = TRUE;
SystemWasInstalled = TRUE;
@ -346,7 +346,6 @@ cpio_extract(void)
int i, j, zpid, cpid, pfd[2];
Boolean onCDROM = FALSE;
#if 0
if (mediaDevice && mediaDevice->type == DEVICE_TYPE_CDROM) {
if (mediaDevice->init) {
if ((*mediaDevice->init)(mediaDevice)) {
@ -358,7 +357,7 @@ cpio_extract(void)
}
}
}
#endif
tryagain:
while (CpioFD == -1) {
msgConfirm("Please Insert CPIO floppy in floppy drive 0");

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: label.c,v 1.21 1995/05/22 14:10:20 jkh Exp $
* $Id: label.c,v 1.22 1995/05/23 02:41:07 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -560,6 +560,12 @@ diskLabelEditor(char *str)
p = get_mountpoint(label_chunk_info[here].c);
if (p) {
p->newfs = FALSE;
if (label_chunk_info[here].type == PART_FAT
&& (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
|| !strcmp(p->mountpoint, "/var"))) {
msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
strcpy(p->mountpoint, "/bogus");
}
record_label_chunks();
}
break;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $Id: main.c,v 1.7 1995/05/16 11:37:17 jkh Exp $
* $Id: main.c,v 1.8 1995/05/17 14:39:49 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -64,6 +64,9 @@ main(int argc, char **argv)
/* Default to English */
lang_set_English(NULL);
/* Default to passive mode ftp since it's the only thing we currently support :-( */
variable_set2("ftpPassive", "yes");
/* Begin user dialog at outer menu */
while (1) {
choice = scroll = curr = max = 0;

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: media.c,v 1.14 1995/05/22 14:10:21 jkh Exp $
* $Id: media.c,v 1.15 1995/05/23 02:41:09 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -86,9 +86,7 @@ mediaSetCDROM(char *str)
/* This may need to be extended a little, but the basic idea is sound */
strcpy(bootCD.name, "bootCD");
bootCD.type = DEVICE_TYPE_CDROM;
bootCD.init = NULL;
bootCD.get = mediaGetCDROM;
bootCD.close = NULL;
mediaDevice = &bootCD;
return 1;
}
@ -197,7 +195,7 @@ mediaSetDOS(char *str)
if (c1->type == fat) {
/* Got one! */
mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, mediaCloseDOS, NULL);
mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
break;
}
@ -267,7 +265,7 @@ mediaSetFTP(char *str)
ftpDevice.type = DEVICE_TYPE_NETWORK;
ftpDevice.init = mediaInitFTP;
ftpDevice.get = mediaGetFTP;
ftpDevice.close = mediaCloseFTP;
ftpDevice.shutdown = mediaShutdownFTP;
ftpDevice.private = devp;
mediaDevice = &ftpDevice;
return 1;

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: menus.c,v 1.25 1995/05/23 02:41:13 jkh Exp $
* $Id: menus.c,v 1.26 1995/05/24 01:27:12 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -644,17 +644,43 @@ your FreeBSD system more generally usable and which may be selected\n\
from the menu below. When you're done, select Cancel.",
"Press F1 for more information on these options",
"configure.hlp",
{ { "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Add User", "Add users to the system",
{ { "Add User", "Add users to the system",
DMENU_SYSTEM_COMMAND, "adduser", 0, 0 },
{ "Root Pass", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Time Zone", "Set which time zone you're in",
DMENU_SYSTEM_COMMAND, "tzsetup", 0, 0 },
{ "Packages", "Install extra FreeBSD packaged software",
DMENU_CALL, config_packages, 0, 1 },
DMENU_CALL, configPackages, 0, 1 },
{ "Ports", "Enable the FreeBSD Ports Collection from CD",
DMENU_CALL, config_ports, 0, 1 },
DMENU_CALL, configPorts, 0, 1 },
{ "Root Password", "Set the system manager's password",
DMENU_SYSTEM_COMMAND, "passwd root", 0, 0 },
{ "Screen", "Customize system console behavior",
DMENU_SUBMENU, &MenuSyscons, 0, 0 },
{ "Sysconfig", "Edit the system configuration file (with vi)",
DMENU_SYSTEM_COMMAND, "vi /etc/sysconfig", 0, 0 },
{ "XFree86", "Configure XFree86 (if installed)",
DMENU_SYSTEM_COMMAND, "PATH=/usr/bin:/bin:/usr/X11R6/bin xf86config", 0, 0 },
{ NULL } },
};
DMenu MenuSyscons = {
DMENU_NORMAL_TYPE,
"System Console Configuration",
"The default system console driver for FreeBSD (syscons) has a\n\
number of configuration options which may be set according to\n\
your preference. When you are done setting configuration options,\n\
select Cancel.",
NULL,
NULL,
{ { "blank", "Screen-blanking saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Green", "\"green\" power saver (if supported by monitor)",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Snake", "\"snake\" screen saver",
DMENU_SET_VARIABLE, "saver=snake", 0, 0 },
{ "Star", "\"twinkling stars\" screen saver",
DMENU_SET_VARIABLE, "saver=star", 0, 0 },
{ "Timeout", "Set screen saver timeout interval",
DMENU_CALL, configSaverTimeout, 0, 0 },
{ NULL } },
};

View file

@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $Id: msg.c,v 1.22 1995/05/22 14:10:25 jkh Exp $
* $Id: msg.c,v 1.23 1995/05/23 02:41:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -100,6 +100,7 @@ msgInfo(char *fmt, ...)
attrset(A_REVERSE);
mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, line);
attrset(attrs);
move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79);
refresh();
if (OnVTY) {
msgDebug("Information: `%s'\n", errstr);

View file

@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $Id: sysinstall.h,v 1.28 1995/05/23 18:06:16 jkh Exp $
* $Id: sysinstall.h,v 1.29 1995/05/24 01:27:14 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@ -159,8 +159,9 @@ typedef struct _device {
DeviceType type;
Boolean enabled;
Boolean (*init)(struct _device *);
Boolean (*get)(char *fname);
void (*close)(struct _device *);
int (*get)(char *fname);
Boolean (*close)(struct _device *, int fd);
void (*shutdown)(struct _device *);
void *private;
} Device;
@ -216,6 +217,7 @@ extern DMenu MenuMediaFloppy; /* Floppy media menu */
extern DMenu MenuMediaFTP; /* FTP media menu */
extern DMenu MenuMediaTape; /* Tape media menu */
extern DMenu MenuNetworkDevice; /* Network device menu */
extern DMenu MenuSyscons; /* System console configuration menu */
extern DMenu MenuInstall; /* Installation menu */
extern DMenu MenuInstallType; /* Installation type menu */
extern DMenu MenuDistributions; /* Distribution menu */
@ -238,11 +240,12 @@ extern void command_shell_add(char *key, char *fmt, ...);
extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
extern void config_fstab(void);
extern void config_sysconfig(void);
extern void config_resolv(void);
extern int config_ports(char *str);
extern int config_packages(char *str);
extern void configFstab(void);
extern void configSysconfig(void);
extern void configResolv(void);
extern int configPorts(char *str);
extern int configPackages(char *str);
extern int configSaverTimeout(char *str);
/* decode.c */
extern DMenuItem *decode(DMenu *menu, char *name);
@ -256,8 +259,9 @@ extern Device **deviceFind(char *name, DeviceType type);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev), Boolean (*get)(char *distname),
void (*close)(Device *mediadev), void *private);
Boolean (*init)(Device *mediadev), int (*get)(char *distname),
Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev),
void *private);
/* disks.c */
extern int diskPartitionEditor(char *unused);
@ -338,12 +342,12 @@ extern int mediaGetFloppy(char *dist);
extern int mediaGetFTP(char *dist);
extern int mediaGetTape(char *dist);
extern int mediaGetUFS(char *dist);
extern void mediaCloseCDROM(Device *dev);
extern void mediaCloseDOS(Device *dev);
extern void mediaCloseFTP(Device *dev);
extern void mediaCloseFloppy(Device *dev);
extern void mediaCloseNetwork(Device *dev);
extern void mediaCloseTape(Device *dev);
extern void mediaShutdownCDROM(Device *dev);
extern void mediaShutdownDOS(Device *dev);
extern void mediaShutdownFTP(Device *dev);
extern void mediaShutdownFloppy(Device *dev);
extern void mediaShutdownNetwork(Device *dev);
extern void mediaShutdownTape(Device *dev);
/* misc.c */
extern Boolean file_readable(char *fname);