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