home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / ARCHIE-1.2 / GET_PAUT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-04  |  2.1 KB  |  90 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.  
  8. #include <copyright.h>
  9. #include <stdio.h>
  10. #ifndef VMS
  11. # include <sys/types.h> /* this may/will define FD_SET etc */
  12. # include <pmachine.h>
  13. #endif
  14.  
  15. #ifdef NEED_STRING_H
  16. # include <string.h>
  17. #else
  18. # include <strings.h>
  19. #endif
  20.  
  21. #ifndef VMS
  22. # if defined(MSDOS) && !defined(OS2)
  23. #  ifndef CUTCP
  24. #   include <rwconf.h>
  25. #  endif
  26. # else
  27. #  include <pwd.h>
  28. # endif
  29. #else
  30. # include <jpidef.h>
  31. # include <vms.h>
  32. #endif
  33.  
  34. #include <pcompat.h>
  35. #include <pauthent.h>
  36.  
  37. PAUTH
  38. get_pauth(type)
  39.     int        type;
  40.     {
  41.     static PAUTH_ST   no_auth_st;
  42.     static PAUTH          no_auth = NULL;
  43. #if !defined(VMS) && !defined(MSDOS) || defined(OS2)
  44.     struct passwd *whoiampw;
  45. #else
  46.     char username[13];
  47.     unsigned short usernamelen;
  48.     struct {
  49.         unsigned short buflen;
  50.         unsigned short itmcod;
  51.         char *bufadr;
  52.         unsigned short *retlenadr;
  53.         unsigned long null;
  54.     } jpi_itemlist;
  55. #endif
  56.  
  57.     if(no_auth == NULL) {
  58.         no_auth = &no_auth_st;
  59.         strcpy(no_auth->auth_type,"UNAUTHENTICATED");
  60.  
  61.         /* find out who we are */
  62. #ifndef VMS
  63. #if defined(MSDOS) && !defined(OS2)
  64. #ifndef CUTCP
  65.         if (!getconf("general", "user", no_auth->authenticator, 250)
  66.         || (strlen (no_auth->authenticator) == 0))
  67. #endif
  68.           strcpy(no_auth->authenticator,"nobody");
  69. #else /* not MSDOS */
  70.         DISABLE_PFS(whoiampw = getpwuid(getuid()));
  71.         if (whoiampw == 0) strcpy(no_auth->authenticator,"nobody");
  72.         else strcpy(no_auth->authenticator, whoiampw->pw_name);
  73. #endif /* not MSDOS */
  74. #else
  75.         jpi_itemlist.buflen = sizeof(username);
  76.         jpi_itemlist.itmcod = JPI$_USERNAME;
  77.         jpi_itemlist.bufadr = &username;
  78.         jpi_itemlist.retlenadr = &usernamelen;
  79.         jpi_itemlist.null = 0;
  80.         if (SYS$GETJPI(0, 0, 0, &jpi_itemlist, 0, 0, 0) & 0x1)
  81.         {
  82.         username[usernamelen] = 0;
  83.         strcpy(no_auth->authenticator, username);
  84.         } else
  85.         strcpy(no_auth->authenticator, "nobody");
  86. #endif
  87.     }
  88.     return(no_auth);
  89.     }
  90.