// Receives pid of the invoked process.
// Invoker doesn't know it, because the launcher daemon
// is the one who forks.
static uint32_t invoker_recv_pid(int fd)
{
  uint32_t action, pid;

   // Receive action.
  invoke_recv_msg(fd, &action);

  if (action != INVOKER_MSG_PID)
      die(1, "Received a bad pid (%08x)\n", action);

  // Receive pid.
  invoke_recv_msg(fd, &pid);
  return pid;
}
Esempio n. 2
0
// Receives pid of the invoked process.
// Invoker doesn't know it, because the launcher daemon
// is the one who forks.
static uint32_t invoker_recv_pid(int fd)
{
    // Receive action.
    uint32_t action;
    invoke_recv_msg(fd, &action);
    if (action != INVOKER_MSG_PID)
        die(1, "Received a bad message id (%08x)\n", action);

    // Receive pid.
    uint32_t pid = 0;
    invoke_recv_msg(fd, &pid);
    if (pid == 0)
        die(1, "Received a zero pid \n");

    return pid;
}
// Receives exit status of the invoked process
static uint32_t invoker_recv_exit(int fd)
{
  uint32_t action, status;

  // Receive action.
  invoke_recv_msg(fd, &action);

  if (action != INVOKER_MSG_EXIT)
  {
      // Boosted application process was killed somehow.
      // Let's give applauncherd process some time to cope 
      // with this situation.
      sleep(2);

      // If nothing happend, return
      return EXIT_STATUS_APPLICATION_CONNECTION_LOST;
  }
  
  // Receive exit status.
  invoke_recv_msg(fd, &status);
  return status;
}
Esempio n. 4
0
// Receives exit status of the invoked process
static bool invoker_recv_exit(int fd, int* status)
{
    uint32_t action;

    // Receive action.
    bool res = invoke_recv_msg(fd, &action);

    if (!res || (action != INVOKER_MSG_EXIT))
    {
        // Boosted application process was killed somehow.
        // Let's give applauncherd process some time to cope 
        // with this situation.
        sleep(2);

        // If nothing happend, return
        return false;
    }
  
    // Receive exit status.
    res = invoke_recv_msg(fd, (uint32_t*) status);
    return res;
}
Esempio n. 5
0
// Receive ACK
static bool invoke_recv_ack(int fd)
{
    uint32_t action;

    invoke_recv_msg(fd, &action);

    if (action != INVOKER_MSG_ACK)
    {
        die(1, "Received wrong ack (%08x)\n", action);
    }

    return true;
}
// Receive ACK
static bool invoke_recv_ack(int fd)
{
    uint32_t action;

    invoke_recv_msg(fd, &action);

    if (action == INVOKER_MSG_BAD_CREDS)
    {
        die(1, "Security credential check failed.\n");
    }
    else if (action != INVOKER_MSG_ACK)
    {
        die(1, "Received wrong ack (%08x)\n", action);
    }

    return true;
}
Esempio n. 7
0
char *
invoke_recv_str(int fd)
{
  uint32_t size;
  char *str;

  /* Get the size. */
  if ( !invoke_recv_msg(fd, &size) )
  {
    error("string size read failure in %s\n", __FUNCTION__);
    return NULL;
  }

  if (size > INVOKER_MAX_STRING_SIZE)
  {
    error("string size is %u and larger than %u in %s\n", size, INVOKER_MAX_STRING_SIZE, __FUNCTION__);
    return NULL;
  }

  str = malloc(size + 1);
  if (!str)
  {
    error("mallocing in %s for %u bytes string failed\n", __FUNCTION__, size);
    return NULL;
  }

  /* Get the string if size is non-zero */
  if ( size )
  {
    const int ret = invoke_raw_read(fd, str, size);
    if ( ret )
    {
      error("getting string with %u bytes got error %d\n", size, ret);
      free(str);
      return NULL;
    }
  }
  str[size] = 0;

  debug("%s: '%s'\n", __FUNCTION__, str);

  return str;
}