home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume22 / auth-utils / part01 / tam / tamsetup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-29  |  634 b   |  34 lines

  1. /* tamsetup version 1.0, 4/23/90. */
  2.  
  3. #include <stdio.h>
  4. #include <sys/file.h>
  5. #ifdef BSD
  6. #include <limits.h>
  7. #endif
  8. #include <pwd.h>
  9.  
  10. #ifndef TAMDIR
  11. #define TAMDIR "/usr/spool/tam"
  12. #endif
  13.  
  14. main()
  15. {
  16.  struct passwd *pw;
  17.  char path[sizeof(TAMDIR) + 11];
  18.  int fd;
  19.  
  20.  if (!(pw = getpwuid(getuid())))
  21.   {
  22.    fprintf(stderr,"tamsetup: fatal: who are you?\n");
  23.    exit(1);
  24.   }
  25.  (void) sprintf(path,"%s/%s",TAMDIR,pw->pw_name);
  26.  if ((fd = open(path,O_WRONLY | O_CREAT | O_EXCL,0600)) == -1)
  27.   {
  28.    perror("tamsetup: fatal: can't create tam spool file");
  29.    exit(2);
  30.   }
  31.  fprintf(stderr,"tamsetup: okay, tam spool file created\n");
  32.  exit(0);
  33. }
  34.