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