[PATCH] Prevent network install when no network devices are found (#470144)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 anaconda              |   21 +++++++++++++++++++++
 isys/isys.py          |    7 +++++++
 iw/welcome_gui.py     |   21 +++++++++++++++++++--
 textw/welcome_text.py |   16 ++++++++++++++--
 4 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/anaconda b/anaconda
index 2731c43..ade122d 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 05e0806..c7cf25b 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 a12a2e1..8dc1a7e 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 c5fce5c..c0f771d 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
-- 
1.6.0.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux