Example #1
0
    if not args.r:
        setgid(common.ossec_gid)
        seteuid(common.ossec_uid)

    # Creating pid file
    create_pid("wazuh-clusterd", getpid())

    # Validate config
    try:
        check_cluster_config(cluster_config)
    except WazuhException as e:
        clean_exit(reason="Invalid configuration: '{0}'".format(str(e)),
                   error=True)

    # Clean all temporary files before starting
    clean_up()

    # Main
    try:

        if cluster_config['node_type'] == "master":
            manager_tag = "Master"
            logger.info("[{0}] PID: {1}".format(manager_tag, getpid()))

            try:
                master_main(cluster_config)
            except socket.error as e:
                if e.args[0] == socket.errno.EADDRINUSE:
                    logger.error(
                        "There is another wazuh-clusterd instance running. Please, close it. '{0}'."
                        .format(str(e)))
Example #2
0
    cluster_configuration = cluster.read_config(config_file=args.config_file)
    if cluster_configuration['disabled']:
        sys.exit(0)
    cluster_items = cluster.get_cluster_items()
    try:
        cluster.check_cluster_config(cluster_configuration)
    except Exception as e:
        main_logger.error(e)
        sys.exit(1)

    if args.test_config:
        sys.exit(0)

    # clean
    cluster.clean_up()

    # Foreground/Daemon
    if not args.foreground:
        pyDaemonModule.pyDaemon()

    # Drop privileges to ossec
    if not args.root:
        os.setgid(common.ossec_gid)
        os.setuid(common.ossec_uid)

    pyDaemonModule.create_pid('wazuh-clusterd', os.getpid())

    main_function = master_main if cluster_configuration[
        'node_type'] == 'master' else worker_main
    try: