def _commonCleanFs(dirname, media): if media is not None: os.chown(media, resolveUid(DISKIMAGE_USER), resolveGid(DISKIMAGE_GROUP)) if dirname is not None: shutil.rmtree(dirname)
def getFileName(vmId): if not os.path.exists(_P_PAYLOAD_IMAGES): try: os.mkdir(_P_PAYLOAD_IMAGES) os.chown(_P_PAYLOAD_IMAGES, resolveUid(DISKIMAGE_USER), resolveGid(DISKIMAGE_GROUP)) except OSError as e: if e.errno != errno.EEXIST: raise path = os.path.join(_P_PAYLOAD_IMAGES, "%s.img" % (vmId, )) return path
def getFileName(vmId, files): if not os.path.exists(_P_PAYLOAD_IMAGES): try: os.mkdir(_P_PAYLOAD_IMAGES) os.chown(_P_PAYLOAD_IMAGES, resolveUid(DISKIMAGE_USER), resolveGid(DISKIMAGE_GROUP)) except OSError as e: if e.errno != os.errno.EEXIST: raise content = ''.join(files.keys()) + ''.join(files.values()) md5 = hashlib.md5(content).hexdigest() path = os.path.join(_P_PAYLOAD_IMAGES, "%s.%s.img" % (vmId, md5)) return path
def _db_owned_by_vdsm(): stat = os.stat(mvdb.DB_FILE) actual_uid = stat.st_uid actual_gid = stat.st_gid expected_uid = fileUtils.resolveUid(constants.VDSM_USER) expected_gid = fileUtils.resolveGid(constants.VDSM_GROUP) if expected_uid == actual_uid and expected_gid == actual_gid: return True else: sys.stdout.write("DB file %s doesn't have proper ownership %s:%s\n" "Actual ownership is %s:%s\n" % (mvdb.DB_FILE, expected_uid, expected_gid, actual_uid, actual_gid)) return False
def child(pipe): res = ex = None try: uid = resolveUid(user) if groups: gids = [resolveGid(g) for g in groups] os.setgid(gids[0]) os.setgroups(gids) os.setuid(uid) res = func(*args, **kwargs) except BaseException as e: ex = e pipe.send((res, ex)) pipe.recv()
def child(writer): try: uid = resolveUid(user) if groups: gids = [resolveGid(g) for g in groups] os.setgid(gids[0]) os.setgroups(gids) os.setuid(uid) res = func(*args, **kwargs) writer.send((res, None)) except BaseException as e: writer.send((None, e)) writer.close()