From 5e09a3098d47371b7d105e7f5f571a72532a03d7 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 5 Oct 2012 02:59:12 +0200 Subject: [PATCH] backend: Switch to new file storage directory verification The configuration is no longer used for verifying file storage paths. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/backend.py | 14 ++++---------- lib/bdev.py | 7 +++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 4e9d8958a..0a3f2dc89 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2743,16 +2743,10 @@ def _TransformFileStorageDir(fs_dir): if not (constants.ENABLE_FILE_STORAGE or constants.ENABLE_SHARED_FILE_STORAGE): _Fail("File storage disabled at configure time") - cfg = _GetConfig() - fs_dir = os.path.normpath(fs_dir) - base_fstore = cfg.GetFileStorageDir() - base_shared = cfg.GetSharedFileStorageDir() - if not (utils.IsBelowDir(base_fstore, fs_dir) or - utils.IsBelowDir(base_shared, fs_dir)): - _Fail("File storage directory '%s' is not under base file" - " storage directory '%s' or shared storage directory '%s'", - fs_dir, base_fstore, base_shared) - return fs_dir + + bdev.CheckFileStoragePath(fs_dir) + + return os.path.normpath(fs_dir) def CreateFileStorageDir(file_storage_dir): diff --git a/lib/bdev.py b/lib/bdev.py index 725c9521b..6c20b4bbd 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -2245,6 +2245,9 @@ class FileStorage(BlockDev): raise ValueError("Invalid configuration data %s" % str(unique_id)) self.driver = unique_id[0] self.dev_path = unique_id[1] + + CheckFileStoragePath(self.dev_path) + self.Attach() def Assemble(self): @@ -2361,7 +2364,11 @@ class FileStorage(BlockDev): """ if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2: raise ValueError("Invalid configuration data %s" % str(unique_id)) + dev_path = unique_id[1] + + CheckFileStoragePath(dev_path) + try: fd = os.open(dev_path, os.O_RDWR | os.O_CREAT | os.O_EXCL) f = os.fdopen(fd, "w") -- GitLab