summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2008-12-04 17:22:56 -1000
committerDavid Cantrell <dcantrell@redhat.com>2008-12-05 10:42:17 -1000
commitc7142dfee35eb97d484bca4cab4d01bdfa5dac62 (patch)
treef03fd52d7651e6f8edb1a9c28227a066cdb135cf
parent6bd08c935dd49f229df3f93016d159bc9422e8b6 (diff)
downloadanaconda-c7142dfee35eb97d484bca4cab4d01bdfa5dac62.tar.gz
anaconda-c7142dfee35eb97d484bca4cab4d01bdfa5dac62.tar.xz
anaconda-c7142dfee35eb97d484bca4cab4d01bdfa5dac62.zip
Prevent network install when no network devices are found (#470144)
A corner case, but if a user boots up with boot.iso and has no network devices available, we get all the way to package selection and user is told they cannot continue. This is after all of the other screens and partitioning. In the welcome screen, perform a check to see if the user has booted the installer to a point where it requires a network install for the packages. If so, tell the user they cannot continue and exit the installer.
-rwxr-xr-xanaconda21
-rwxr-xr-xisys/isys.py7
-rw-r--r--iw/welcome_gui.py21
-rw-r--r--textw/welcome_text.py16
4 files changed, 61 insertions, 4 deletions
diff --git a/anaconda b/anaconda
index 2731c43b9..ade122dc6 100755
--- a/anaconda
+++ b/anaconda
@@ -564,6 +564,27 @@ class Anaconda:
else:
self.methodstr = methodstr
+ def requiresNetworkInstall(self):
+ fail = False
+ numNetDevs = isys.getNetworkDeviceCount()
+
+ if self.methodstr is not None:
+ if (methodstr.startswith("http://") or \
+ methodstr.startswith("ftp://") or \
+ methodstr.startswith("nfs:")) and \
+ numNetDevs == 0:
+ fail = True
+ elif self.stage2 is not None:
+ if stage2.startswith("cdrom://") and \
+ not os.path.isdir("/mnt/source/Packages") and \
+ numNetDevs == 0:
+ fail = True
+
+ if fail:
+ log.error("network install required, but no network devices available")
+
+ return fail
+
if __name__ == "__main__":
anaconda = Anaconda()
diff --git a/isys/isys.py b/isys/isys.py
index 05e0806c9..c7cf25b77 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -873,6 +873,13 @@ def isIsoImage(file):
def fbinfo():
return _isys.fbinfo()
+# Return number of network devices
+def getNetworkDeviceCount():
+ bus = dbus.SystemBus()
+ nm = bus.get_object(NM_SERVICE, NM_MANAGER_PATH)
+ devlist = nm.get_dbus_method("GetDevices")()
+ return len(devlist)
+
# Get a D-Bus interface for the specified device's (e.g., eth0) properties.
# If dev=None, return a hash of the form 'hash[dev] = props_iface' that
# contains all device properties for all interfaces that NetworkManager knows
diff --git a/iw/welcome_gui.py b/iw/welcome_gui.py
index a12a2e104..8dc1a7ef6 100644
--- a/iw/welcome_gui.py
+++ b/iw/welcome_gui.py
@@ -25,16 +25,18 @@ from constants import *
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
-class WelcomeWindow (InstallWindow):
+class WelcomeWindow (InstallWindow):
windowTitle = "" #N_("Welcome")
def __init__ (self, ics):
- InstallWindow.__init__ (self, ics)
+ InstallWindow.__init__ (self, ics)
ics.setGrabNext (1)
+ self.anaconda = None
# WelcomeWindow tag="wel"
def getScreen (self, anaconda):
+ self.anaconda = anaconda
# this is a bit ugly... but scale the image if we're not at 800x600
(w, h) = self.ics.cw.window.get_size_request()
if w >= 800:
@@ -48,3 +50,18 @@ class WelcomeWindow (InstallWindow):
box.add (pix)
return box
+ def getNext (self):
+ if self.anaconda.requiresNetworkInstall():
+ self.anaconda.intf.messageWindow(_("Network Install Required"),
+ _("Your installation source is set to "
+ "a network location, but no netork "
+ "devices were found on your "
+ "system. To avoid a network "
+ "installation, boot with the full "
+ "DVD, full CD set, or do not pass "
+ "a repo= parameter that specifies "
+ "a network source."),
+ type="custom",
+ custom_icon="error",
+ custom_buttons=[_("E_xit Installer")])
+ sys.exit(0)
diff --git a/textw/welcome_text.py b/textw/welcome_text.py
index c5fce5c70..c0f771d74 100644
--- a/textw/welcome_text.py
+++ b/textw/welcome_text.py
@@ -25,10 +25,22 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
class WelcomeWindow:
def __call__(self, screen, anaconda):
- rc = ButtonChoiceWindow(screen, _("%s") % (productName,),
+ rc = ButtonChoiceWindow(screen, _("%s") % (productName,),
_("Welcome to %s!\n\n")
% (productName, ),
buttons = [TEXT_OK_BUTTON], width = 50,
- help = "welcome")
+ help = "welcome")
+
+ if anaconda.requiresNetworkInstall():
+ anaconda.intf.messageWindow(_("Network Install Required"),
+ _("Your installation source is set to "
+ "a network location, but no netork "
+ "devices were found on your "
+ "system. To avoid a network "
+ "installation, boot with the full "
+ "DVD, full CD set, or do not pass "
+ "a repo= parameter that specifies "
+ "a network source."))
+ sys.exit(0)
return INSTALL_OK