Beispiel #1
0
    def _chkconfig(self):
        '''
        returns True if iptables is enabled on any runlevel
        redhat-based only
        '''

        if not os.path.exists(CHKCONFIG):
            raise UtilError('chkconfig not found')
        out, err, retcode = system2([CHKCONFIG, '--list', 'iptables'])
        if err:
            raise UtilError(str(err))
        if out:
            raw = out.split('\n')
            for row in raw:
                if row:
                    data = row.split('\t')
                    if len(data) == 8:
                        service = data.pop(0).strip()
                        levels = []
                        for level in data:
                            levels.append(True if 'on' in level else False)
                        if len(levels) == 7 and service == 'iptables' and any(
                                levels):
                            return True
        return False
Beispiel #2
0
 def __str__(self):
     s = "(output: %s)" % self.output
     return UtilError.__str__(self) +  s
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     UtilError.__init__(self, *args)
     self.output = kwargs.get("output", "")
Beispiel #4
0
 def __str__(self):
     s = "(output: %s)" % self.output
     return UtilError.__str__(self) + s
Beispiel #5
0
 def __init__(self, *args, **kwargs):
     UtilError.__init__(self, *args)
     self.output = kwargs.get("output", "")