From e51db2a60de2f1a6a3b651586d31a2ddecbe6698 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 5 Mar 2010 11:17:59 +0100
Subject: [PATCH] Add caller-validation on Disk.StaticDevPath

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 | 2 ++
 lib/objects.py | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/lib/backend.py b/lib/backend.py
index 3e2fa9697..e3053e938 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -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)
 
diff --git a/lib/objects.py b/lib/objects.py
index 7fb7d5be6..6e81a45ea 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -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])
-- 
GitLab