[rhel5-branch] Validate the user-chosen name of an mpath device.

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

 



Related: rhbz#572862
---
 iutil.py     |   10 ++++++++++
 kickstart.py |    4 ++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/iutil.py b/iutil.py
index 8b3e6b9..c482b18 100644
--- a/iutil.py
+++ b/iutil.py
@@ -444,6 +444,16 @@ def cpuFeatureFlags():
 
     return []
 
+def valid_dm_name(name):
+    """ Tests whether name is a good name for a dm device
+
+        Sometimes the user could call the device 'devp3' and then how is
+        bootloaderInfo.getDiskPart() to tell it's not a partition?
+    """
+    if re.search("p\d{1,2}$", name):
+        return False
+    return True
+
 def writeRpmPlatform(root="/"):
     import rhpl.arch
 
diff --git a/kickstart.py b/kickstart.py
index 1f414c5..46c6c1f 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -393,6 +393,10 @@ class AnacondaKSHandlers(KickstartHandlers):
             newname = ""
             it = True
             for path in mpath.paths:
+                if not iutil.valid_dm_name(path.name):
+                    msg = "Invalid name for a multipath device '%s' "\
+                        "(resembles a partition?)." % path.name
+                    raise KickstartValueError, formatErrorMsg(self.lineno, msg)
                 dev = path.device
                 log.debug("Searching for mpath having '%s' as a member, the scsi id or wwpn:lunid" % (dev,))
                 log.debug("mpath '%s' has members %s" % (mp.name, list(mp.members)))
-- 
1.7.3.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