Add caller-validation on Disk.StaticDevPath
authorIustin Pop <iustin@google.com>
Fri, 5 Mar 2010 10:17:59 +0000 (11:17 +0100)
committerIustin Pop <iustin@google.com>
Mon, 8 Mar 2010 13:52:39 +0000 (14:52 +0100)
Since in objects we don't have access to utils.py, we add a warning that
the result value from objects.Disk.StaticDevPath might not be a valid
path, and change its only caller to validate the path.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/backend.py
lib/objects.py

index 3e2fa96..e3053e9 100644 (file)
@@ -1461,6 +1461,8 @@ def BlockdevRemovechildren(parent_cdev, new_cdevs):
       else:
         devs.append(bd.dev_path)
     else:
+      if not utils.IsNormAbsPath(rpath):
+        _Fail("Strange path returned from StaticDevPath: '%s'", rpath)
       devs.append(rpath)
   parent_bdev.RemoveChildren(devs)
 
index 7fb7d5b..6e81a45 100644 (file)
@@ -411,6 +411,9 @@ class Disk(ConfigObject):
     irrespective of their status. For such devices, we return this
     path, for others we return None.
 
+    @warning: The path returned is not a normalized pathname; callers
+        should check that it is a valid path.
+
     """
     if self.dev_type == constants.LD_LV:
       return "/dev/%s/%s" % (self.logical_id[0], self.logical_id[1])