def test_2_daemon_with_option(self): logger_path = test_base.getTestDirectory(test_base.CONFIG_DIR) daemon = self._run_daemon( { "disable_watchdog": True, "disable_extensions": True, "disable_logging": False, }, options_only={ "logger_path": logger_path, "verbose": True, }) self.assertTrue(daemon.isAlive()) def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path) # Wait for the daemon to flush to GLOG. test_base.expectTrue(info_exists) # Assign the variable after we have assurances it exists info_path = test_base.getLatestInfoLog(logger_path) self.assertTrue(os.path.exists(info_path)) # Lastly, verify that we have permission to read the file data = '' with open(info_path, 'r') as fh: try: data = fh.read() except: pass self.assertTrue(len(data) > 0) daemon.kill()
def test_2_daemon_with_option(self): logger_path = test_base.getTestDirectory(test_base.CONFIG_DIR) daemon = self._run_daemon( { "disable_watchdog": True, "disable_extensions": True, "disable_logging": False, }, options_only={ "logger_path": logger_path, "verbose": True, }) self.assertTrue(daemon.isAlive()) def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path) # Wait for the daemon to flush to GLOG. test_base.expectTrue(info_exists) # Assign the variable after we have assurances it exists info_path = test_base.getLatestInfoLog(logger_path) self.assertTrue(os.path.exists(info_path)) # Lastly, verify that we have permission to read the file data = '' with open(info_path, 'r') as fh: try: data = fh.read() except: pass self.assertTrue(len(data) > 0) daemon.kill()
def test_6_logger_mode(self): logger_path = test_base.getTestDirectory(test_base.CONFIG_DIR) test_mode = 0o754 # Strange mode that should never exist daemon = self._run_daemon( { "disable_watchdog": True, "disable_extensions": True, "disable_logging": False, }, options_only={ "logger_path": logger_path, "logger_mode": test_mode, "verbose": True, }) results_path = os.path.join(logger_path, "osqueryd.results.log") self.assertTrue(daemon.isAlive()) # Wait for the daemon to write the info log to disk before continuing def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path) info_path = test_base.getLatestInfoLog(logger_path) def results_exists(): return os.path.exists(results_path) # Wait for the daemon to flush to GLOG. test_base.expectTrue(info_exists) test_base.expectTrue(results_exists) # Both log files should exist, the results should have the given mode. for pth in [info_path, results_path]: self.assertTrue(os.path.exists(pth)) # Only apply the mode checks to .log files. # TODO: Add ACL checks for Windows logs if pth.find('.log') > 0 and os.name != "nt": rpath = os.path.realpath(pth) mode = os.stat(rpath).st_mode & 0o777 self.assertEqual(mode, test_mode) daemon.kill()
def test_6_logger_mode(self): logger_path = test_base.getTestDirectory(test_base.CONFIG_DIR) test_mode = 0754 # Strange mode that should never exist daemon = self._run_daemon( { "disable_watchdog": True, "disable_extensions": True, "disable_logging": False, }, options_only={ "logger_path": logger_path, "logger_mode": test_mode, "verbose": True, }) results_path = os.path.join(logger_path, "osqueryd.results.log") self.assertTrue(daemon.isAlive()) # Wait for the daemon to write the info log to disk before continuing def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path) info_path = test_base.getLatestInfoLog(logger_path) def results_exists(): return os.path.exists(results_path) # Wait for the daemon to flush to GLOG. test_base.expectTrue(info_exists) test_base.expectTrue(results_exists) # Both log files should exist, the results should have the given mode. for pth in [info_path, results_path]: self.assertTrue(os.path.exists(pth)) # Only apply the mode checks to .log files. # TODO: Add ACL checks for Windows logs if pth.find('.log') > 0 and os.name != "nt": rpath = os.path.realpath(pth) mode = os.stat(rpath).st_mode & 0777 self.assertEqual(mode, test_mode) daemon.kill()
def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path)
def info_exists(): info_path = test_base.getLatestInfoLog(logger_path) return os.path.exists(info_path)