Home | History | Annotate | Line # | Download | only in rpc.pcnfsd
pcnfsd_v1.c revision 1.2.4.1
      1  1.2.4.1  veego /*	$NetBSD: pcnfsd_v1.c,v 1.2.4.1 1997/11/09 21:52:24 veego 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.1    jtc #include <sys/ioctl.h>
     22  1.2.4.1  veego #include <sys/stat.h>
     23  1.2.4.1  veego 
     24      1.1    jtc #include <netdb.h>
     25  1.2.4.1  veego #include <pwd.h>
     26  1.2.4.1  veego #include <signal.h>
     27  1.2.4.1  veego #include <stdio.h>
     28      1.1    jtc #include <string.h>
     29  1.2.4.1  veego #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.2.4.1  veego #include "common.h"
     44  1.2.4.1  veego #include "pcnfsd.h"
     45  1.2.4.1  veego #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.2.4.1  veego 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.2.4.1  veego void   *
     64  1.2.4.1  veego pcnfsd_null_1_svc(arg, req)
     65  1.2.4.1  veego 	void   *arg;
     66  1.2.4.1  veego 	struct svc_req *req;
     67      1.1    jtc {
     68  1.2.4.1  veego 	static char dummy;
     69  1.2.4.1  veego 	return ((void *) &dummy);
     70      1.1    jtc }
     71      1.1    jtc 
     72  1.2.4.1  veego auth_results *
     73  1.2.4.1  veego pcnfsd_auth_1_svc(arg, req)
     74  1.2.4.1  veego 	auth_args *arg;
     75  1.2.4.1  veego 	struct svc_req *req;
     76      1.1    jtc {
     77  1.2.4.1  veego 	static auth_results r;
     78      1.1    jtc 
     79  1.2.4.1  veego 	char    uname[32];
     80  1.2.4.1  veego 	char    pw[64];
     81  1.2.4.1  veego 	int     c1, c2;
     82  1.2.4.1  veego 	struct passwd *p;
     83      1.1    jtc 
     84      1.1    jtc 
     85      1.1    jtc 	r.stat = AUTH_RES_FAIL;	/* assume failure */
     86  1.2.4.1  veego 	r.uid = (int) -2;
     87  1.2.4.1  veego 	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.2.4.1  veego 	if (check_cache(uname, pw, &r.uid, &r.gid)) {
     94  1.2.4.1  veego 		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.2.4.1  veego 		return (&r);
     99  1.2.4.1  veego 	}
    100      1.1    jtc #endif
    101      1.1    jtc 
    102      1.1    jtc 	p = get_password(uname);
    103  1.2.4.1  veego 	if (p == (struct passwd *) NULL)
    104  1.2.4.1  veego 		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.2.4.1  veego 	    (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
    110  1.2.4.1  veego 		return (&r);
    111  1.2.4.1  veego 	}
    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.2.4.1  veego 	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.2.4.1  veego 	return (&r);
    124      1.1    jtc }
    125      1.1    jtc 
    126  1.2.4.1  veego pr_init_results *
    127  1.2.4.1  veego pcnfsd_pr_init_1_svc(pi_arg, req)
    128  1.2.4.1  veego 	pr_init_args *pi_arg;
    129  1.2.4.1  veego 	struct svc_req *req;
    130      1.1    jtc {
    131  1.2.4.1  veego 	static pr_init_results pi_res;
    132      1.1    jtc 
    133      1.1    jtc 	pi_res.stat =
    134  1.2.4.1  veego 	    (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
    135      1.1    jtc 
    136  1.2.4.1  veego 	return (&pi_res);
    137      1.1    jtc }
    138      1.1    jtc 
    139  1.2.4.1  veego pr_start_results *
    140  1.2.4.1  veego pcnfsd_pr_start_1_svc(ps_arg, req)
    141  1.2.4.1  veego 	pr_start_args *ps_arg;
    142  1.2.4.1  veego 	struct svc_req *req;
    143      1.1    jtc {
    144  1.2.4.1  veego 	static pr_start_results ps_res;
    145  1.2.4.1  veego 	char   *dummyptr;
    146      1.1    jtc 
    147      1.1    jtc 	ps_res.stat =
    148  1.2.4.1  veego 	    (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
    149  1.2.4.1  veego 	    ps_arg->file, ps_arg->opts, &dummyptr);
    150      1.1    jtc 
    151  1.2.4.1  veego 	return (&ps_res);
    152      1.1    jtc }
    153