def __init__(self, request): self.userinfo = UserInfo.getUserInfo(request) FileManager.__init__(self, self.userinfo.getHomePath())
def getAuth(userinfo, fullPath, mode = 0x07): """ 조회 대상에 대하여 소유한 권한을 RWD 튜플로 반환한다. """ if userinfo.isYeoman() or mode == 0x04 and userinfo.isMetic() : return (True, True, True) readable = not (mode & 0x04) | userinfo.isMetic() writeable = not (mode & 0x02) deletable = not (mode & 0x01) normFullPath = os.path.normpath(fullPath) descriptor = None file_id = index.dir_get(fullPath) # 재귀적으로 권한 추출 시 사용자 홈 이상으로는 올라갈 수 없음. # info("ROOT : " + userinfo.getHomePath()) # info("COMP : " + normFullPath) if normFullPath == userinfo.getHomePath() : inheritable = False else : inheritable = True if file_id is not None and file_id >= 0 : try : descriptor = FileDescriptor.objects.get(file_id=file_id) readable |= descriptor.readable writeable |= descriptor.writeable deletable |= descriptor.deletable if not (readable and writeable and deletable) : users = [] users.append(userinfo) for user in UserGroups.objects.filter(user=userinfo) : users.append(user.group) for userAuthority in UserAuthority.objects.filter(username__in=users, file_id=file_id) : readable |= userAuthority.readable writeable |= userAuthority.writeable deletable |= userAuthority.deletable if readable and writeable and deletable : break if not (readable and writeable and deletable) and inheritable and descriptor.inherit : auth_inherit = Directory.getAuth(userinfo, FileManager.getParent(fullPath)) readable |= auth_inherit[0] writeable |= auth_inherit[1] deletable |= auth_inherit[2] except Exception as err: error("auth.dir.get : " + err.__str__()) pass elif not userinfo.isGuest() or config.USING_GUEST : readable = config.DEFAULT_AUTH_DIR_READABLE writeable = config.DEFAULT_AUTH_DIR_WRITEABLE deletable = config.DEFAULT_AUTH_DIR_DELETABLE # 상속받는 경우 if not(readable and writeable and deletable) and inheritable and config.DEFAULT_AUTH_DIR_INHERIT : auth_inherit = Directory.getAuth(userinfo, FileManager.getParent(fullPath)) readable |= auth_inherit[0] writeable |= auth_inherit[1] deletable |= auth_inherit[2] # 만약 guest 활성화 되어있다면 GUEST HOME 에 대한 파일 조회 권한만 부여 한다. if userinfo.isGuest() and normFullPath == config.getHomeGuest() : readable = True return (readable, writeable, deletable)
def getAuth(userinfo, fullPath, mode=0x07): """ 조회 대상에 대하여 소유한 권한을 RWD 튜플로 반환한다. """ if userinfo.isYeoman() or mode == 0x04 and userinfo.isMetic(): return (True, True, True) readable = not (mode & 0x04) | userinfo.isMetic() writeable = not (mode & 0x02) deletable = not (mode & 0x01) normFullPath = os.path.normpath(fullPath) descriptor = None file_id = index.dir_get(fullPath) # 재귀적으로 권한 추출 시 사용자 홈 이상으로는 올라갈 수 없음. # info("ROOT : " + userinfo.getHomePath()) # info("COMP : " + normFullPath) if normFullPath == userinfo.getHomePath(): inheritable = False else: inheritable = True if file_id is not None and file_id >= 0: try: descriptor = FileDescriptor.objects.get(file_id=file_id) readable |= descriptor.readable writeable |= descriptor.writeable deletable |= descriptor.deletable if not (readable and writeable and deletable): users = [] users.append(userinfo) for user in UserGroups.objects.filter(user=userinfo): users.append(user.group) for userAuthority in UserAuthority.objects.filter( username__in=users, file_id=file_id): readable |= userAuthority.readable writeable |= userAuthority.writeable deletable |= userAuthority.deletable if readable and writeable and deletable: break if not (readable and writeable and deletable) and inheritable and descriptor.inherit: auth_inherit = Directory.getAuth( userinfo, FileManager.getParent(fullPath)) readable |= auth_inherit[0] writeable |= auth_inherit[1] deletable |= auth_inherit[2] except Exception as err: error("auth.dir.get : " + err.__str__()) pass elif not userinfo.isGuest() or config.USING_GUEST: readable = config.DEFAULT_AUTH_DIR_READABLE writeable = config.DEFAULT_AUTH_DIR_WRITEABLE deletable = config.DEFAULT_AUTH_DIR_DELETABLE # 상속받는 경우 if not (readable and writeable and deletable ) and inheritable and config.DEFAULT_AUTH_DIR_INHERIT: auth_inherit = Directory.getAuth( userinfo, FileManager.getParent(fullPath)) readable |= auth_inherit[0] writeable |= auth_inherit[1] deletable |= auth_inherit[2] # 만약 guest 활성화 되어있다면 GUEST HOME 에 대한 파일 조회 권한만 부여 한다. if userinfo.isGuest() and normFullPath == config.getHomeGuest(): readable = True return (readable, writeable, deletable)