Ejemplo n.º 1
0
// Sends UID and GID
static void invoker_send_ids(int fd, int uid, int gid)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_IDS);
    invoke_send_msg(fd, uid);
    invoke_send_msg(fd, gid);
}
Ejemplo n.º 2
0
static void invoker_send_args(int fd, int argc, char **argv)
{
    int i;

    invoke_send_msg(fd, INVOKER_MSG_ARGS);
    invoke_send_msg(fd, argc);
    for (i = 0; i < argc; i++)
    {
        debug("param %d %s \n", i, argv[i]);
        invoke_send_str(fd, argv[i]);
    }
}
Ejemplo n.º 3
0
// Sends the END message
static void invoker_send_end(int fd)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_END);
    invoke_recv_ack(fd);

}
Ejemplo n.º 4
0
bool
invoke_send_str(int fd, char *str)
{
  uint32_t size;

  /* Send size. */
  size = (str && *str ? strlen(str) : 0);
  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 false;
  }

  if ( !invoke_send_msg(fd, size) )
  {
    error("unable to write string size is %u in %s\n", size, __FUNCTION__);
    return false;
  }

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

  /* Send the string if size is non-zero */
  if (size && size != (uint32_t)write(fd, str, size))
  {
    error("unable to write string with size %u in %s\n", size, __FUNCTION__);
    return false;
  }

  return true;
}
Ejemplo n.º 5
0
// Sends the environment variables
static void invoker_send_env(int fd)
{
    int i, n_vars;

    // Count environment variables.
    for (n_vars = 0; environ[n_vars] != NULL; n_vars++) ;

    invoke_send_msg(fd, INVOKER_MSG_ENV);
    invoke_send_msg(fd, n_vars);

    for (i = 0; i < n_vars; i++)
    {
        invoke_send_str(fd, environ[i]);
    }

    return;
}
void invoke_send_str(int fd, char *str)
{
    if (str)
    {
        uint32_t size;

        /* Send size. */
        size = strlen(str) + 1;
        invoke_send_msg(fd, size);

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

        /* Send the string. */
        write(fd, str, size);
    }
}
Ejemplo n.º 7
0
// Sends I/O descriptors
static void invoker_send_io(int fd)
{
    struct msghdr msg;
    struct cmsghdr *cmsg = NULL;
    int io[3] = { 0, 1, 2 };
    char buf[CMSG_SPACE(sizeof(io))];
    struct iovec iov;
    int dummy;

    memset(&msg, 0, sizeof(struct msghdr));

    iov.iov_base = &dummy;
    iov.iov_len = 1;

    msg.msg_iov = &iov;
    msg.msg_iovlen = 1;
    msg.msg_control = buf;
    msg.msg_controllen = sizeof(buf);

    cmsg = CMSG_FIRSTHDR(&msg);
    cmsg->cmsg_len = CMSG_LEN(sizeof(io));
    cmsg->cmsg_level = SOL_SOCKET;
    cmsg->cmsg_type = SCM_RIGHTS;

    memcpy(CMSG_DATA(cmsg), io, sizeof(io));

    msg.msg_controllen = cmsg->cmsg_len;

    invoke_send_msg(fd, INVOKER_MSG_IO);
    if (sendmsg(fd, &msg, 0) < 0)
    {
        warning("sendmsg failed in invoker_send_io: %s \n", strerror(errno));
    }

    return;
}
Ejemplo n.º 8
0
// Sends booster respawn delay
static void invoker_send_delay(int fd, int delay)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_DELAY);
    invoke_send_msg(fd, delay);
}
Ejemplo n.º 9
0
static void invoker_send_prio(int fd, int prio)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_PRIO);
    invoke_send_msg(fd, prio);
}
Ejemplo n.º 10
0
static void invoker_send_exec(int fd, char *exec)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_EXEC);
    invoke_send_str(fd, exec);
}
Ejemplo n.º 11
0
// Sends the process name to be invoked.
static void invoker_send_name(int fd, char *name)
{
    // Send action.
    invoke_send_msg(fd, INVOKER_MSG_NAME);
    invoke_send_str(fd, name);
}
Ejemplo n.º 12
0
// Sends magic number / protocol version
static void invoker_send_magic(int fd, uint32_t options)
{
    // Send magic.
    invoke_send_msg(fd, INVOKER_MSG_MAGIC | INVOKER_MSG_MAGIC_VERSION | options);
}
Ejemplo n.º 13
0
static void invoker_send_landscape_splash_file(int fd, char *filename)
{
    invoke_send_msg(fd, INVOKER_MSG_LANDSCAPE_SPLASH);
    invoke_send_str(fd, filename);
}