def main(unused_args):
    # Allow per platform configuration.
    config_lib.CONFIG.AddContext(
        "Client Context", "Context applied when we run the client process.")

    startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()

    errors = config_lib.CONFIG.Validate(["Client", "CA", "Logging"])

    if errors and errors.keys() != ["Client.private_key"]:
        raise config_lib.ConfigFormatError(errors)

    enrollment_necessary = not config_lib.CONFIG.Get("Client.private_key")
    # Instantiating the client will create a private_key so we need to use a flag.
    client = GRRClient()
    if enrollment_necessary:
        logging.info("No private key found, starting enrollment.")
        client.client.InitiateEnrolment(comms.Status())

    if flags.FLAGS.break_on_start:
        pdb.set_trace()
    else:
        client.Run()
示例#2
0
文件: client.py 项目: sh1nu11bi/grr
def main(unused_args):
    # Allow per platform configuration.
    config.CONFIG.AddContext(
        contexts.CLIENT_CONTEXT,
        "Context applied when we run the client process.")

    client_startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()

    errors = config.CONFIG.Validate(["Client", "CA", "Logging"])

    if errors and errors.keys() != ["Client.private_key"]:
        raise config_lib.ConfigFormatError(errors)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        raise ValueError(
            "This is not a Fleetspeak client, yet 'Client.fleetspeak_enabled' is "
            "set to 'True'.")

    enrollment_necessary = not config.CONFIG.Get("Client.private_key")
    # Instantiating the client will create a private_key so we need to use a flag.
    client = comms.GRRHTTPClient(ca_cert=config.CONFIG["CA.certificate"],
                                 private_key=config.CONFIG.Get(
                                     "Client.private_key", default=None))

    if enrollment_necessary:
        logging.info("No private key found, starting enrollment.")
        client.InitiateEnrolment()

    if flags.FLAGS.break_on_start:
        pdb.set_trace()
    else:
        client.Run()
示例#3
0
def main(unused_args):
    # Allow per platform configuration.
    config_lib.CONFIG.AddContext(
        "Client Context", "Context applied when we run the client process.")

    startup.ClientInit()

    if flags.FLAGS.install:
        installer.RunInstaller()

    errors = config_lib.CONFIG.Validate(["Client", "CA", "Logging"])

    if not errors:
        client = GRRClient()
    elif errors.keys() == ["Client.private_key"]:
        client = GRRClient()
        client.client.InitiateEnrolment(comms.Status())
    else:
        raise config_lib.ConfigFormatError(errors)

    if flags.FLAGS.break_on_start:
        pdb.set_trace()
    else:
        client.Run()