Possible fixed identd

Phillip R. Jaenke (prj@NLS.NET)
Wed, 13 Aug 1997 21:05:51 -0400

Moving right along, ahead of schedule..

Submitted for your approval and testing, a slightly modified identd.

Please note, this is UNTESTED as of 09:13 EDT, Wednesday, August 13th.
I'm currently swamped, but will be attempting to run a few tests today.

Compiles cleanly on Linux.

[root@maezw /root]# gcc -Wall -O3 -m486 identd.c -o identd
[root@maezw /root]#

Any contributions, ideas, suggestions, please email me privately. If
you have an OS that it does NOT compile on, and you create a fix or
patch, please share with the entire list. Thanks, and enjoy! :)

--------8<---cut here--->8---------

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <ctype.h>
#include <string.h>

int writeranduser(void)
{
int r;
char username[12];
srandom(getpid());
memset(username, 0, 12);
r = random() % 26;
r = r + 'a';
memset(username, r, 11);
if(write(1, username, strlen(username)) < strlen(username))
exit(0);
return 1;
}

int main(int argc, char **argv)
{
char genrandomuser = 1;
char *portpair = NULL;
fd_set rset;
struct timeval tv;
int i;

if(argc > 1) genrandomuser = 0;
portpair = malloc(1024);
if(!portpair)
exit(0);
memset(portpair, 0, 1024);
tv.tv_sec = 180;
tv.tv_usec = 0;
FD_ZERO(&rset);
FD_SET(0, &rset);
i = select(1, &rset, NULL, NULL, &tv);
if(i < 1)
exit(0);
if(read(0, portpair, 512) < 1)
exit(0);
while(*portpair)
{
if(isdigit(*portpair))
if(write(1, portpair, 1) < 0)
exit(0);
else;
else if(*portpair == ',')
if(write(1, portpair, 1) < 0)
exit(0);
else;
portpair++;
}
if(write(1, " : USERID : UNIX : ", 19) < 19)
exit(0);
if(!genrandomuser)
if(write(1, argv[1], strlen(argv[1])) < strlen(argv[1]))
exit(0);
else;
else
writeranduser();
if(write(1, "\r\n", 2) < 2)
exit(0);
return 1;
}

-Phillip R. Jaenke (InterNIC Handle: PRJ5) [prj@NLS.NET]
UNIX Systems Administration, Management, and Technical Support,
NetLink Services, Inc. (216/468.5100 - sales@nls.net - www.nls.net)
"People disagree with me. I just ignore them." -- Linus Torvalds
-RC5- Team Nightmare (ARRRRRRRRGH!! We lost our webserver. AGAIN!)
"RC5 - DES Was Too Easy!" -- [i386] @ IRC