<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import logging <EOL> import dmgtestutilities <EOL> import macdmgtest <EOL> def ListSuidSgid ( path ) : <EOL> """<STR_LIT>""" <EOL> cmd = [ '<STR_LIT>' , path , '<STR_LIT>' , '<STR_LIT:f>' , '<STR_LIT:(>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:)>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:{}>' , '<STR_LIT:;>' ] <EOL> res = dmgtestutilities . ProcessCommand ( cmd ) <EOL> catalog = [ ] <EOL> prefix_length = len ( path ) <EOL> for f in res [ '<STR_LIT>' ] : <EOL> if f : <EOL> snip = f . find ( '<STR_LIT:/>' ) <EOL> if snip : <EOL> snip_index = snip + prefix_length <EOL> rawpath = f [ snip_index : ] <EOL> catalog . append ( rawpath ) <EOL> else : <EOL> logging . warn ( '<STR_LIT>' % snip ) <EOL> logging . warn ( f ) <EOL> return catalog <EOL> def ReadWhiteList ( path ) : <EOL> """<STR_LIT>""" <EOL> white_file = open ( path , '<STR_LIT:r>' ) <EOL> catalog = { } <EOL> for entry in white_file : <EOL> if not entry or entry [ : <NUM_LIT:1> ] == '<STR_LIT:#>' : <EOL> pass <EOL> else : <EOL> catalog [ entry . strip ( ) ] = True <EOL> return catalog <EOL> class TestSUIDGUIDFiles ( macdmgtest . DMGUnitTest ) : <EOL> def setUp ( self ) : <EOL> whitelist_path = self . ConfigPath ( '<STR_LIT>' ) <EOL> self . whitelisted_suids = ReadWhiteList ( whitelist_path ) <EOL> def testForUnknownSUIDsAndGUIDs ( self ) : <EOL> """<STR_LIT>""" <EOL> scrutinize = ListSuidSgid ( self . Mountpoint ( ) ) <EOL> illegal_suids = [ ] <EOL> for s in scrutinize : <EOL> if s not in self . whitelisted_suids : <EOL> illegal_suids . append ( s ) <EOL> if illegal_suids : <EOL> print '<STR_LIT>' <EOL> '<STR_LIT:\n>' . join ( illegal_suids ) <EOL> print '<STR_LIT>' <EOL> self . assertEqual ( <NUM_LIT:0> , len ( illegal_suids ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> macdmgtest . main ( ) </s>
