NNTPC: rfc931 broken?, stats?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Julian Assange writes:

  > Does the rfc931 code in nntpcache-1.0 work?  We have a working identd
  > daemon here, rfc931 is `yes' in the nntpcache config file, yet every
  > entry in the log shows a connection by `unknown@machine-name'.  This
  > is on Sunos-4.1.3.
  
  I tested this code yesterday, and it seems to work under linux at
  least. It is possible that it doesn't like sunos, though it isn't
  immidiately obvious how that could be.

It works on Sunos-4.1.3 with the following function substituted for
the one originally in acc.c.

-- 

   Ronald Florence		Maple Lawn Farm, Stonington, CT
   ron@mlfarm.com		http://www.connix.com/~mlfarm



----------[rfc931]----------

char *rfc931(struct sockaddr_in *our_sin, struct sockaddr_in *remote_sin)
{
  int fd;
  struct sockaddr_in addr;
  int addrlen;
  int port;
  FILE *fp_in, *fp_out;
  int lport, fport;
  char buffer[8192];
  char *cp;
  char user[1024];

  addr = *remote_sin;
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd == -1)
    return(NULL);

  addr.sin_family = AF_INET;
  port = 113;
  addr.sin_port = htons(port);
  addrlen = sizeof(addr);

  if (connect(fd, &addr, addrlen) == -1)
    return(NULL);

  addrlen = sizeof(addr);
  if (getsockname(fd, &addr, &addrlen) == -1)
    return(NULL);

  fp_in  = fdopen(fd, "r");
  fp_out = fdopen(fd, "w");
  if (!fp_in || !fp_out)
    return(NULL);

  fprintf(fp_out, "%d , %d\n", ntohs(addr.sin_port), port);
  fflush(fp_out);
  if (fgets(buffer, sizeof(buffer)-1, fp_in) == NULL)
    return(NULL);
  shutdown(fd, 1);
  cp = buffer;
  while (*cp != 0 && (*cp < ' ' || isspace(*cp)))
      ++cp;
  if (sscanf(cp, "%d , %d : USERID : %*[^:] : %[^\n\r]",
		&lport, &fport,  user) !=  3)
    return(NULL);
  fclose(fp_out);
  fclose(fp_in);

  return(user);
}

-----------[eof]-----------


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux