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