a qqe @sddlZddlZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZdd lmZdd lmZmZGd d d e eZdS) N)suppress)Iterable)CriteriaDescriptorCriteriaSetDescriptor)NoCommon) MatchName)ObjClass) PolicyQuery) match_regexmatch_regex_or_setcs|eZdZUdZeddZdZeed<e dZ dZ eed<dZ eed<dZ eed<d d fd d Zeed d dZZS) ObjClassQueryaO Query object classes. Parameter: policy The policy to query. Keyword Parameters/Class attributes: name The name of the object set to match. name_regex If true, regular expression matching will be used for matching the name. common The name of the inherited common to match. common_regex If true, regular expression matching will be used for matching the common name. perms The permissions to match. perms_equal If true, only commons with permission sets that are equal to the criteria will match. Otherwise, any intersection will match. perms_regex If true, regular expression matching will be used on the permission names instead of set logic. comparison will not be used. perms_indirect If false, permissions inherited from a common permission set not will be evaluated. Default is true. common_regexZ lookup_commonF perms_regex perms_equalTperms_indirectN)returnc s(tt|j|fi|tt|_dS)N)superr __init__loggingZ getLogger__name__log)selfpolicykwargs __class__;/usr/lib64/python3.9/site-packages/setools/objclassquery.pyr6szObjClassQuery.__init__c cs|jd|||j|jd||jd||jD]}||s\qL|jrzt |j|j|j szWqLWnt yYqLYn0|j r|j }|j rtt ||jj O}Wdn1s0Yt||j |j|jsqL|VqLdS)z3Generator which yields all matching object classes.z/Generating object class results from {0.policy}z-Common: {0.common!r}, regex: {0.common_regex}z[Perms: {0.perms}, regex: {0.perms_regex}, eq: {0.perms_equal}, indirect: {0.perms_indirect}N)rinfoformatZ_match_name_debugdebugrclassesZ _match_namecommonr rrpermsrrr rr)rclass_r$rrrresults:s@      *zObjClassQuery.results)r __module__ __qualname____doc__rr#rbool__annotations__rr$rrrrrr r& __classcell__rrrrr s      r )rre contextlibrtypingrZ descriptorsrr exceptionrZmixinsrZ policyrepr queryr utilr r r rrrrs