<s> """<STR_LIT>""" <EOL> import commands <EOL> import os <EOL> import pwd <EOL> import socket <EOL> from compass . actions . health_check import base <EOL> from compass . actions . health_check import utils as health_check_utils <EOL> class SquidCheck ( base . BaseCheck ) : <EOL> """<STR_LIT>""" <EOL> NAME = "<STR_LIT>" <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> self . check_squid_files ( ) <EOL> print "<STR_LIT>" <EOL> self . check_squid_service ( ) <EOL> print "<STR_LIT>" <EOL> if self . code == <NUM_LIT:1> : <EOL> self . messages . append ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> return ( self . code , self . messages ) <EOL> def check_squid_files ( self ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" , <EOL> var_map = { <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> } <EOL> conf_err_msg = health_check_utils . check_path ( <EOL> self . NAME , <EOL> "<STR_LIT>" ) <EOL> if not conf_err_msg == "<STR_LIT>" : <EOL> self . _set_status ( <NUM_LIT:0> , conf_err_msg ) <EOL> elif int ( oct ( os . stat ( '<STR_LIT>' ) . st_mode ) ) < <NUM_LIT> : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> else : <EOL> var_map [ '<STR_LIT>' ] = True <EOL> squid_path_err_msg = health_check_utils . check_path ( <EOL> self . NAME , '<STR_LIT>' ) <EOL> if not squid_path_err_msg == "<STR_LIT>" : <EOL> self . _set_status ( <NUM_LIT:0> , squid_path_err_msg ) <EOL> elif health_check_utils . check_path ( <EOL> self . NAME , <EOL> '<STR_LIT>' <EOL> ) != "<STR_LIT>" : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> health_check_utils . check_path ( <EOL> self . NAME , <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> else : <EOL> var_map [ '<STR_LIT>' ] = True <EOL> uid = os . stat ( '<STR_LIT>' ) . st_uid <EOL> gid = os . stat ( '<STR_LIT>' ) . st_gid <EOL> if uid != gid or pwd . getpwuid ( <NUM_LIT> ) . pw_name != '<STR_LIT>' : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> else : <EOL> var_map [ '<STR_LIT>' ] = True <EOL> fails = [ ] <EOL> for key in var_map . keys ( ) : <EOL> if var_map [ key ] is False : <EOL> fails . append ( key ) <EOL> if len ( fails ) != <NUM_LIT:0> : <EOL> self . messages . append ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT:%s>" % ( <EOL> self . NAME , <EOL> '<STR_LIT:U+002CU+0020>' . join ( item for item in fails ) <EOL> ) <EOL> ) <EOL> return True <EOL> def check_squid_service ( self ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" , <EOL> if '<STR_LIT>' not in commands . getoutput ( '<STR_LIT>' ) : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> try : <EOL> if '<STR_LIT>' != socket . getservbyport ( <NUM_LIT> ) : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> except Exception : <EOL> self . _set_status ( <EOL> <NUM_LIT:0> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % self . NAME ) <EOL> return True </s>
