Hello Federico Simoncelli, Yedidyah Bar David, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/29425
to review the following change.
Change subject: Add missing validateQemuReadable to oop
......................................................................
Add missing validateQemuReadable to oop
Change-Id: I6598619c7acd18e41b51c15018627973f1eb263a
Bug-Url:
https://bugzilla.redhat.com/show_bug.cgi?id=1114499
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
Reviewed-on:
http://gerrit.ovirt.org/29398
Reviewed-by: Federico Simoncelli <fsimonce(a)redhat.com>
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
Tested-by: Yedidyah Bar David <didi(a)redhat.com>
---
M vdsm/storage/outOfProcess.py
1 file changed, 13 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/29425/1
diff --git a/vdsm/storage/outOfProcess.py b/vdsm/storage/outOfProcess.py
index 77f40aa..9003f40 100644
--- a/vdsm/storage/outOfProcess.py
+++ b/vdsm/storage/outOfProcess.py
@@ -18,12 +18,14 @@
# Refer to the README and COPYING files for full details of the license
#
import errno
+import grp
import logging
import os
import stat
import sys
import types
+from vdsm import constants
from vdsm.config import config
import threading
from functools import partial
@@ -176,6 +178,17 @@
def pathExists(self, filename, writable=False):
return self._iop.pathExists(filename, writable)
+ def validateQemuReadable(self, targetPath):
+ """
+ Validate that qemu process can read file
+ """
+ gids = (grp.getgrnam(constants.DISKIMAGE_GROUP).gr_gid,
+ grp.getgrnam(constants.METADATA_GROUP).gr_gid)
+ st = _IOProcessOs(self._iop).stat(targetPath)
+ if not (st.st_gid in gids and st.st_mode & stat.S_IRGRP or
+ st.st_mode & stat.S_IROTH):
+ raise OSError(errno.EACCES, os.strerror(errno.EACCES))
+
class _IOProcessOs(object):
def __init__(self, iop):
--
To view, visit
http://gerrit.ovirt.org/29425
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6598619c7acd18e41b51c15018627973f1eb263a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Yedidyah Bar David <didi(a)redhat.com>