From c97113d14f96c09d523fd1b51ffff9266720f2f7 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sun, 28 Apr 1996 20:54:11 +0000 Subject: [PATCH] Add a new -fake argument to make sysinstall not actually change things while I'm testing it. --- release/sysinstall/config.c | 22 ++++---- release/sysinstall/disks.c | 4 +- release/sysinstall/ftp.c | 83 ++++++++++++++-------------- release/sysinstall/globals.c | 16 +++--- release/sysinstall/install.c | 12 ++-- release/sysinstall/installUpgrade.c | 29 +++++++--- release/sysinstall/main.c | 14 +++-- release/sysinstall/network.c | 7 ++- release/sysinstall/sysinstall.h | 3 +- release/sysinstall/system.c | 13 ++++- release/sysinstall/wizard.c | 4 +- usr.sbin/sade/config.c | 22 ++++---- usr.sbin/sade/disks.c | 4 +- usr.sbin/sade/globals.c | 16 +++--- usr.sbin/sade/install.c | 12 ++-- usr.sbin/sade/main.c | 14 +++-- usr.sbin/sade/sade.h | 3 +- usr.sbin/sade/system.c | 13 ++++- usr.sbin/sade/wizard.c | 4 +- usr.sbin/sysinstall/config.c | 22 ++++---- usr.sbin/sysinstall/disks.c | 4 +- usr.sbin/sysinstall/ftp.c | 83 ++++++++++++++-------------- usr.sbin/sysinstall/globals.c | 16 +++--- usr.sbin/sysinstall/install.c | 12 ++-- usr.sbin/sysinstall/installUpgrade.c | 29 +++++++--- usr.sbin/sysinstall/main.c | 14 +++-- usr.sbin/sysinstall/network.c | 7 ++- usr.sbin/sysinstall/sysinstall.h | 3 +- usr.sbin/sysinstall/system.c | 13 ++++- usr.sbin/sysinstall/wizard.c | 4 +- 30 files changed, 298 insertions(+), 204 deletions(-) diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c index 22fc8017a3e6..c1956025a3e4 100644 --- a/release/sysinstall/config.c +++ b/release/sysinstall/config.c @@ -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.26 1996/04/28 01:07:21 jkh Exp $ + * $Id: config.c,v 1.27 1996/04/28 03:26:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -581,16 +581,16 @@ configNFSServer(dialogMenuItem *self) "an /etc/exports file to indicate which hosts are allowed certain\n" "kinds of access to your local file systems.\n" "Press [ENTER] now to invoke an editor on /etc/exports\n"); - system("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); - system("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); - system("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); - system("echo '#/usr huey louie dewie' >> /etc/exports"); - system("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); - system("echo '#/a -maproot=0 bill albert' >> /etc/exports"); - system("echo '#' >> /etc/exports"); - system("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); - system("echo >> /etc/exports"); - sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); + vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); + vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); + vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); + vsystem("echo '#/usr huey louie dewie' >> /etc/exports"); + vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); + vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports"); + vsystem("echo '#' >> /etc/exports"); + vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); + vsystem("echo >> /etc/exports"); + vsprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); dialog_clear(); systemExecute(cmd); restorescr(w); diff --git a/release/sysinstall/disks.c b/release/sysinstall/disks.c index 0c62dacbf851..79f58817e23a 100644 --- a/release/sysinstall/disks.c +++ b/release/sysinstall/disks.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: disks.c,v 1.43 1996/04/28 00:37:28 jkh Exp $ + * $Id: disks.c,v 1.44 1996/04/28 03:26:49 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -502,7 +502,7 @@ diskPartitionWrite(dialogMenuItem *self) Set_Boot_Blocks(d, boot1, boot2); msgNotify("Writing partition information to drive %s", d->name); - if (Write_Disk(d)) { + if (!Fake && Write_Disk(d)) { msgConfirm("ERROR: Unable to write data to disk %s!", d->name); return DITEM_FAILURE; } diff --git a/release/sysinstall/ftp.c b/release/sysinstall/ftp.c index e4b2c3eb5e04..0668416480ac 100644 --- a/release/sysinstall/ftp.c +++ b/release/sysinstall/ftp.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ftp.c,v 1.14.2.1 1995/10/21 14:06:35 jkh Exp $ + * $Id: ftp.c,v 1.15 1995/12/07 10:33:47 peter Exp $ * * Return values have been sanitized: * -1 error, but you (still) have a session. @@ -49,9 +49,9 @@ debug(FTP_t ftp, const char *fmt, ...) va_start(ap, fmt); #ifdef STANDALONE_FTP strcpy(p,"LIBFTP: "); - (void) vsnprintf(p+strlen(p), sizeof p - strlen(p), fmt, ap); + (void) vsnprintf(p + strlen(p), sizeof p - strlen(p), fmt, ap); va_end(ap); - write(ftp->fd_debug,p,strlen(p)); + write(ftp->fd_debug, p, strlen(p)); #else if (isDebug()) { (void) vsnprintf(p, sizeof p - strlen(p), fmt, ap); @@ -64,7 +64,7 @@ static int writes(int fd, char *s) { int i = strlen(s); - if (i != write(fd,s,i)) + if (i != write(fd, s, i)) return -2; return 0; } @@ -76,14 +76,14 @@ get_a_line(FTP_t ftp) int i,j; for(i=0;ifd_ctrl,buf+i,1); + 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, "received <%s>\n",buf); + debug(ftp, "received <%s>\n", buf); return buf; } i++; @@ -152,11 +152,11 @@ cmd(FTP_t ftp, const char *fmt, ...) (void) vsnprintf(p, sizeof p, fmt, ap); va_end(ap); - debug(ftp, "send <%s>\n",p); + debug(ftp, "send <%s>\n", p); strcat(p,"\r\n"); - if (writes(ftp->fd_ctrl,p)) + if (writes(ftp->fd_ctrl, p)) return -2; - i = get_a_number(ftp,0); + i = get_a_number(ftp, 0); return i; } @@ -239,11 +239,12 @@ FtpOpen(FTP_t ftp, char *host, char *user, char *passwd) debug(ftp, "open (%d)\n",get_a_number(ftp,0)); - i = cmd(ftp,"USER %s",user); + i = cmd(ftp, "USER %s", user); if (i >= 300 && i < 400) i = cmd(ftp,"PASS %s",passwd); if (i >= 299 || i < 0) { - close(ftp->fd_ctrl); ftp->fd_ctrl = -1; + close(ftp->fd_ctrl); + ftp->fd_ctrl = -1; return zap(ftp); } ftp->state = isopen; @@ -267,9 +268,10 @@ int FtpChdir(FTP_t ftp, char *dir) { int i; + if (ftp->state != isopen) return botch(ftp,"FtpChdir","open"); - i = cmd(ftp,"CWD %s",dir); + i = cmd(ftp, "CWD %s", dir); if (i < 0) return i; else if (i != 250) @@ -286,27 +288,27 @@ FtpGet(FTP_t ftp, char *file) struct sockaddr_in sin; u_long a; - debug(ftp, "FtpGet(ftp,%s)\n",file); + debug(ftp, "FtpGet(ftp,%s)\n", file); if (ftp->state != isopen) - return botch(ftp,"FtpGet","open"); - if(ftp->binary) { - i = cmd(ftp,"TYPE I"); + return botch(ftp, "FtpGet", "open"); + if (ftp->binary) { + i = cmd(ftp, "TYPE I"); if (i < 0 || FTP_TIMEOUT(i)) return zap(ftp); if (i > 299) return -1; - } else { - return -1; } + else + return -1; if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0) return zap(ftp); if (ftp->passive) { - debug(ftp, "send <%s>\n","PASV"); - if (writes(ftp->fd_ctrl,"PASV\r\n")) + debug(ftp, "send <%s>\n", "PASV"); + if (writes(ftp->fd_ctrl, "PASV\r\n")) return zap(ftp); - i = get_a_number(ftp,&q); + i = get_a_number(ftp, &q); if (i < 0) return zap(ftp); if (i != 227) @@ -316,14 +318,14 @@ FtpGet(FTP_t ftp, char *file) if (!*q) return zap(ftp); q--; - for(i=0;i<6;i++) { + for(i = 0; i < 6; i++) { q++; - addr[i] = strtol(q,&q,10); + addr[i] = strtol(q, &q, 10); } sin.sin_family = ftp->addrtype; bcopy(addr, (char *)&sin.sin_addr, 4); - bcopy(addr+4, (char *)&sin.sin_port, 2); + bcopy(addr + 4, (char *)&sin.sin_port, 2); debug(ftp, "Opening active socket to %s : %u\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); debug(ftp, "Connecting to %s:%u\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); @@ -333,7 +335,7 @@ FtpGet(FTP_t ftp, char *file) return -1; } ftp->fd_xfer = s; - i = cmd(ftp,"RETR %s",file); + i = cmd(ftp,"RETR %s", file); if (i < 0 || FTP_TIMEOUT(i)) { close(s); return zap(ftp); @@ -348,31 +350,31 @@ FtpGet(FTP_t ftp, char *file) return s; } else { i = sizeof sin; - getsockname(ftp->fd_ctrl,(struct sockaddr *)&sin,&i); + getsockname(ftp->fd_ctrl, (struct sockaddr *)&sin, &i); sin.sin_port = 0; i = sizeof sin; if (bind(s,(struct sockaddr *)&sin, i) < 0) { - close (s); - debug(ftp,"bind failed %d\n",errno); - return zap(ftp); + close (s); + debug(ftp, "bind failed %d\n", errno); + return zap(ftp); } - getsockname(s,(struct sockaddr *)&sin,&i); - if (listen(s,1) < 0) { - close (s); - debug(ftp,"listen failed %d\n",errno); - return zap(ftp); + getsockname(s, (struct sockaddr *)&sin, &i); + if (listen(s, 1) < 0) { + close (s); + debug(ftp, "listen failed %d\n", errno); + return zap(ftp); } a = ntohl(sin.sin_addr.s_addr); - i = cmd(ftp,"PORT %d,%d,%d,%d,%d,%d", + i = cmd(ftp, "PORT %d,%d,%d,%d,%d,%d", (a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, - a & 0xff, + a & 0xff, (ntohs(sin.sin_port) >> 8) & 0xff, - ntohs(sin.sin_port) & 0xff); + ntohs(sin.sin_port) & 0xff); if (i != 200) return -1; - i = cmd(ftp,"RETR %s",file); + i = cmd(ftp,"RETR %s", file); if (i < 0) { close(s); return zap(ftp); @@ -403,9 +405,10 @@ FtpEOF(FTP_t ftp) int i; if (ftp->state != xfer) - return botch(ftp,"FtpEOF","xfer"); + return botch(ftp, "FtpEOF", "xfer"); debug(ftp, "FtpEOF(ftp)\n"); - close(ftp->fd_xfer); ftp->fd_xfer = -1; + close(ftp->fd_xfer); + ftp->fd_xfer = -1; ftp->state = isopen; i = get_a_number(ftp,0); if (i < 0) diff --git a/release/sysinstall/globals.c b/release/sysinstall/globals.c index c528b635b8da..7e10877f077a 100644 --- a/release/sysinstall/globals.c +++ b/release/sysinstall/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.11 1995/12/07 10:33:50 peter Exp $ + * $Id: globals.c,v 1.12 1996/04/13 13:31:38 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -41,14 +41,15 @@ * whatever values we feel are appropriate. */ -int DebugFD; /* Where diagnostic output goes */ +int DebugFD; /* Where diagnostic output goes */ +Boolean Fake; /* Only pretend to be useful */ Boolean RunningAsInit; /* Are we running as init? */ -Boolean DialogActive; -Boolean ColorDisplay; -Boolean OnVTY; -Variable *VarHead; /* The head of the variable chain */ +Boolean DialogActive; /* Is libdialog initialized? */ +Boolean ColorDisplay; /* Are we on a color display? */ +Boolean OnVTY; /* Are we on a VTY? */ +Variable *VarHead; /* The head of the variable chain */ Device *mediaDevice; /* Where we're installing from */ -int BootMgr; +int BootMgr; /* Which boot manager we're using */ /* * Yes, I know some of these are already automatically initialized as @@ -59,6 +60,7 @@ globalsInit(void) { DebugFD = -1; ColorDisplay = FALSE; + Fake = FALSE; OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index 524b5c1935e4..ce36a3a92243 100644 --- a/release/sysinstall/install.c +++ b/release/sysinstall/install.c @@ -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.88 1996/04/28 01:07:22 jkh Exp $ + * $Id: install.c,v 1.89 1996/04/28 03:27:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -159,7 +159,8 @@ installInitial(void) return DITEM_SUCCESS; if (!variable_get(DISK_LABELLED)) { - msgConfirm("You need to assign disk labels before you can proceed with\nthe installation."); + msgConfirm("You need to assign disk labels before you can proceed with\n" + "the installation."); return DITEM_FAILURE; } /* If it's labelled, assume it's also partitioned */ @@ -518,7 +519,7 @@ installFixup(dialogMenuItem *self) if (!file_readable("/kernel")) { if (file_readable("/kernel.GENERIC")) { - if (system("cp -p /kernel.GENERIC /kernel")) { + if (vsystem("cp -p /kernel.GENERIC /kernel")) { msgConfirm("Unable to link /kernel into place!"); return DITEM_FAILURE; } @@ -567,8 +568,8 @@ installFixup(dialogMenuItem *self) msgNotify("Fixing permissions.."); /* BOGON #1: XFree86 extracting /usr/X11R6 with root-only perms */ if (directory_exists("/usr/X11R6")) { - system("chmod -R a+r /usr/X11R6"); - system("find /usr/X11R6 -type d | xargs chmod a+x"); + vsystem("chmod -R a+r /usr/X11R6"); + vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); } /* BOGON #2: We leave /etc in a bad state */ chmod("/etc", 0755); @@ -729,6 +730,7 @@ installFilesystems(dialogMenuItem *self) return DITEM_SUCCESS; } +/* Initialize various user-settable values to their defaults */ int installVarDefaults(dialogMenuItem *self) { diff --git a/release/sysinstall/installUpgrade.c b/release/sysinstall/installUpgrade.c index 562302eb7387..8d15c82762c4 100644 --- a/release/sysinstall/installUpgrade.c +++ b/release/sysinstall/installUpgrade.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: installUpgrade.c,v 1.22 1996/04/25 17:31:20 jkh Exp $ + * $Id: installUpgrade.c,v 1.23 1996/04/28 03:27:05 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -264,7 +264,10 @@ installUpgrade(dialogMenuItem *self) if (!rootExtract()) { msgConfirm("Failed to load the ROOT distribution. Please correct\n" "this problem and try again (the system will now reboot)."); - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } if (extractingBin) { @@ -284,13 +287,16 @@ installUpgrade(dialogMenuItem *self) (void)vsystem("cp -pr /etc/* %s", saved_etc); } if (file_readable("/kernel")) { - msgNotify("Moving old kernel to /kernel.205"); - if (system("chflags noschg /kernel && mv /kernel /kernel.205")) { + msgNotify("Moving old kernel to /kernel.prev"); + if (system("chflags noschg /kernel && mv /kernel /kernel.prev")) { if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n" "treat this as a big problem and abort the upgrade? Due to the\n" "way that this upgrade process works, you will have to reboot\n" "and start over from the beginning. Select Yes to reboot now")) { - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } } } @@ -303,7 +309,10 @@ installUpgrade(dialogMenuItem *self) "should be considered a failure and started from the beginning, sorry!\n" "The system will reboot now."); dialog_clear(); - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } msgConfirm("The extraction process seems to have had some problems, but we got most\n" "of the essentials. We'll treat this as a warning since it may have been\n" @@ -359,9 +368,13 @@ installUpgrade(dialogMenuItem *self) msgDebug("Unable to get the terminal attributes!\n"); printf("Well, good luck! When you're done, please type \"reboot\" or exit\n" "the shell to reboot the new system.\n"); - execlp("sh", "-sh", 0); + if (!Fake) + execlp("sh", "-sh", 0); + else + exit(0); msgDebug("Was unable to execute sh for post-upgrade shell!\n"); - reboot(0); + if (RunningAsInit) + reboot(0); /* NOTREACHED */ return 0; } diff --git a/release/sysinstall/main.c b/release/sysinstall/main.c index f956d135d25e..deb8524dff47 100644 --- a/release/sysinstall/main.c +++ b/release/sysinstall/main.c @@ -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.16 1996/04/07 03:52:31 jkh Exp $ + * $Id: main.c,v 1.17 1996/04/13 13:31:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -65,6 +65,15 @@ main(int argc, char **argv) /* Set up whatever things need setting up */ systemInitialize(argc, argv); + /* Set default flag and variable values */ + installVarDefaults(NULL); + + if (argc > 1 && !strcmp(argv[1], "-fake")) { + variable_set2(VAR_DEBUG, "YES"); + Fake = TRUE; + msgConfirm("I'll be just faking it from here on out, OK?"); + } + /* Try to preserve our scroll-back buffer */ if (OnVTY) for (curr = 0; curr < 25; curr++) @@ -73,9 +82,6 @@ main(int argc, char **argv) /* Probe for all relevant devices on the system */ deviceGetAll(); - /* Set default flag and variable values */ - installVarDefaults(NULL); - /* Begin user dialog at outer menu */ while (1) { choice = scroll = curr = max = 0; diff --git a/release/sysinstall/network.c b/release/sysinstall/network.c index f1d7c3082ffe..03493214d5fb 100644 --- a/release/sysinstall/network.c +++ b/release/sysinstall/network.c @@ -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: network.c,v 1.10 1996/04/13 13:32:03 jkh Exp $ + * $Id: network.c,v 1.11 1996/04/23 01:29:29 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -177,7 +177,7 @@ startPPP(Device *devp) int fd2; FILE *fp; char *val; - pid_t pid; + pid_t pid = 0; char myaddr[16], provider[16], speed[16]; /* These are needed to make ppp work */ @@ -233,7 +233,8 @@ startPPP(Device *devp) msgConfirm("Warning: No /dev/tun0 device. PPP will not work!"); return 0; } - if (!(pid = fork())) { + + if (!Fake && !(pid = fork())) { int i, fd; struct termios foo; extern int login_tty(int); diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index 62656419b65a..0ae55445e64b 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.h @@ -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.53 1996/04/28 00:37:36 jkh Exp $ + * $Id: sysinstall.h,v 1.54 1996/04/28 01:07:26 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -264,6 +264,7 @@ typedef struct _devPriv { /*** Externs ***/ extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean Fake; /* Don't actually modify anything - testing */ extern Boolean SystemWasInstalled; /* Did we install it? */ extern Boolean RunningAsInit; /* Are we running stand-alone? */ extern Boolean DialogActive; /* Is the dialog() stuff up? */ diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c index adb89e8ccb69..ff448ebc0914 100644 --- a/release/sysinstall/system.c +++ b/release/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.54 1996/04/28 01:07:27 jkh Exp $ + * $Id: system.c,v 1.55 1996/04/28 03:27:26 jkh Exp $ * * Jordan Hubbard * @@ -109,7 +109,12 @@ systemExecute(char *command) foo.c_cc[VERASE] = '\010'; tcsetattr(0, TCSANOW, &foo); } - status = system(command); + if (!Fake) + status = system(command); + else { + status = 0; + msgDebug("systemExecute: Faked execution of `%s'\n", command); + } DialogActive = TRUE; return status; } @@ -199,6 +204,10 @@ vsystem(char *fmt, ...) va_end(args); omask = sigblock(sigmask(SIGCHLD)); + if (Fake) { + msgDebug("vsystem: Faked execution of `%s'\n", cmd); + return 0; + } if (isDebug()) msgDebug("Executing command `%s'\n", cmd); pid = fork(); diff --git a/release/sysinstall/wizard.c b/release/sysinstall/wizard.c index 66e2233ddff0..ae6dc7859e2e 100644 --- a/release/sysinstall/wizard.c +++ b/release/sysinstall/wizard.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: wizard.c,v 1.6.2.1 1995/09/20 10:43:13 jkh Exp $ + * $Id: wizard.c,v 1.7 1995/12/07 10:34:25 peter Exp $ * */ @@ -208,7 +208,7 @@ slice_wizard(Disk *d) } if (!strcasecmp(*cmds,"write")) { printf("Write=%d\n", - Write_Disk(d)); + Fake ? 0 : Write_Disk(d)); Free_Disk(d); d = Open_Disk(d->name); continue; diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index 22fc8017a3e6..c1956025a3e4 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -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.26 1996/04/28 01:07:21 jkh Exp $ + * $Id: config.c,v 1.27 1996/04/28 03:26:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -581,16 +581,16 @@ configNFSServer(dialogMenuItem *self) "an /etc/exports file to indicate which hosts are allowed certain\n" "kinds of access to your local file systems.\n" "Press [ENTER] now to invoke an editor on /etc/exports\n"); - system("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); - system("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); - system("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); - system("echo '#/usr huey louie dewie' >> /etc/exports"); - system("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); - system("echo '#/a -maproot=0 bill albert' >> /etc/exports"); - system("echo '#' >> /etc/exports"); - system("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); - system("echo >> /etc/exports"); - sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); + vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); + vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); + vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); + vsystem("echo '#/usr huey louie dewie' >> /etc/exports"); + vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); + vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports"); + vsystem("echo '#' >> /etc/exports"); + vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); + vsystem("echo >> /etc/exports"); + vsprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); dialog_clear(); systemExecute(cmd); restorescr(w); diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c index 0c62dacbf851..79f58817e23a 100644 --- a/usr.sbin/sade/disks.c +++ b/usr.sbin/sade/disks.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: disks.c,v 1.43 1996/04/28 00:37:28 jkh Exp $ + * $Id: disks.c,v 1.44 1996/04/28 03:26:49 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -502,7 +502,7 @@ diskPartitionWrite(dialogMenuItem *self) Set_Boot_Blocks(d, boot1, boot2); msgNotify("Writing partition information to drive %s", d->name); - if (Write_Disk(d)) { + if (!Fake && Write_Disk(d)) { msgConfirm("ERROR: Unable to write data to disk %s!", d->name); return DITEM_FAILURE; } diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c index c528b635b8da..7e10877f077a 100644 --- a/usr.sbin/sade/globals.c +++ b/usr.sbin/sade/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.11 1995/12/07 10:33:50 peter Exp $ + * $Id: globals.c,v 1.12 1996/04/13 13:31:38 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -41,14 +41,15 @@ * whatever values we feel are appropriate. */ -int DebugFD; /* Where diagnostic output goes */ +int DebugFD; /* Where diagnostic output goes */ +Boolean Fake; /* Only pretend to be useful */ Boolean RunningAsInit; /* Are we running as init? */ -Boolean DialogActive; -Boolean ColorDisplay; -Boolean OnVTY; -Variable *VarHead; /* The head of the variable chain */ +Boolean DialogActive; /* Is libdialog initialized? */ +Boolean ColorDisplay; /* Are we on a color display? */ +Boolean OnVTY; /* Are we on a VTY? */ +Variable *VarHead; /* The head of the variable chain */ Device *mediaDevice; /* Where we're installing from */ -int BootMgr; +int BootMgr; /* Which boot manager we're using */ /* * Yes, I know some of these are already automatically initialized as @@ -59,6 +60,7 @@ globalsInit(void) { DebugFD = -1; ColorDisplay = FALSE; + Fake = FALSE; OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 524b5c1935e4..ce36a3a92243 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -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.88 1996/04/28 01:07:22 jkh Exp $ + * $Id: install.c,v 1.89 1996/04/28 03:27:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -159,7 +159,8 @@ installInitial(void) return DITEM_SUCCESS; if (!variable_get(DISK_LABELLED)) { - msgConfirm("You need to assign disk labels before you can proceed with\nthe installation."); + msgConfirm("You need to assign disk labels before you can proceed with\n" + "the installation."); return DITEM_FAILURE; } /* If it's labelled, assume it's also partitioned */ @@ -518,7 +519,7 @@ installFixup(dialogMenuItem *self) if (!file_readable("/kernel")) { if (file_readable("/kernel.GENERIC")) { - if (system("cp -p /kernel.GENERIC /kernel")) { + if (vsystem("cp -p /kernel.GENERIC /kernel")) { msgConfirm("Unable to link /kernel into place!"); return DITEM_FAILURE; } @@ -567,8 +568,8 @@ installFixup(dialogMenuItem *self) msgNotify("Fixing permissions.."); /* BOGON #1: XFree86 extracting /usr/X11R6 with root-only perms */ if (directory_exists("/usr/X11R6")) { - system("chmod -R a+r /usr/X11R6"); - system("find /usr/X11R6 -type d | xargs chmod a+x"); + vsystem("chmod -R a+r /usr/X11R6"); + vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); } /* BOGON #2: We leave /etc in a bad state */ chmod("/etc", 0755); @@ -729,6 +730,7 @@ installFilesystems(dialogMenuItem *self) return DITEM_SUCCESS; } +/* Initialize various user-settable values to their defaults */ int installVarDefaults(dialogMenuItem *self) { diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c index f956d135d25e..deb8524dff47 100644 --- a/usr.sbin/sade/main.c +++ b/usr.sbin/sade/main.c @@ -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.16 1996/04/07 03:52:31 jkh Exp $ + * $Id: main.c,v 1.17 1996/04/13 13:31:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -65,6 +65,15 @@ main(int argc, char **argv) /* Set up whatever things need setting up */ systemInitialize(argc, argv); + /* Set default flag and variable values */ + installVarDefaults(NULL); + + if (argc > 1 && !strcmp(argv[1], "-fake")) { + variable_set2(VAR_DEBUG, "YES"); + Fake = TRUE; + msgConfirm("I'll be just faking it from here on out, OK?"); + } + /* Try to preserve our scroll-back buffer */ if (OnVTY) for (curr = 0; curr < 25; curr++) @@ -73,9 +82,6 @@ main(int argc, char **argv) /* Probe for all relevant devices on the system */ deviceGetAll(); - /* Set default flag and variable values */ - installVarDefaults(NULL); - /* Begin user dialog at outer menu */ while (1) { choice = scroll = curr = max = 0; diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 62656419b65a..0ae55445e64b 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -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.53 1996/04/28 00:37:36 jkh Exp $ + * $Id: sysinstall.h,v 1.54 1996/04/28 01:07:26 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -264,6 +264,7 @@ typedef struct _devPriv { /*** Externs ***/ extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean Fake; /* Don't actually modify anything - testing */ extern Boolean SystemWasInstalled; /* Did we install it? */ extern Boolean RunningAsInit; /* Are we running stand-alone? */ extern Boolean DialogActive; /* Is the dialog() stuff up? */ diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index adb89e8ccb69..ff448ebc0914 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.54 1996/04/28 01:07:27 jkh Exp $ + * $Id: system.c,v 1.55 1996/04/28 03:27:26 jkh Exp $ * * Jordan Hubbard * @@ -109,7 +109,12 @@ systemExecute(char *command) foo.c_cc[VERASE] = '\010'; tcsetattr(0, TCSANOW, &foo); } - status = system(command); + if (!Fake) + status = system(command); + else { + status = 0; + msgDebug("systemExecute: Faked execution of `%s'\n", command); + } DialogActive = TRUE; return status; } @@ -199,6 +204,10 @@ vsystem(char *fmt, ...) va_end(args); omask = sigblock(sigmask(SIGCHLD)); + if (Fake) { + msgDebug("vsystem: Faked execution of `%s'\n", cmd); + return 0; + } if (isDebug()) msgDebug("Executing command `%s'\n", cmd); pid = fork(); diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c index 66e2233ddff0..ae6dc7859e2e 100644 --- a/usr.sbin/sade/wizard.c +++ b/usr.sbin/sade/wizard.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: wizard.c,v 1.6.2.1 1995/09/20 10:43:13 jkh Exp $ + * $Id: wizard.c,v 1.7 1995/12/07 10:34:25 peter Exp $ * */ @@ -208,7 +208,7 @@ slice_wizard(Disk *d) } if (!strcasecmp(*cmds,"write")) { printf("Write=%d\n", - Write_Disk(d)); + Fake ? 0 : Write_Disk(d)); Free_Disk(d); d = Open_Disk(d->name); continue; diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index 22fc8017a3e6..c1956025a3e4 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -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.26 1996/04/28 01:07:21 jkh Exp $ + * $Id: config.c,v 1.27 1996/04/28 03:26:46 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -581,16 +581,16 @@ configNFSServer(dialogMenuItem *self) "an /etc/exports file to indicate which hosts are allowed certain\n" "kinds of access to your local file systems.\n" "Press [ENTER] now to invoke an editor on /etc/exports\n"); - system("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); - system("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); - system("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); - system("echo '#/usr huey louie dewie' >> /etc/exports"); - system("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); - system("echo '#/a -maproot=0 bill albert' >> /etc/exports"); - system("echo '#' >> /etc/exports"); - system("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); - system("echo >> /etc/exports"); - sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); + vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports"); + vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports"); + vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports"); + vsystem("echo '#/usr huey louie dewie' >> /etc/exports"); + vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports"); + vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports"); + vsystem("echo '#' >> /etc/exports"); + vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports"); + vsystem("echo >> /etc/exports"); + vsprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR)); dialog_clear(); systemExecute(cmd); restorescr(w); diff --git a/usr.sbin/sysinstall/disks.c b/usr.sbin/sysinstall/disks.c index 0c62dacbf851..79f58817e23a 100644 --- a/usr.sbin/sysinstall/disks.c +++ b/usr.sbin/sysinstall/disks.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: disks.c,v 1.43 1996/04/28 00:37:28 jkh Exp $ + * $Id: disks.c,v 1.44 1996/04/28 03:26:49 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -502,7 +502,7 @@ diskPartitionWrite(dialogMenuItem *self) Set_Boot_Blocks(d, boot1, boot2); msgNotify("Writing partition information to drive %s", d->name); - if (Write_Disk(d)) { + if (!Fake && Write_Disk(d)) { msgConfirm("ERROR: Unable to write data to disk %s!", d->name); return DITEM_FAILURE; } diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c index e4b2c3eb5e04..0668416480ac 100644 --- a/usr.sbin/sysinstall/ftp.c +++ b/usr.sbin/sysinstall/ftp.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ftp.c,v 1.14.2.1 1995/10/21 14:06:35 jkh Exp $ + * $Id: ftp.c,v 1.15 1995/12/07 10:33:47 peter Exp $ * * Return values have been sanitized: * -1 error, but you (still) have a session. @@ -49,9 +49,9 @@ debug(FTP_t ftp, const char *fmt, ...) va_start(ap, fmt); #ifdef STANDALONE_FTP strcpy(p,"LIBFTP: "); - (void) vsnprintf(p+strlen(p), sizeof p - strlen(p), fmt, ap); + (void) vsnprintf(p + strlen(p), sizeof p - strlen(p), fmt, ap); va_end(ap); - write(ftp->fd_debug,p,strlen(p)); + write(ftp->fd_debug, p, strlen(p)); #else if (isDebug()) { (void) vsnprintf(p, sizeof p - strlen(p), fmt, ap); @@ -64,7 +64,7 @@ static int writes(int fd, char *s) { int i = strlen(s); - if (i != write(fd,s,i)) + if (i != write(fd, s, i)) return -2; return 0; } @@ -76,14 +76,14 @@ get_a_line(FTP_t ftp) int i,j; for(i=0;ifd_ctrl,buf+i,1); + 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, "received <%s>\n",buf); + debug(ftp, "received <%s>\n", buf); return buf; } i++; @@ -152,11 +152,11 @@ cmd(FTP_t ftp, const char *fmt, ...) (void) vsnprintf(p, sizeof p, fmt, ap); va_end(ap); - debug(ftp, "send <%s>\n",p); + debug(ftp, "send <%s>\n", p); strcat(p,"\r\n"); - if (writes(ftp->fd_ctrl,p)) + if (writes(ftp->fd_ctrl, p)) return -2; - i = get_a_number(ftp,0); + i = get_a_number(ftp, 0); return i; } @@ -239,11 +239,12 @@ FtpOpen(FTP_t ftp, char *host, char *user, char *passwd) debug(ftp, "open (%d)\n",get_a_number(ftp,0)); - i = cmd(ftp,"USER %s",user); + i = cmd(ftp, "USER %s", user); if (i >= 300 && i < 400) i = cmd(ftp,"PASS %s",passwd); if (i >= 299 || i < 0) { - close(ftp->fd_ctrl); ftp->fd_ctrl = -1; + close(ftp->fd_ctrl); + ftp->fd_ctrl = -1; return zap(ftp); } ftp->state = isopen; @@ -267,9 +268,10 @@ int FtpChdir(FTP_t ftp, char *dir) { int i; + if (ftp->state != isopen) return botch(ftp,"FtpChdir","open"); - i = cmd(ftp,"CWD %s",dir); + i = cmd(ftp, "CWD %s", dir); if (i < 0) return i; else if (i != 250) @@ -286,27 +288,27 @@ FtpGet(FTP_t ftp, char *file) struct sockaddr_in sin; u_long a; - debug(ftp, "FtpGet(ftp,%s)\n",file); + debug(ftp, "FtpGet(ftp,%s)\n", file); if (ftp->state != isopen) - return botch(ftp,"FtpGet","open"); - if(ftp->binary) { - i = cmd(ftp,"TYPE I"); + return botch(ftp, "FtpGet", "open"); + if (ftp->binary) { + i = cmd(ftp, "TYPE I"); if (i < 0 || FTP_TIMEOUT(i)) return zap(ftp); if (i > 299) return -1; - } else { - return -1; } + else + return -1; if ((s = socket(ftp->addrtype, SOCK_STREAM, 0)) < 0) return zap(ftp); if (ftp->passive) { - debug(ftp, "send <%s>\n","PASV"); - if (writes(ftp->fd_ctrl,"PASV\r\n")) + debug(ftp, "send <%s>\n", "PASV"); + if (writes(ftp->fd_ctrl, "PASV\r\n")) return zap(ftp); - i = get_a_number(ftp,&q); + i = get_a_number(ftp, &q); if (i < 0) return zap(ftp); if (i != 227) @@ -316,14 +318,14 @@ FtpGet(FTP_t ftp, char *file) if (!*q) return zap(ftp); q--; - for(i=0;i<6;i++) { + for(i = 0; i < 6; i++) { q++; - addr[i] = strtol(q,&q,10); + addr[i] = strtol(q, &q, 10); } sin.sin_family = ftp->addrtype; bcopy(addr, (char *)&sin.sin_addr, 4); - bcopy(addr+4, (char *)&sin.sin_port, 2); + bcopy(addr + 4, (char *)&sin.sin_port, 2); debug(ftp, "Opening active socket to %s : %u\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); debug(ftp, "Connecting to %s:%u\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); @@ -333,7 +335,7 @@ FtpGet(FTP_t ftp, char *file) return -1; } ftp->fd_xfer = s; - i = cmd(ftp,"RETR %s",file); + i = cmd(ftp,"RETR %s", file); if (i < 0 || FTP_TIMEOUT(i)) { close(s); return zap(ftp); @@ -348,31 +350,31 @@ FtpGet(FTP_t ftp, char *file) return s; } else { i = sizeof sin; - getsockname(ftp->fd_ctrl,(struct sockaddr *)&sin,&i); + getsockname(ftp->fd_ctrl, (struct sockaddr *)&sin, &i); sin.sin_port = 0; i = sizeof sin; if (bind(s,(struct sockaddr *)&sin, i) < 0) { - close (s); - debug(ftp,"bind failed %d\n",errno); - return zap(ftp); + close (s); + debug(ftp, "bind failed %d\n", errno); + return zap(ftp); } - getsockname(s,(struct sockaddr *)&sin,&i); - if (listen(s,1) < 0) { - close (s); - debug(ftp,"listen failed %d\n",errno); - return zap(ftp); + getsockname(s, (struct sockaddr *)&sin, &i); + if (listen(s, 1) < 0) { + close (s); + debug(ftp, "listen failed %d\n", errno); + return zap(ftp); } a = ntohl(sin.sin_addr.s_addr); - i = cmd(ftp,"PORT %d,%d,%d,%d,%d,%d", + i = cmd(ftp, "PORT %d,%d,%d,%d,%d,%d", (a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, - a & 0xff, + a & 0xff, (ntohs(sin.sin_port) >> 8) & 0xff, - ntohs(sin.sin_port) & 0xff); + ntohs(sin.sin_port) & 0xff); if (i != 200) return -1; - i = cmd(ftp,"RETR %s",file); + i = cmd(ftp,"RETR %s", file); if (i < 0) { close(s); return zap(ftp); @@ -403,9 +405,10 @@ FtpEOF(FTP_t ftp) int i; if (ftp->state != xfer) - return botch(ftp,"FtpEOF","xfer"); + return botch(ftp, "FtpEOF", "xfer"); debug(ftp, "FtpEOF(ftp)\n"); - close(ftp->fd_xfer); ftp->fd_xfer = -1; + close(ftp->fd_xfer); + ftp->fd_xfer = -1; ftp->state = isopen; i = get_a_number(ftp,0); if (i < 0) diff --git a/usr.sbin/sysinstall/globals.c b/usr.sbin/sysinstall/globals.c index c528b635b8da..7e10877f077a 100644 --- a/usr.sbin/sysinstall/globals.c +++ b/usr.sbin/sysinstall/globals.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: globals.c,v 1.11 1995/12/07 10:33:50 peter Exp $ + * $Id: globals.c,v 1.12 1996/04/13 13:31:38 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -41,14 +41,15 @@ * whatever values we feel are appropriate. */ -int DebugFD; /* Where diagnostic output goes */ +int DebugFD; /* Where diagnostic output goes */ +Boolean Fake; /* Only pretend to be useful */ Boolean RunningAsInit; /* Are we running as init? */ -Boolean DialogActive; -Boolean ColorDisplay; -Boolean OnVTY; -Variable *VarHead; /* The head of the variable chain */ +Boolean DialogActive; /* Is libdialog initialized? */ +Boolean ColorDisplay; /* Are we on a color display? */ +Boolean OnVTY; /* Are we on a VTY? */ +Variable *VarHead; /* The head of the variable chain */ Device *mediaDevice; /* Where we're installing from */ -int BootMgr; +int BootMgr; /* Which boot manager we're using */ /* * Yes, I know some of these are already automatically initialized as @@ -59,6 +60,7 @@ globalsInit(void) { DebugFD = -1; ColorDisplay = FALSE; + Fake = FALSE; OnVTY = FALSE; DialogActive = FALSE; VarHead = NULL; diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 524b5c1935e4..ce36a3a92243 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -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.88 1996/04/28 01:07:22 jkh Exp $ + * $Id: install.c,v 1.89 1996/04/28 03:27:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -159,7 +159,8 @@ installInitial(void) return DITEM_SUCCESS; if (!variable_get(DISK_LABELLED)) { - msgConfirm("You need to assign disk labels before you can proceed with\nthe installation."); + msgConfirm("You need to assign disk labels before you can proceed with\n" + "the installation."); return DITEM_FAILURE; } /* If it's labelled, assume it's also partitioned */ @@ -518,7 +519,7 @@ installFixup(dialogMenuItem *self) if (!file_readable("/kernel")) { if (file_readable("/kernel.GENERIC")) { - if (system("cp -p /kernel.GENERIC /kernel")) { + if (vsystem("cp -p /kernel.GENERIC /kernel")) { msgConfirm("Unable to link /kernel into place!"); return DITEM_FAILURE; } @@ -567,8 +568,8 @@ installFixup(dialogMenuItem *self) msgNotify("Fixing permissions.."); /* BOGON #1: XFree86 extracting /usr/X11R6 with root-only perms */ if (directory_exists("/usr/X11R6")) { - system("chmod -R a+r /usr/X11R6"); - system("find /usr/X11R6 -type d | xargs chmod a+x"); + vsystem("chmod -R a+r /usr/X11R6"); + vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); } /* BOGON #2: We leave /etc in a bad state */ chmod("/etc", 0755); @@ -729,6 +730,7 @@ installFilesystems(dialogMenuItem *self) return DITEM_SUCCESS; } +/* Initialize various user-settable values to their defaults */ int installVarDefaults(dialogMenuItem *self) { diff --git a/usr.sbin/sysinstall/installUpgrade.c b/usr.sbin/sysinstall/installUpgrade.c index 562302eb7387..8d15c82762c4 100644 --- a/usr.sbin/sysinstall/installUpgrade.c +++ b/usr.sbin/sysinstall/installUpgrade.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: installUpgrade.c,v 1.22 1996/04/25 17:31:20 jkh Exp $ + * $Id: installUpgrade.c,v 1.23 1996/04/28 03:27:05 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -264,7 +264,10 @@ installUpgrade(dialogMenuItem *self) if (!rootExtract()) { msgConfirm("Failed to load the ROOT distribution. Please correct\n" "this problem and try again (the system will now reboot)."); - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } if (extractingBin) { @@ -284,13 +287,16 @@ installUpgrade(dialogMenuItem *self) (void)vsystem("cp -pr /etc/* %s", saved_etc); } if (file_readable("/kernel")) { - msgNotify("Moving old kernel to /kernel.205"); - if (system("chflags noschg /kernel && mv /kernel /kernel.205")) { + msgNotify("Moving old kernel to /kernel.prev"); + if (system("chflags noschg /kernel && mv /kernel /kernel.prev")) { if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n" "treat this as a big problem and abort the upgrade? Due to the\n" "way that this upgrade process works, you will have to reboot\n" "and start over from the beginning. Select Yes to reboot now")) { - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } } } @@ -303,7 +309,10 @@ installUpgrade(dialogMenuItem *self) "should be considered a failure and started from the beginning, sorry!\n" "The system will reboot now."); dialog_clear(); - reboot(0); + if (RunningAsInit) + reboot(0); + else + exit(1); } msgConfirm("The extraction process seems to have had some problems, but we got most\n" "of the essentials. We'll treat this as a warning since it may have been\n" @@ -359,9 +368,13 @@ installUpgrade(dialogMenuItem *self) msgDebug("Unable to get the terminal attributes!\n"); printf("Well, good luck! When you're done, please type \"reboot\" or exit\n" "the shell to reboot the new system.\n"); - execlp("sh", "-sh", 0); + if (!Fake) + execlp("sh", "-sh", 0); + else + exit(0); msgDebug("Was unable to execute sh for post-upgrade shell!\n"); - reboot(0); + if (RunningAsInit) + reboot(0); /* NOTREACHED */ return 0; } diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c index f956d135d25e..deb8524dff47 100644 --- a/usr.sbin/sysinstall/main.c +++ b/usr.sbin/sysinstall/main.c @@ -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.16 1996/04/07 03:52:31 jkh Exp $ + * $Id: main.c,v 1.17 1996/04/13 13:31:51 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -65,6 +65,15 @@ main(int argc, char **argv) /* Set up whatever things need setting up */ systemInitialize(argc, argv); + /* Set default flag and variable values */ + installVarDefaults(NULL); + + if (argc > 1 && !strcmp(argv[1], "-fake")) { + variable_set2(VAR_DEBUG, "YES"); + Fake = TRUE; + msgConfirm("I'll be just faking it from here on out, OK?"); + } + /* Try to preserve our scroll-back buffer */ if (OnVTY) for (curr = 0; curr < 25; curr++) @@ -73,9 +82,6 @@ main(int argc, char **argv) /* Probe for all relevant devices on the system */ deviceGetAll(); - /* Set default flag and variable values */ - installVarDefaults(NULL); - /* Begin user dialog at outer menu */ while (1) { choice = scroll = curr = max = 0; diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c index f1d7c3082ffe..03493214d5fb 100644 --- a/usr.sbin/sysinstall/network.c +++ b/usr.sbin/sysinstall/network.c @@ -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: network.c,v 1.10 1996/04/13 13:32:03 jkh Exp $ + * $Id: network.c,v 1.11 1996/04/23 01:29:29 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -177,7 +177,7 @@ startPPP(Device *devp) int fd2; FILE *fp; char *val; - pid_t pid; + pid_t pid = 0; char myaddr[16], provider[16], speed[16]; /* These are needed to make ppp work */ @@ -233,7 +233,8 @@ startPPP(Device *devp) msgConfirm("Warning: No /dev/tun0 device. PPP will not work!"); return 0; } - if (!(pid = fork())) { + + if (!Fake && !(pid = fork())) { int i, fd; struct termios foo; extern int login_tty(int); diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 62656419b65a..0ae55445e64b 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -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.53 1996/04/28 00:37:36 jkh Exp $ + * $Id: sysinstall.h,v 1.54 1996/04/28 01:07:26 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -264,6 +264,7 @@ typedef struct _devPriv { /*** Externs ***/ extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean Fake; /* Don't actually modify anything - testing */ extern Boolean SystemWasInstalled; /* Did we install it? */ extern Boolean RunningAsInit; /* Are we running stand-alone? */ extern Boolean DialogActive; /* Is the dialog() stuff up? */ diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index adb89e8ccb69..ff448ebc0914 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.54 1996/04/28 01:07:27 jkh Exp $ + * $Id: system.c,v 1.55 1996/04/28 03:27:26 jkh Exp $ * * Jordan Hubbard * @@ -109,7 +109,12 @@ systemExecute(char *command) foo.c_cc[VERASE] = '\010'; tcsetattr(0, TCSANOW, &foo); } - status = system(command); + if (!Fake) + status = system(command); + else { + status = 0; + msgDebug("systemExecute: Faked execution of `%s'\n", command); + } DialogActive = TRUE; return status; } @@ -199,6 +204,10 @@ vsystem(char *fmt, ...) va_end(args); omask = sigblock(sigmask(SIGCHLD)); + if (Fake) { + msgDebug("vsystem: Faked execution of `%s'\n", cmd); + return 0; + } if (isDebug()) msgDebug("Executing command `%s'\n", cmd); pid = fork(); diff --git a/usr.sbin/sysinstall/wizard.c b/usr.sbin/sysinstall/wizard.c index 66e2233ddff0..ae6dc7859e2e 100644 --- a/usr.sbin/sysinstall/wizard.c +++ b/usr.sbin/sysinstall/wizard.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: wizard.c,v 1.6.2.1 1995/09/20 10:43:13 jkh Exp $ + * $Id: wizard.c,v 1.7 1995/12/07 10:34:25 peter Exp $ * */ @@ -208,7 +208,7 @@ slice_wizard(Disk *d) } if (!strcasecmp(*cmds,"write")) { printf("Write=%d\n", - Write_Disk(d)); + Fake ? 0 : Write_Disk(d)); Free_Disk(d); d = Open_Disk(d->name); continue;