def install_agent(self): """Installs the ossec agent in the given remote system""" if not self.__authfile: self.__add_error("Can't create the auth file") return False smb = SambaClient(self.__authfile, SMB_WINEXEC_CONFIGURATION_FILE, self.__host) wine = WinExeC(self.__authfile, SMB_WINEXEC_CONFIGURATION_FILE, self.__host) #systemunit = wine.get_working_unit() origdstfile = "%s" % (os.path.basename(OSSEC_AGENT_BINARY_FILE)) logger.info("Saving the binary file") if not smb.put_file(DOWNLOADS_FOLDER, os.path.basename(OSSEC_AGENT_BINARY_FILE), "", origdstfile): self.__add_error("Error copying the file to the remote host") return False # installs logger.info("Running the ossec-agent setup....") systemunit = wine.get_working_unit() if not systemunit: self.__add_error("Can't retrieve the system unit from remote host. Maybe I can't connect to the remote host.") return False dstfile = "%s:/%s" % (systemunit.lower(), os.path.basename(OSSEC_AGENT_BINARY_FILE)) if not wine.run_command('%s /S' % (dstfile)): logger.info("Running the ossec-agent setup.... FAIL") self.__add_error("Error installing the ossec agent..") return False time.sleep(2) if not smb.remove_file(origdstfile): logger.info("Error removing the ossec-agent from the remote host") self.__add_error("Error removing the ossec-agent from the remote host") return True