home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / XARCHIE2.TAR / get_pauth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-02  |  1.7 KB  |  78 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.1 - 09/17/91 (bpk) - added BULL & USG stuff, thanks to Jim Sillas
  8.  * v1.2.0 - 09/17/91 (bpk) - fixed it up (thanks to synful)
  9.  * v1.1.1 - 08/30/91 (bpk) - added VMS support
  10.  */
  11.  
  12. #include <copyright.h>
  13. #include <stdio.h>
  14. #ifndef VMS
  15. # include <sys/types.h>
  16. #endif
  17.  
  18. #if defined(USG) || defined(UTS) || defined(_AIX)
  19. # include <string.h>
  20. #else
  21. # include <strings.h>
  22. #endif
  23.  
  24. #ifndef VMS
  25. # include <pwd.h>
  26. #else
  27. # include <jpidef.h>
  28. #endif
  29.  
  30. #include <pcompat.h>
  31. #include <pauthent.h>
  32.  
  33. PAUTH
  34. get_pauth(type)
  35.     int        type;
  36.     {
  37.     static PAUTH_ST   no_auth_st;
  38.     static PAUTH          no_auth = NULL;
  39. #ifndef VMS
  40.     struct passwd *whoiampw;
  41. #else
  42.     char username[13];
  43.     unsigned short usernamelen;
  44.     struct {
  45.         unsigned short buflen;
  46.         unsigned short itmcod;
  47.         char *bufadr;
  48.         unsigned short *retlenadr;
  49.         unsigned long null;
  50.     } jpi_itemlist;
  51. #endif
  52.  
  53.     if(no_auth == NULL) {
  54.         no_auth = &no_auth_st;
  55.         strcpy(no_auth->auth_type,"UNAUTHENTICATED");
  56.  
  57.         /* find out who we are */
  58. #ifndef VMS
  59.         DISABLE_PFS(whoiampw = getpwuid(getuid()));
  60.         if (whoiampw == 0) strcpy(no_auth->authenticator,"nobody");
  61.         else strcpy(no_auth->authenticator, whoiampw->pw_name);
  62. #else
  63.         jpi_itemlist.buflen = sizeof(username);
  64.         jpi_itemlist.itmcod = JPI$_USERNAME;
  65.         jpi_itemlist.bufadr = &username;
  66.         jpi_itemlist.retlenadr = &usernamelen;
  67.         jpi_itemlist.null = 0;
  68.         if (SYS$GETJPI(0, 0, 0, &jpi_itemlist, 0, 0, 0) & 0x1)
  69.         {
  70.         username[usernamelen] = 0;
  71.         strcpy(no_auth->authenticator, username);
  72.         } else
  73.         strcpy(no_auth->authenticator, "nobody");
  74. #endif
  75.     }
  76.     return(no_auth);
  77.     }
  78.