def setConditionsForRule(self):
     '''
     Configure system for the unit test
     @param self: essential if you override this definition
     @return: boolean - If successful True; If failure False
     @author: Eric Ball
     '''
     success = True
     # Run report() to get variables
     self.rule.report()
     ssh = {"ClientAliveInterval": "0", "ClientAliveCountMax": "900"}
     if os.path.exists(self.rule.path):
         kvtype = "conf"
         intent = "present"
         self.editor = KVEditorStonix(self.statechglogger, self.logdispatch,
                                      kvtype, self.rule.path,
                                      self.rule.tpath, ssh, intent, "space")
         if not self.editor.report():
             if self.editor.fixables:
                 if self.editor.fix():
                     if not self.editor.commit():
                         success = False
                         debug = "KVEditor commit did not succeed"
                         self.logdispatch.log(LogPriority.DEBUG, debug)
                 else:
                     success = False
                     debug = "KVEditor fix() did not succeed"
                     self.logdispatch.log(LogPriority.DEBUG, debug)
         self.rule.iditerator = 0
         myid = iterate(self.rule.iditerator, self.rule.rulenumber)
         if not setPerms(self.rule.path, [99, 99, 0770], self.logdispatch,
                         self.statechglogger, myid):
             success = False
             debug = "Could not set permissions"
             self.logdispatch.log(LogPriority.DEBUG, debug)
Example #2
0
 def setConditionsForRule(self):
     '''
     Configure system for the unit test
     @param self: essential if you override this definition
     @return: boolean - If successful True; If failure False
     @author: Eric Ball
     '''
     success = True
     # This is tested as working on both platforms
     sudoers = "/etc/sudoers"
     self.rule.ci.updatecurrvalue(True)
     self.rule.iditerator = 0
     myid = iterate(self.rule.iditerator, self.rule.rulenumber)
     setPerms(sudoers, [99, 99, 0770], self.logdispatch,
              self.statechglogger, myid)
     contents = readFile(sudoers, self.logdispatch)
     for line in contents:
         if re.search("^Defaults\s+timestamp_timeout", line.strip()):
             contents.remove(line)
             break
     return success
 def setConditionsForRule(self):
     '''
     Configure system for the unit test
     @param self: essential if you override this definition
     @return: boolean - If successful True; If failure False
     @author: Eric Ball
     '''
     success = True
     # This is tested as working on both platforms
     sudoers = "/etc/sudoers"
     self.rule.ci.updatecurrvalue(True)
     self.rule.iditerator = 0
     myid = iterate(self.rule.iditerator, self.rule.rulenumber)
     setPerms(sudoers, [99, 99, 0770], self.logdispatch,
              self.statechglogger, myid)
     contents = readFile(sudoers, self.logdispatch)
     for line in contents:
         if re.search("^Defaults\s+timestamp_timeout", line.strip()):
             contents.remove(line)
             break
     return success
 def setConditionsForRule(self):
     '''
     Configure system for the unit test
     @param self: essential if you override this definition
     @return: boolean - If successful True; If failure False
     @author: Eric Ball
     '''
     success = True
     # Run report() to get variables
     self.rule.report()
     ssh = {"ClientAliveInterval": "0",
            "ClientAliveCountMax": "900"}
     if os.path.exists(self.rule.path):
         kvtype = "conf"
         intent = "present"
         self.editor = KVEditorStonix(self.statechglogger, self.logdispatch,
                                      kvtype, self.rule.path,
                                      self.rule.tpath, ssh, intent, "space")
         if not self.editor.report():
             if self.editor.fixables:
                 if self.editor.fix():
                     if not self.editor.commit():
                         success = False
                         debug = "KVEditor commit did not succeed"
                         self.logdispatch.log(LogPriority.DEBUG, debug)
                 else:
                     success = False
                     debug = "KVEditor fix() did not succeed"
                     self.logdispatch.log(LogPriority.DEBUG, debug)
         self.rule.iditerator = 0
         myid = iterate(self.rule.iditerator, self.rule.rulenumber)
         if not setPerms(self.rule.path, [99, 99, 0770], self.logdispatch,
                         self.statechglogger, myid):
             success = False
             debug = "Could not set permissions"
             self.logdispatch.log(LogPriority.DEBUG, debug)