Yeela Kaplan has uploaded a new change for review.
Change subject: fileUtils.validateAccess ioprocess implementation
......................................................................
fileUtils.validateAccess ioprocess implementation
Change-Id: Ide82ef85d245216492e1e4327efb37c6c32a55dc
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M vdsm/storage/outOfProcess.py
1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/27120/1
diff --git a/vdsm/storage/outOfProcess.py b/vdsm/storage/outOfProcess.py
index ead305b..3b5071c 100644
--- a/vdsm/storage/outOfProcess.py
+++ b/vdsm/storage/outOfProcess.py
@@ -18,6 +18,9 @@
# Refer to the README and COPYING files for full details of the license
#
import types
+import os
+import errno
+import logging
from ioprocess import IOProcess
@@ -37,6 +40,8 @@
_procLock = threading.Lock()
_proc = {}
_ioproc = {}
+
+log = logging.getLogger('oop')
def setDefaultImpl(impl):
@@ -75,6 +80,17 @@
return self._iop.glob(pattern)
+class _ioprocessFileUtils(object):
+ def __init__(self, iop):
+ self._iop = iop
+
+ def validateAccess(self, targetPath, perms=(os.R_OK | os.W_OK | os.X_OK)):
+ if not self._iop.access(targetPath, perms):
+ log.warning("Permission denied for directory: %s with
permissions:"
+ "%s", targetPath, perms)
+ raise OSError(errno.EACCES, os.strerror(errno.EACCES))
+
+
class _ModuleWrapper(types.ModuleType):
def __init__(self, modName, procPool, ioproc, timeout, subModNames=()):
self._modName = modName
@@ -98,6 +114,8 @@
if ioproc:
self.glob = _ioprocessGlob(ioproc)
+ self.fileUtils.validateAccess = \
+ _ioprocessFileUtils(ioproc).validateAccess
def __getattr__(self, name):
# Root modules is fake, we need to remove it
--
To view, visit
http://gerrit.ovirt.org/27120
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide82ef85d245216492e1e4327efb37c6c32a55dc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>