Exemplo n.º 1
0
def main(argv):
  communication.Main(
      communication.Channel.FromSerialized(
          pipe_input=int(argv[1]), pipe_output=int(argv[2])),
      Handler,
      user="",
      group="")
Exemplo n.º 2
0
def main(argv):
    del argv
    communication.Main(
        communication.Channel.FromSerialized(
            pipe_input=flags.FLAGS.unprivileged_server_pipe_input,
            pipe_output=flags.FLAGS.unprivileged_server_pipe_output),
        interface_registry.GetConnectionHandlerForInterfaceString(
            flags.FLAGS.unprivileged_server_interface))
Exemplo n.º 3
0
def main(unused_args):
    client_plugins.RegisterPlugins()

    if flags.FLAGS.remote_debugging_port:
        _start_remote_debugging(flags.FLAGS.remote_debugging_port)
    elif flags.FLAGS.break_on_start:
        pdb.set_trace()

    if (flags.FLAGS.unprivileged_server_pipe_input != -1
            and flags.FLAGS.unprivileged_server_pipe_output != -1
            and flags.FLAGS.unprivileged_server_interface):
        communication.Main(
            communication.Channel.FromSerialized(
                pipe_input=flags.FLAGS.unprivileged_server_pipe_input,
                pipe_output=flags.FLAGS.unprivileged_server_pipe_output),
            interface_registry.GetConnectionHandlerForInterfaceString(
                flags.FLAGS.unprivileged_server_interface),
            flags.FLAGS.unprivileged_user, flags.FLAGS.unprivileged_group)
        return

    # 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()
        sys.exit(0)

    if config.CONFIG["Client.fleetspeak_enabled"]:
        fleetspeak_client.GRRFleetspeakClient().Run()
        return

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

    if errors and list(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()

    client.Run()
Exemplo n.º 4
0
 def testMain_entersSandbox(self):
   with mock.patch.object(sandbox, "EnterSandbox") as mock_enter_sandbox:
     input_fd = os.open("/dev/null", os.O_RDONLY)
     output_file = os.open("/dev/null", os.O_WRONLY)
     channel = communication.Channel(
         communication.FileDescriptor.FromFileDescriptor(input_fd),
         communication.FileDescriptor.FromFileDescriptor(output_file))
     communication.Main(channel, lambda connection: None, "fooUser",
                        "barGroup")
     mock_enter_sandbox.assert_called_with("fooUser", "barGroup")
Exemplo n.º 5
0
 def testMain_entersSandbox(self):
     # pylint: disable=g-import-not-at-top
     from grr_response_client.unprivileged.unix import sandbox
     # pylint: enable=g-import-not-at-top
     with mock.patch.object(sandbox, "EnterSandbox") as mock_enter_sandbox:
         input_fd = os.open("/dev/null", os.O_RDONLY)
         output_file = os.open("/dev/null", os.O_WRONLY)
         channel = communication.Channel(
             communication.FileDescriptor.FromFileDescriptor(input_fd),
             communication.FileDescriptor.FromFileDescriptor(output_file))
         communication.Main(channel, lambda connection: None, "fooUser",
                            "barGroup")
         mock_enter_sandbox.assert_called_with("fooUser", "barGroup")
Exemplo n.º 6
0
def main(unused_args):
  if flags.FLAGS.remote_debugging_port:
    _start_remote_debugging(flags.FLAGS.remote_debugging_port)
  elif flags.FLAGS.break_on_start:
    pdb.set_trace()

  if flags.FLAGS.filesystem_server_socket != -1:
    communication.Main(flags.FLAGS.filesystem_server_socket,
                       server_lib.Dispatch)
    return

  # 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()
    sys.exit(0)

  if config.CONFIG["Client.fleetspeak_enabled"]:
    fleetspeak_client.GRRFleetspeakClient().Run()
    return

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

  if errors and list(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()

  client.Run()
Exemplo n.º 7
0
def main(argv):
  communication.Main(int(argv[1]), server_lib.Dispatch)
Exemplo n.º 8
0
def main(argv):
    communication.Main(int(argv[1]), Handler)
Exemplo n.º 9
0
def main(argv):
  communication.Main(
      communication.Channel(pipe_input=int(argv[1]), pipe_output=int(argv[2])),
      server_lib.Dispatch)
Exemplo n.º 10
0
def main(argv):
  communication.Main(
      communication.Channel(pipe_input=int(argv[1]), pipe_output=int(argv[2])),
      Handler)