def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return stats.STATS = stats.StatsCollector() # Set up a temporary syslog handler so we have somewhere to log problems with # ConfigInit() which needs to happen before we can start our create our proper # logging setup. syslog_logger = logging.getLogger("TempLogger") handler = logging.handlers.SysLogHandler(address="/dev/log") syslog_logger.addHandler(handler) try: AddConfigContext() ConfigInit() except config_lib.Error: syslog_logger.exception("Died during config initialization") raise ServerLoggingStartupInit() registry.Init() if config_lib.CONFIG["Server.username"]: try: os.setuid( pwd.getpwnam(config_lib.CONFIG["Server.username"]).pw_uid) except (KeyError, OSError): logging.exception("Unable to switch to user %s", config_lib.CONFIG["Server.username"]) raise INIT_RAN = True
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return stats.STATS = stats.StatsCollector() # Set up a temporary syslog handler so we have somewhere to log problems with # ConfigInit() which needs to happen before we can start our create our proper # logging setup. syslog_logger = logging.getLogger("TempLogger") if os.path.exists("/dev/log"): handler = logging.handlers.SysLogHandler(address="/dev/log") else: handler = logging.handlers.SysLogHandler() syslog_logger.addHandler(handler) try: AddConfigContext() ConfigInit() except config_lib.Error: syslog_logger.exception("Died during config initialization") raise ServerLoggingStartupInit() registry.Init() INIT_RAN = True
def main(unused_argv): """Main.""" # Change the startup sequence in order to set the database path, if needed. config_lib.SetPlatformArchContext() config_lib.CONFIG.AddContext(contexts.DATA_SERVER_CONTEXT, "Context applied when running a data server.") config_lib.ParseConfigCommandLine() if flags.FLAGS.path: config_lib.CONFIG.Set("Datastore.location", flags.FLAGS.path) log.ServerLoggingStartupInit() stats.STATS = stats.StatsCollector() # We avoid starting some hooks because they add unneeded things # to the data store. do_not_start = set( ["ConfigurationViewInitHook", "FileStoreInit", "GRRAFF4Init"]) registry.Init(skip_set=do_not_start) if flags.FLAGS.ipv6: af = socket.AF_INET6 else: af = socket.AF_INET Start( data_store.DB, port=flags.FLAGS.port, address_family=af, is_master=flags.FLAGS.master)
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return stats.STATS = stats.StatsCollector() AddConfigContext() ConfigInit() ServerLoggingStartupInit() registry.Init() if platform.system() != "Windows": if config_lib.CONFIG["Server.username"]: try: os.setuid( pwd.getpwnam(config_lib.CONFIG["Server.username"]).pw_uid) except (KeyError, OSError): logging.exception("Unable to switch to user %s", config_lib.CONFIG["Server.username"]) raise INIT_RAN = True
def ClientInit(): """Run all startup routines for the client.""" if stats.STATS is None: stats.STATS = stats.StatsCollector() config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() client_logging.LogInit() registry.Init()
def ClientInit(): """Run all startup routines for the client.""" stats.STATS = stats.StatsCollector() AddConfigContext() ConfigInit() ClientLoggingStartupInit() ClientPluginInit() registry.Init()
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return stats.STATS = stats.StatsCollector() AddConfigContext() ConfigInit() ServerLoggingStartupInit() registry.Init() INIT_RAN = True
def ClientInit(): """Run all startup routines for the client.""" if stats.STATS is None: stats.STATS = stats.StatsCollector() config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() client_logging.LogInit() registry.Init() if not config.CONFIG.ContextApplied(contexts.CLIENT_BUILD_CONTEXT): config.CONFIG.Persist("Client.labels") config.CONFIG.Persist("Client.proxy_servers") config.CONFIG.Persist("Client.tempdir_roots")
def Init(): """Run all required startup routines and initialization hooks.""" global INIT_RAN if INIT_RAN: return # Set up a temporary syslog handler so we have somewhere to log problems # with ConfigInit() which needs to happen before we can start our create our # proper logging setup. syslog_logger = logging.getLogger("TempLogger") if os.path.exists("/dev/log"): handler = logging.handlers.SysLogHandler(address="/dev/log") else: handler = logging.handlers.SysLogHandler() syslog_logger.addHandler(handler) try: config_lib.SetPlatformArchContext() config_lib.ParseConfigCommandLine() except config_lib.Error: syslog_logger.exception("Died during config initialization") raise if hasattr(registry_init, "stats"): logging.debug("Using local stats collector.") stats.STATS = registry_init.stats.StatsCollector() else: logging.debug("Using default stats collector.") stats.STATS = stats.StatsCollector() server_logging.ServerLoggingStartupInit() registry.Init() # Exempt config updater from this check because it is the one responsible for # setting the variable. if not config.CONFIG.ContextApplied("ConfigUpdater Context"): if not config.CONFIG.Get("Server.initialized"): raise RuntimeError( "Config not initialized, run \"grr_config_updater" " initialize\". If the server is already configured," " add \"Server.initialized: True\" to your config.") INIT_RAN = True
def main(unused_argv): """Main.""" # Change the startup sequence in order to set the database path, if needed. startup.AddConfigContext() startup.ConfigInit() if flags.FLAGS.path: config_lib.CONFIG.Set("Datastore.location", flags.FLAGS.path) startup.ServerLoggingStartupInit() stats.STATS = stats.StatsCollector() # We avoid starting some hooks because they add unneeded things # to the data store. do_not_start = set( ["ConfigurationViewInitHook", "FileStoreInit", "GRRAFF4Init"]) registry.Init(skip_set=do_not_start) Start(data_store.DB, port=flags.FLAGS.port, is_master=flags.FLAGS.master)