Home | History | Annotate | Line # | Download | only in rpc.pcnfsd
pcnfsd_v1.c revision 1.2
      1  1.2  gwr /*	$NetBSD: pcnfsd_v1.c,v 1.2 1995/07/25 22:21:19 gwr Exp $	*/
      2  1.2  gwr 
      3  1.1  jtc /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v1.c 1.1 91/09/03 12:41:50 SMI */
      4  1.1  jtc /*
      5  1.1  jtc **=====================================================================
      6  1.1  jtc ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
      7  1.1  jtc **	@(#)pcnfsd_v1.c	1.1	9/3/91
      8  1.1  jtc **=====================================================================
      9  1.1  jtc */
     10  1.1  jtc #include "common.h"
     11  1.1  jtc 
     12  1.1  jtc /*
     13  1.1  jtc **=====================================================================
     14  1.1  jtc **             I N C L U D E   F I L E   S E C T I O N                *
     15  1.1  jtc **                                                                    *
     16  1.1  jtc ** If your port requires different include files, add a suitable      *
     17  1.1  jtc ** #define in the customization section, and make the inclusion or    *
     18  1.1  jtc ** exclusion of the files conditional on this.                        *
     19  1.1  jtc **=====================================================================
     20  1.1  jtc */
     21  1.1  jtc #include "pcnfsd.h"
     22  1.1  jtc 
     23  1.1  jtc #include <stdio.h>
     24  1.1  jtc #include <pwd.h>
     25  1.1  jtc #include <sys/file.h>
     26  1.1  jtc #include <signal.h>
     27  1.1  jtc #include <sys/stat.h>
     28  1.1  jtc #include <sys/ioctl.h>
     29  1.1  jtc #include <netdb.h>
     30  1.1  jtc #include <string.h>
     31  1.1  jtc 
     32  1.1  jtc #ifndef SYSV
     33  1.1  jtc #include <sys/wait.h>
     34  1.1  jtc #endif
     35  1.1  jtc 
     36  1.1  jtc #ifdef ISC_2_0
     37  1.1  jtc #include <sys/fcntl.h>
     38  1.1  jtc #endif
     39  1.1  jtc 
     40  1.1  jtc #ifdef SHADOW_SUPPORT
     41  1.1  jtc #include <shadow.h>
     42  1.1  jtc #endif
     43  1.1  jtc 
     44  1.1  jtc /*
     45  1.1  jtc **---------------------------------------------------------------------
     46  1.1  jtc ** Other #define's
     47  1.1  jtc **---------------------------------------------------------------------
     48  1.1  jtc */
     49  1.1  jtc 
     50  1.1  jtc extern void     scramble();
     51  1.1  jtc extern char    *crypt();
     52  1.1  jtc 
     53  1.1  jtc #ifdef WTMP
     54  1.1  jtc extern void wlogin();
     55  1.1  jtc #endif
     56  1.1  jtc 
     57  1.1  jtc extern struct passwd  *get_password();
     58  1.1  jtc 
     59  1.1  jtc /*
     60  1.1  jtc **---------------------------------------------------------------------
     61  1.1  jtc **                       Misc. variable definitions
     62  1.1  jtc **---------------------------------------------------------------------
     63  1.1  jtc */
     64  1.1  jtc 
     65  1.1  jtc int             buggit = 0;
     66  1.1  jtc 
     67  1.1  jtc /*
     68  1.1  jtc **=====================================================================
     69  1.1  jtc **                      C O D E   S E C T I O N                       *
     70  1.1  jtc **=====================================================================
     71  1.1  jtc */
     72  1.1  jtc 
     73  1.1  jtc 
     74  1.1  jtc /*ARGSUSED*/
     75  1.1  jtc void *pcnfsd_null_1_svc(arg, req)
     76  1.1  jtc void *arg;
     77  1.1  jtc struct svc_req *req;
     78  1.1  jtc {
     79  1.1  jtc static char dummy;
     80  1.1  jtc return((void *)&dummy);
     81  1.1  jtc }
     82  1.1  jtc 
     83  1.1  jtc auth_results *pcnfsd_auth_1_svc(arg, req)
     84  1.1  jtc auth_args *arg;
     85  1.1  jtc struct svc_req *req;
     86  1.1  jtc {
     87  1.1  jtc static auth_results r;
     88  1.1  jtc 
     89  1.1  jtc char            uname[32];
     90  1.1  jtc char            pw[64];
     91  1.1  jtc int             c1, c2;
     92  1.1  jtc struct passwd  *p;
     93  1.1  jtc 
     94  1.1  jtc 
     95  1.1  jtc 	r.stat = AUTH_RES_FAIL;	/* assume failure */
     96  1.1  jtc 	r.uid = (int)-2;
     97  1.1  jtc 	r.gid = (int)-2;
     98  1.1  jtc 
     99  1.1  jtc 	scramble(arg->id, uname);
    100  1.1  jtc 	scramble(arg->pw, pw);
    101  1.1  jtc 
    102  1.1  jtc #ifdef USER_CACHE
    103  1.1  jtc 	if(check_cache(uname, pw, &r.uid, &r.gid)) {
    104  1.1  jtc 		 r.stat = AUTH_RES_OK;
    105  1.1  jtc #ifdef WTMP
    106  1.1  jtc 		wlogin(uname, req);
    107  1.1  jtc #endif
    108  1.1  jtc 		 return (&r);
    109  1.1  jtc    }
    110  1.1  jtc #endif
    111  1.1  jtc 
    112  1.1  jtc 	p = get_password(uname);
    113  1.1  jtc 	if (p == (struct passwd *)NULL)
    114  1.1  jtc 	   return (&r);
    115  1.1  jtc 
    116  1.1  jtc 	c1 = strlen(pw);
    117  1.1  jtc 	c2 = strlen(p->pw_passwd);
    118  1.1  jtc 	if ((c1 && !c2) || (c2 && !c1) ||
    119  1.1  jtc 	   (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd))))
    120  1.1  jtc            {
    121  1.1  jtc 	   return (&r);
    122  1.1  jtc 	   }
    123  1.1  jtc 	r.stat = AUTH_RES_OK;
    124  1.1  jtc 	r.uid = p->pw_uid;
    125  1.1  jtc 	r.gid = p->pw_gid;
    126  1.1  jtc #ifdef WTMP
    127  1.1  jtc 		wlogin(uname, req);
    128  1.1  jtc #endif
    129  1.1  jtc 
    130  1.1  jtc #ifdef USER_CACHE
    131  1.1  jtc 	add_cache_entry(p);
    132  1.1  jtc #endif
    133  1.1  jtc 
    134  1.1  jtc return(&r);
    135  1.1  jtc }
    136  1.1  jtc 
    137  1.1  jtc pr_init_results *pcnfsd_pr_init_1_svc(pi_arg, req)
    138  1.1  jtc pr_init_args *pi_arg;
    139  1.1  jtc struct svc_req *req;
    140  1.1  jtc {
    141  1.1  jtc static pr_init_results pi_res;
    142  1.1  jtc 
    143  1.1  jtc 	pi_res.stat =
    144  1.1  jtc 	  (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
    145  1.1  jtc 
    146  1.1  jtc return(&pi_res);
    147  1.1  jtc }
    148  1.1  jtc 
    149  1.1  jtc pr_start_results *pcnfsd_pr_start_1_svc(ps_arg, req)
    150  1.1  jtc pr_start_args *ps_arg;
    151  1.1  jtc struct svc_req *req;
    152  1.1  jtc {
    153  1.1  jtc static pr_start_results ps_res;
    154  1.1  jtc char *dummyptr;
    155  1.1  jtc 
    156  1.1  jtc 	ps_res.stat =
    157  1.1  jtc 	  (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
    158  1.1  jtc 	  ps_arg ->file, ps_arg->opts, &dummyptr);
    159  1.1  jtc 
    160  1.1  jtc return(&ps_res);
    161  1.1  jtc }
    162  1.1  jtc 
    163