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

a()
{
  int fd;

  if ((fd = open("/mit/ark/temp/yahoo", O_RDONLY, 0)) > 0)
    {
      printf("Open succeeded\n");
      close(fd);
    }
  else printf("Open failed\n");
}

main()
{
  printf("Becoming ark\n");
  setuid(2915);
  printf("Uid is now %d\n", getuid());
  a();
  getc(stdin);

  printf("Setting euid to thorne\n");
  seteuid(14493);
  printf("Uid is now %d\n", getuid());
  a();
  getc(stdin);

  printf("Going back to root\n");
  seteuid(0);
  printf("Uid is now %d\n", getuid());
  a();
  getc(stdin);
  
  printf("Setting uid to thorne\n");
  setuid(14493);
  printf("Uid is now %d\n", getuid());
  a();
  getc(stdin);

  printf("Back to root\n");
  setruid(0);
  printf("Uid is now %d\n", getuid());
  a();
  getc(stdin);
}
