From 4f5277e7b1e4fc2939ca1e0bc470c9b3e6252b03 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Fri, 22 May 2009 13:48:27 +0100 Subject: [PATCH] Hypervisors: make absolute path checking strict Use the new utils.IsAbsNormPath function, rather than just os.path.isabs Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/hypervisor/hv_base.py | 4 ++-- lib/hypervisor/hv_kvm.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py index 442cd810d..c055a7231 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 = (os.path.isabs, "must be an absolute path", +_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", os.path.isfile, "not found or not a file") # must be a directory -_DIR_CHECK = (os.path.isabs, "must be an absolute path", +_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", os.path.isdir, "not found or not a directory") # nice wrappers for users diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index fdfc28a47..507e23a07 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -56,7 +56,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): constants.HV_ACPI: hv_base.NO_CHECK, constants.HV_SERIAL_CONSOLE: hv_base.NO_CHECK, constants.HV_VNC_BIND_ADDRESS: \ - (False, lambda x: (utils.IsValidIP(x) or os.path.isabs(x)), + (False, lambda x: (utils.IsValidIP(x) or utils.IsAbsNormPath(x)), "the VNC bind address must be either a valid IP address or an absolute" " pathname", None, None), constants.HV_VNC_TLS: hv_base.NO_CHECK, -- GitLab