Home | History | Annotate | Line # | Download | only in rpc.pcnfsd
      1 /*	$NetBSD: pcnfsd_v1.c,v 1.5 2018/01/23 21:06:25 sevan 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(void *arg, struct svc_req *req)
     65 {
     66 	static char dummy;
     67 	return ((void *) &dummy);
     68 }
     69 
     70 auth_results *
     71 pcnfsd_auth_1_svc(auth_args *arg, struct svc_req *req)
     72 {
     73 	static auth_results r;
     74 
     75 	char    uname[32];
     76 	char    pw[64];
     77 	int     c1, c2;
     78 	struct passwd *p;
     79 
     80 
     81 	r.stat = AUTH_RES_FAIL;	/* assume failure */
     82 	r.uid = (int) -2;
     83 	r.gid = (int) -2;
     84 
     85 	scramble(arg->id, uname);
     86 	scramble(arg->pw, pw);
     87 
     88 #ifdef USER_CACHE
     89 	if (check_cache(uname, pw, &r.uid, &r.gid)) {
     90 		r.stat = AUTH_RES_OK;
     91 #ifdef WTMP
     92 		wlogin(uname, req);
     93 #endif
     94 		return (&r);
     95 	}
     96 #endif
     97 
     98 	p = get_password(uname);
     99 	if (p == NULL)
    100 		return (&r);
    101 
    102 	c1 = strlen(pw);
    103 	c2 = strlen(p->pw_passwd);
    104 	if ((c1 && !c2) || (c2 && !c1) ||
    105 	    (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
    106 		return (&r);
    107 	}
    108 	r.stat = AUTH_RES_OK;
    109 	r.uid = p->pw_uid;
    110 	r.gid = p->pw_gid;
    111 #ifdef WTMP
    112 	wlogin(uname, req);
    113 #endif
    114 
    115 #ifdef USER_CACHE
    116 	add_cache_entry(p);
    117 #endif
    118 
    119 	return (&r);
    120 }
    121 
    122 pr_init_results *
    123 pcnfsd_pr_init_1_svc(pr_init_args *pi_arg, struct svc_req *req)
    124 {
    125 	static pr_init_results pi_res;
    126 
    127 	pi_res.stat =
    128 	    (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
    129 
    130 	return (&pi_res);
    131 }
    132 
    133 pr_start_results *
    134 pcnfsd_pr_start_1_svc(pr_start_args *ps_arg, struct svc_req *req)
    135 {
    136 	static pr_start_results ps_res;
    137 	char   *dummyptr;
    138 
    139 	ps_res.stat =
    140 	    (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
    141 	    ps_arg->file, ps_arg->opts, &dummyptr);
    142 
    143 	return (&ps_res);
    144 }
    145