home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / C_ARCHI1.TAR / archie / get_pauth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-19  |  2.2 KB  |  91 lines

  1. /*
  2.  * Copyright (c) 1989, 1990 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  *
  7.  * v1.2.2 - 11/19/91 (mmt) - added MSDOS & OS2 stuff
  8.  * v1.2.1 - 09/17/91 (bpk) - added BULL & USG stuff, thanks to Jim Sillas
  9.  * v1.2.0 - 09/17/91 (bpk) - fixed it up (thanks to synful)
  10.  * v1.1.1 - 08/30/91 (bpk) - added VMS support
  11.  */
  12.  
  13. #include <copyright.h>
  14. #include <stdio.h>
  15. #ifndef VMS
  16. # include <sys/types.h> /* this may/will define FD_SET etc */
  17. # include <pmachine.h>
  18. #endif
  19.  
  20. #ifdef NEED_STRING_H
  21. # include <string.h>
  22. #else
  23. # include <strings.h>
  24. #endif
  25.  
  26. #ifndef VMS
  27. # if defined(MSDOS) && !defined(OS2)
  28. #  include <rwconf.h>
  29. # else
  30. #  include <pwd.h>
  31. # endif
  32. #else
  33. # include <jpidef.h>
  34. # include <vms.h>
  35. #endif
  36.  
  37. #include <pcompat.h>
  38. #include <pauthent.h>
  39.  
  40. PAUTH
  41. get_pauth(type)
  42.     int        type;
  43.     {
  44.     static PAUTH_ST   no_auth_st;
  45.     static PAUTH          no_auth = NULL;
  46. #if !defined(VMS) && !defined(MSDOS) || defined(OS2)
  47.     struct passwd *whoiampw;
  48. #else
  49.     char username[13];
  50.     unsigned short usernamelen;
  51.     struct {
  52.         unsigned short buflen;
  53.         unsigned short itmcod;
  54.         char *bufadr;
  55.         unsigned short *retlenadr;
  56.         unsigned long null;
  57.     } jpi_itemlist;
  58. #endif
  59.  
  60.     if(no_auth == NULL) {
  61.         no_auth = &no_auth_st;
  62.         strcpy(no_auth->auth_type,"UNAUTHENTICATED");
  63.  
  64.         /* find out who we are */
  65. #ifndef VMS
  66. #if defined(MSDOS) && !defined(OS2)
  67.         if (!getconf("general", "user", no_auth->authenticator, 250)
  68.         || (strlen (no_auth->authenticator) == 0))
  69.           strcpy(no_auth->authenticator,"nobody");
  70. #else /* not MSDOS */
  71.         DISABLE_PFS(whoiampw = getpwuid(getuid()));
  72.         if (whoiampw == 0) strcpy(no_auth->authenticator,"nobody");
  73.         else strcpy(no_auth->authenticator, whoiampw->pw_name);
  74. #endif /* not MSDOS */
  75. #else
  76.         jpi_itemlist.buflen = sizeof(username);
  77.         jpi_itemlist.itmcod = JPI$_USERNAME;
  78.         jpi_itemlist.bufadr = &username;
  79.         jpi_itemlist.retlenadr = &usernamelen;
  80.         jpi_itemlist.null = 0;
  81.         if (SYS$GETJPI(0, 0, 0, &jpi_itemlist, 0, 0, 0) & 0x1)
  82.         {
  83.         username[usernamelen] = 0;
  84.         strcpy(no_auth->authenticator, username);
  85.         } else
  86.         strcpy(no_auth->authenticator, "nobody");
  87. #endif
  88.     }
  89.     return(no_auth);
  90.     }
  91.