예제 #1
0
void		get_list(struct s_static_socket *br)
{
  FILE		*list;
  char		buffer[BUF_SIZE];
  size_t	octet;

  if (open_dataconnection(br) == -1)
    return ;
  if (br->pasv == -1)
    xwrite(br->cs, "425 Can't open data connection\n", 31);
  else
    {
      my_putstr("LIST REQUEST\n");
      if (get_list_popen(br, &list) == -1)
	return ;
      while ((octet = fread(buffer, 1, BUF_SIZE, list)) > 0)
	xwrite(br->pasv, buffer, octet);
      xclose(br->pasv);
      br->pasv = -1;
      xfpurge(list);
      usleep(500000);
      xwrite(br->cs, "226 Transfer complete\n", 22);
      xpclose(list);
    }
}
예제 #2
0
static hostlist_t 
_read_genders_attr(char *attr, int iopt)
{
    FILE *f;
    hostlist_t hl = hostlist_create(NULL);
    char cmd[LINEBUFSIZE];
    char buf[LINEBUFSIZE];

    /* 
     *   xpopen sets uid back to real user id, so it is ok to use 
     *     "nodeattr" from user's path here
     */
    snprintf(cmd, sizeof(cmd), "%s %s%s -%sn %s", _PATH_NODEATTR, 
             gfile ? "-f " : "",
             gfile ? gfile : "",
             iopt ? "" : "r", attr);

    f = xpopen(cmd, "r");
    if (f == NULL)
        errx("%p: error running \"%s\"\n", _PATH_NODEATTR);
    while (fgets(buf, LINEBUFSIZE, f) != NULL) {
        xstrcln(buf, NULL);
        if (hostlist_push(hl, buf) <= 0)
            err("%p: warning: target `%s' not parsed\n", buf);
    }
    if (xpclose(f) != 0)
        errx("%p: error running nodeattr\n");

    return hl;
}
예제 #3
0
void		get_pwd_pop(char *pwd)
{
  FILE		*stream;
  size_t	octet;

  stream = popen_result("pwd");
  octet = xfread(pwd, 1, 2048, stream);
  if (pwd[octet - 1] == '\n')
    pwd[octet - 1] = '\0';
  pwd[octet] = '\0';
  xfpurge(stream);
  xpclose(stream);
}