home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / LINUX_PC.TAR / pcnfsd_linux2 / pcnfsd_v1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-06  |  4.2 KB  |  194 lines

  1. /* RE_SID: @(%)/tmp_mnt/vol/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v1.c 1.4 93/01/29 17:53:53 SMI */
  2. /*
  3. **=====================================================================
  4. ** Copyright (c) 1986-1993 by Sun Microsystems, Inc.
  5. **      @(#)pcnfsd_v1.c    1.4     1/29/93
  6. **=====================================================================
  7. *    Code hacked by meister@ftp.com to allow Ultrix4.X auth database to be 
  8. *    understood 10/15/92
  9. */
  10. #include "common.h"
  11.  
  12. /*
  13. **=====================================================================
  14. **             I N C L U D E   F I L E   S E C T I O N                *
  15. **                                                                    *
  16. ** If your port requires different include files, add a suitable      *
  17. ** #define in the customization section, and make the inclusion or    *
  18. ** exclusion of the files conditional on this.                        *
  19. **=====================================================================
  20. */
  21. #include "pcnfsd.h"
  22.  
  23. #include <stdio.h>
  24. #include <pwd.h>
  25. #include <sys/file.h>
  26. #include <signal.h>
  27. #include <sys/stat.h>
  28. #include <sys/ioctl.h>
  29. #include <netdb.h>
  30. #include <string.h>
  31.  
  32. #ifndef SYSV
  33. #include <sys/wait.h>
  34. #endif
  35.  
  36. #ifdef ISC_2_0
  37. #include <sys/fcntl.h>
  38. #endif
  39.  
  40. #ifdef SHADOW_SUPPORT
  41. #include <shadow.h>
  42. #endif
  43.  
  44. #ifdef ULTRIX_AUTH
  45. # include <auth.h>
  46. #endif
  47.  
  48. /*
  49. **---------------------------------------------------------------------
  50. ** Other #define's 
  51. **---------------------------------------------------------------------
  52. */
  53.  
  54. extern void     scramble();
  55. extern char    *crypt();
  56.  
  57. #ifdef WTMP
  58. extern void wlogin();
  59. #endif
  60.  
  61. extern struct passwd  *get_password();
  62.  
  63. /*
  64. **---------------------------------------------------------------------
  65. **                       Misc. variable definitions
  66. **---------------------------------------------------------------------
  67. */
  68.  
  69. int             buggit = 0;
  70.  
  71. /*
  72. **=====================================================================
  73. **                      C O D E   S E C T I O N                       *
  74. **=====================================================================
  75. */
  76.  
  77.  
  78. /*ARGSUSED*/
  79. void *pcnfsd_null_1(arg)
  80. void *arg;
  81. {
  82. static char dummy;
  83. return((void *)&dummy);
  84. }
  85.  
  86. auth_results *pcnfsd_auth_1(arg)
  87. auth_args *arg;
  88. {
  89. static auth_results r;
  90.  
  91. char            uname[32];
  92. char            pw[64];
  93. int             c1, c2;
  94. char        *msgp;
  95. struct passwd  *p;
  96.  
  97. #ifdef ULTRIX_AUTH
  98.     struct authorization *authbuf;
  99.     char   salt [2];
  100. #endif
  101.  
  102.     r.stat = AUTH_RES_FAIL;    /* assume failure */
  103.     r.uid = (int)-2;
  104.     r.gid = (int)-2;
  105.  
  106.     scramble(arg->id, uname);
  107.     scramble(arg->pw, pw);
  108.  
  109. #ifdef USER_CACHE
  110.     if(check_cache(uname, pw, &r.uid, &r.gid)) {
  111.          r.stat = AUTH_RES_OK;
  112. #ifdef WTMP
  113.         wlogin(uname);
  114. #endif
  115.          return (&r);
  116.    }
  117. #endif
  118.  
  119.     p = get_password(uname, &msgp);
  120.     if (p == (struct passwd *)NULL)
  121.        return (&r);
  122.  
  123. #ifdef ULTRIX_AUTH
  124.         if (p->pw_passwd [0] == '*')
  125.         {
  126.         authbuf = getauthuid (p->pw_uid);
  127.             if (!authbuf)
  128.             {    return (&r);
  129.             }
  130.  
  131.             salt [0] = authbuf->a_password [0];
  132.             salt [1] = authbuf->a_password [1];
  133.             c1 = strlen(pw);
  134.             c2 = strlen(authbuf->a_password);
  135.             if ((c1 && !c2) || (c2 && !c1))
  136.                 return (&r);
  137.             if (strncmp (crypt16 (pw, salt), authbuf->a_password, 
  138.                 CRYPT_PASSWORD_LENGTH))
  139.             {   return (&r);
  140.             }
  141.         }
  142.         else
  143.         {
  144. #endif
  145.     c1 = strlen(pw);
  146.     c2 = strlen(p->pw_passwd);
  147.     if ((c1 && !c2) || (c2 && !c1) ||
  148.        (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) 
  149.            {
  150.        return (&r);
  151.        }
  152. #ifdef ULTRIX_AUTH
  153.         }
  154. #endif
  155.  
  156.     r.stat = AUTH_RES_OK;
  157.     r.uid = p->pw_uid;
  158.     r.gid = p->pw_gid;
  159. #ifdef WTMP
  160.         wlogin(uname);
  161. #endif
  162.  
  163. #ifdef USER_CACHE
  164.     add_cache_entry(p);
  165. #endif
  166.  
  167. return(&r);
  168. }
  169.  
  170. pr_init_results *pcnfsd_pr_init_1(pi_arg)
  171. pr_init_args *pi_arg;
  172. {
  173. static pr_init_results pi_res;
  174.  
  175.     pi_res.stat =
  176.       (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
  177.  
  178. return(&pi_res);
  179. }
  180.  
  181. pr_start_results *pcnfsd_pr_start_1(ps_arg)
  182. pr_start_args *ps_arg;
  183. {
  184. static pr_start_results ps_res;
  185. char *dummyptr;
  186.  
  187.     ps_res.stat =
  188.       (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
  189.       ps_arg ->file, ps_arg->opts, &dummyptr);
  190.  
  191. return(&ps_res);
  192. }
  193.  
  194.