diff options
author | jkh <jkh@FreeBSD.org> | 1997-01-15 06:30:50 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1997-01-15 06:30:50 +0000 |
commit | 0a45d47c6d7181202cb56c9f539c4c9d7d7f9db9 (patch) | |
tree | 29e7b8dbd6d713f6ae21cbd62c9ecfa9c1abbf3e /usr.sbin | |
parent | 754b3824315ef8a747c71d481aa623198b4a86e5 (diff) | |
download | FreeBSD-src-0a45d47c6d7181202cb56c9f539c4c9d7d7f9db9.zip FreeBSD-src-0a45d47c6d7181202cb56c9f539c4c9d7d7f9db9.tar.gz |
Make the FTP installation codepath a lot more defensive. Trap
bogus path and FTP I/O errors much earlier, offer retry possibilities
at steps along the way so you don't have to resume from the very beginning
again on a hard error.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/install.c | 36 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 12 | ||||
-rw-r--r-- | usr.sbin/sysinstall/ftp.c | 5 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 36 | ||||
-rw-r--r-- | usr.sbin/sysinstall/installUpgrade.c | 37 |
5 files changed, 92 insertions, 34 deletions
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 15059e8..0b44fcc 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -502,7 +502,7 @@ installNovice(dialogMenuItem *self) break; } - if (!mediaDevice && !dmenuOpenSimple(&MenuMedia, FALSE)) + if (!mediaDevice && (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)) return DITEM_FAILURE | DITEM_RECREATE; if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) { @@ -664,8 +664,31 @@ installCommit(dialogMenuItem *self) char *str; Boolean need_bin = FALSE; - if (!mediaVerify()) - return DITEM_FAILURE; + if (!Dists) { + if (!msgYesNo("No distributions are selected for installation! Do you\n" + "want to do this now?")) { + if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists) + return DITEM_FAILURE | DITEM_RECREATE; + } + else + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (!mediaDevice && !msgYesNo("You need to select a media type first. Do you want\n" + "to do this now?")) { + if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice) + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (!mediaDevice->init(mediaDevice)) { + if (!msgYesNo("Unable to initialize selected media. Would you like to\n" + "adjust your media configuration?")) { + if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice) + return DITEM_FAILURE | DITEM_RESTORE; + } + else + return DITEM_FAILURE | DITEM_RESTORE; + } str = variable_get(SYSTEM_STATE); if (isDebug()) @@ -682,9 +705,10 @@ installCommit(dialogMenuItem *self) if (Dists & DIST_BIN) need_bin = TRUE; i = distExtractAll(self); - if (DITEM_STATUS(i) != DITEM_FAILURE || !need_bin || !(Dists & DIST_BIN)) - i = installFixup(self); - + if (DITEM_STATUS(i) == DITEM_SUCCESS) { + if (!need_bin || !(Dists & DIST_BIN)) + i = installFixup(self); + } variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install"); return i | DITEM_RECREATE; } diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index c2f69fe..c8455f7 100644 --- a/usr.sbin/sysinstall/dist.c +++ b/usr.sbin/sysinstall/dist.c @@ -567,16 +567,10 @@ distExtractAll(dialogMenuItem *self) int retries = 0; char buf[512]; - /* First try to initialize the state of things */ - if (!Dists) { - msgConfirm("You haven't selected any distributions to extract."); - return DITEM_FAILURE; - } - if (!mediaVerify()) + /* paranoia */ + if (!Dists || !mediaVerify() || !mediaDevice->init(mediaDevice)) return DITEM_FAILURE; - if (!mediaDevice->init(mediaDevice)) - return DITEM_FAILURE; dialog_clear_norefresh(); msgNotify("Attempting to install all selected distributions.."); /* Try for 3 times around the loop, then give up. */ @@ -592,7 +586,7 @@ distExtractAll(dialogMenuItem *self) msgConfirm("Couldn't extract the following distributions. This may\n" "be because they were not available on the installation\n" "media you've chosen:\n\n\t%s", buf); - return DITEM_FAILURE | DITEM_RESTORE; + return DITEM_SUCCESS | DITEM_RESTORE; } return DITEM_SUCCESS; } diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c index 7746da7..f1e4304 100644 --- a/usr.sbin/sysinstall/ftp.c +++ b/usr.sbin/sysinstall/ftp.c @@ -102,7 +102,10 @@ try: ftpBinary(OpenConn); if (dir && *dir != '\0') { if ((i = ftpChdir(OpenConn, dir)) != 0) { - msgDebug("Attempt to chdir to distribution in %s returns error code %d\n", dir, i); + if (i == 550) + msgConfirm("No such directory %s, please check your path and try again.", dir); + else + msgConfirm("FTP chdir to directory %s returned FTP error status %d\n", dir, i); goto punt; } } diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 15059e8..0b44fcc 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -502,7 +502,7 @@ installNovice(dialogMenuItem *self) break; } - if (!mediaDevice && !dmenuOpenSimple(&MenuMedia, FALSE)) + if (!mediaDevice && (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)) return DITEM_FAILURE | DITEM_RECREATE; if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) { @@ -664,8 +664,31 @@ installCommit(dialogMenuItem *self) char *str; Boolean need_bin = FALSE; - if (!mediaVerify()) - return DITEM_FAILURE; + if (!Dists) { + if (!msgYesNo("No distributions are selected for installation! Do you\n" + "want to do this now?")) { + if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists) + return DITEM_FAILURE | DITEM_RECREATE; + } + else + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (!mediaDevice && !msgYesNo("You need to select a media type first. Do you want\n" + "to do this now?")) { + if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice) + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (!mediaDevice->init(mediaDevice)) { + if (!msgYesNo("Unable to initialize selected media. Would you like to\n" + "adjust your media configuration?")) { + if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice) + return DITEM_FAILURE | DITEM_RESTORE; + } + else + return DITEM_FAILURE | DITEM_RESTORE; + } str = variable_get(SYSTEM_STATE); if (isDebug()) @@ -682,9 +705,10 @@ installCommit(dialogMenuItem *self) if (Dists & DIST_BIN) need_bin = TRUE; i = distExtractAll(self); - if (DITEM_STATUS(i) != DITEM_FAILURE || !need_bin || !(Dists & DIST_BIN)) - i = installFixup(self); - + if (DITEM_STATUS(i) == DITEM_SUCCESS) { + if (!need_bin || !(Dists & DIST_BIN)) + i = installFixup(self); + } variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install"); return i | DITEM_RECREATE; } diff --git a/usr.sbin/sysinstall/installUpgrade.c b/usr.sbin/sysinstall/installUpgrade.c index 7877e68..09c73e9 100644 --- a/usr.sbin/sysinstall/installUpgrade.c +++ b/usr.sbin/sysinstall/installUpgrade.c @@ -198,18 +198,16 @@ installUpgrade(dialogMenuItem *self) msgConfirm("You haven't specified any distributions yet. The upgrade procedure will\n" "only upgrade those portions of the system for which a distribution has\n" "been selected. In the next screen, we'll go to the Distributions menu\n" - "to select those portions of 2.1 you wish to install on top of your 2.0.5\n" - "system."); - if (!dmenuOpenSimple(&MenuDistributions, FALSE)) + "to select those portions of the new system you wish to install on top of\n" + "the old."); + if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists) return DITEM_FAILURE | DITEM_RECREATE; dialog_clear_norefresh(); } - - /* No bin selected? Not much of an upgrade.. */ - if (!(Dists & DIST_BIN)) { + else if (!(Dists & DIST_BIN)) { /* No bin selected? Not much of an upgrade.. */ if (msgYesNo("You didn't select the bin distribution as one of the distributons to load.\n" "This one is pretty vital to a successful upgrade. Are you SURE you don't\n" - "want to select the bin distribution? Chose _No_ to bring up the Distributions\n" + "want to select the bin distribution? Chose No to bring up the Distributions\n" "menu.") != 0) { if (!dmenuOpenSimple(&MenuDistributions, FALSE)) return DITEM_FAILURE | DITEM_RECREATE; @@ -221,12 +219,18 @@ installUpgrade(dialogMenuItem *self) if (!(Dists & DIST_BIN)) extractingBin = FALSE; - if (!mediaDevice) { + if (!mediaVerify()) { msgConfirm("Now you must specify an installation medium for the upgrade."); if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice) return DITEM_FAILURE | DITEM_RECREATE; } + if (!mediaDevice->init(mediaDevice)) { + msgConfirm("Couldn't initialize the media; upgrade aborted. Please\n" + "fix whatever the problem is and try again."); + return DITEM_FAILURE | DITEM_REDRAW; + } + if (RunningAsInit) { Device **devs; int i, cnt; @@ -316,16 +320,25 @@ installUpgrade(dialogMenuItem *self) msgNotify("Beginning extraction of distributions.."); if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) { - if (extractingBin && (Dists & DIST_BIN)) { + msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" + "should be considered a failure and started from the beginning, sorry!\n" + "The system will reboot now."); + dialog_clear(); + systemShutdown(1); + } + else { + if (extractingBin && !(Dists & DIST_BIN)) { + 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" + "only non-essential distributions which failed to load."); + } + else { msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" "should be considered a failure and started from the beginning, sorry!\n" "The system will reboot now."); dialog_clear(); systemShutdown(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" - "only non-essential distributions which failed to load."); } if (extractingBin) { |