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