diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py index c055a72311f2c773708cc8a250ccc7a04c5b56bc..fd675f1b2fc50ac463571f7db85cb2de80cf5b1f 100644 --- a/lib/hypervisor/hv_base.py +++ b/lib/hypervisor/hv_base.py @@ -49,11 +49,11 @@ from ganeti import utils # _CHECK values # must be afile -_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", +_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path", os.path.isfile, "not found or not a file") # must be a directory -_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", +_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path", os.path.isdir, "not found or not a directory") # nice wrappers for users diff --git a/lib/utils.py b/lib/utils.py index 3a0881fcd36e3b1f574115d5a915caca9ec3f1a6..48388babe45aa8e823cd8b81200949e90bed97aa 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1786,7 +1786,7 @@ def SetupLogging(logfile, debug=False, stderr_logging=False, program="", raise def IsNormAbsPath(path): - """Check whether a path is absolute and also "normal". + """Check whether a path is absolute and also normalized This avoids things like /dir/../../other/path to be valid. diff --git a/test/ganeti.utils_unittest.py b/test/ganeti.utils_unittest.py index 433bfe3364d944e1fc3f32f7fd1eb671eb0a1808..846b4b44624796b8b3167daf38c24dbb73a21d90 100755 --- a/test/ganeti.utils_unittest.py +++ b/test/ganeti.utils_unittest.py @@ -975,10 +975,10 @@ class TestIsAbsNormPath(unittest.TestCase): def _pathTestHelper(self, path, result): if result: self.assert_(IsNormAbsPath(path), - "Path %s should be absolute and normal" % path) + "Path %s should result absolute and normalized" % path) else: self.assert_(not IsNormAbsPath(path), - "Path %s should not be absolute and normal" % path) + "Path %s should not result absolute and normalized" % path) def testBase(self): self._pathTestHelper('/etc', True)