relatively simple hack to lookup login-names

From: d. hall (dhall@sunspot.tiac.net)
Date: 12/17/95


there was previous discussion about looking up login names.  after thinking
about it a little, i tried to figure out the easiest way to incorporate it,
without changing stock circle's mechanics and internals to some great
degree, and this seems to be the easiest.

this is a hack job that can be better accomplished with a little rewrite of
segments of source code throughout, but this for people who want to get it
done fast, with as little overall source change.  it does require a slight
modification of the complete player database (but since it's only extending
one of the strings in the basic structure, a comversion program will do
nicely).

first, get you hands on libident-0.17 or a later version, i believe one can
be found at ftp.cs.jhu.edu.  download and compile it.  if it doesn't
support your platform, then this solution isn't for you, unless you know
networking and your platform well.

now, you'll need extra space in the host field of descriptor_data
structure, about 16 (assuming usernames don't exceed this length) so change
the #define HOST_LENGTH from 30 to 46. (!NOTE! this does change how db.c
will write character data to the playerfile)

Add in the following lines to comm.c

#include "ident.h"	/* this include file comes with libident */

in function new_descriptor()

char *idname;

search forward for the initialization of newd->host.

  /* create a new descriptor */
  CREATE(newd, struct descriptor_data, 1);
  memset((char *) newd, 0, sizeof(struct descriptor_data));

  idname = ident_id (desc, 5);	/* this attempts to get the username */

  if (idname == NULL)
    idname = str_dup ("unknown");
    
  /* find the sitename */
  if (nameserver_is_slow || !(from = gethostbyaddr((char *) &peer.sin_addr,
					 sizeof(peer.sin_addr), AF_INET))) {
    if (!nameserver_is_slow)
      perror("gethostbyaddr");
    addr = ntohl(peer.sin_addr.s_addr);
    sprintf(newd->host, "%.16s@%d.%d.%d.%d", idname,
	    (int)((addr & 0xFF000000) >> 24),
	    (int)((addr & 0x00FF0000) >> 16),
	    (int)((addr & 0x0000FF00) >> 8),
	    (int)((addr & 0x000000FF)));
  } else {
    sprintf (newd->host, "%.16s@%.30s", idname, from->h_name);
    *(newd->host + HOST_LENGTH) = '\0';
  }
  free (idname);		/* important to prevent memory leaks =) */

  /* determine if the site is banned */
  /* isbanned needs the "old" site name so pass it strchr() for '@' */
  /* the '@' should exist, since it was explicitedly placed there   */
  if (isbanned (strchr(newd->host,'@')) == BAN_ALL) {
    close(desc);
    sprintf(buf2, "Connection attempt denied from [%s]", newd->host);
    mudlog(buf2, CMP, LVL_GOD, TRUE);
    free(newd);
    return 0;
  }

with this change, the users command will list usernames... of course this
is only if the player's site has identd running on port 113.  if not, then
there isn't an easy way to find out.  this can be further expanded to
included isbanned functionality, so you can band specific usernames (from
their respective sites).  there still might be some conflicts...

d.
--
``god save us, we're in the hands of engineers.''
					- ian malcolm, jurassic park



This archive was generated by hypermail 2b30 : 12/07/00 PST