pcnfsd_v1.c revision 1.1 1 /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v1.c 1.1 91/09/03 12:41:50 SMI */
2 /*
3 **=====================================================================
4 ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
5 ** @(#)pcnfsd_v1.c 1.1 9/3/91
6 **=====================================================================
7 */
8 #include "common.h"
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 #include "pcnfsd.h"
20
21 #include <stdio.h>
22 #include <pwd.h>
23 #include <sys/file.h>
24 #include <signal.h>
25 #include <sys/stat.h>
26 #include <sys/ioctl.h>
27 #include <netdb.h>
28 #include <string.h>
29
30 #ifndef SYSV
31 #include <sys/wait.h>
32 #endif
33
34 #ifdef ISC_2_0
35 #include <sys/fcntl.h>
36 #endif
37
38 #ifdef SHADOW_SUPPORT
39 #include <shadow.h>
40 #endif
41
42 /*
43 **---------------------------------------------------------------------
44 ** Other #define's
45 **---------------------------------------------------------------------
46 */
47
48 extern void scramble();
49 extern char *crypt();
50
51 #ifdef WTMP
52 extern void wlogin();
53 #endif
54
55 extern struct passwd *get_password();
56
57 /*
58 **---------------------------------------------------------------------
59 ** Misc. variable definitions
60 **---------------------------------------------------------------------
61 */
62
63 int buggit = 0;
64
65 /*
66 **=====================================================================
67 ** C O D E S E C T I O N *
68 **=====================================================================
69 */
70
71
72 /*ARGSUSED*/
73 void *pcnfsd_null_1_svc(arg, req)
74 void *arg;
75 struct svc_req *req;
76 {
77 static char dummy;
78 return((void *)&dummy);
79 }
80
81 auth_results *pcnfsd_auth_1_svc(arg, req)
82 auth_args *arg;
83 struct svc_req *req;
84 {
85 static auth_results r;
86
87 char uname[32];
88 char pw[64];
89 int c1, c2;
90 struct passwd *p;
91
92
93 r.stat = AUTH_RES_FAIL; /* assume failure */
94 r.uid = (int)-2;
95 r.gid = (int)-2;
96
97 scramble(arg->id, uname);
98 scramble(arg->pw, pw);
99
100 #ifdef USER_CACHE
101 if(check_cache(uname, pw, &r.uid, &r.gid)) {
102 r.stat = AUTH_RES_OK;
103 #ifdef WTMP
104 wlogin(uname, req);
105 #endif
106 return (&r);
107 }
108 #endif
109
110 p = get_password(uname);
111 if (p == (struct passwd *)NULL)
112 return (&r);
113
114 c1 = strlen(pw);
115 c2 = strlen(p->pw_passwd);
116 if ((c1 && !c2) || (c2 && !c1) ||
117 (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd))))
118 {
119 return (&r);
120 }
121 r.stat = AUTH_RES_OK;
122 r.uid = p->pw_uid;
123 r.gid = p->pw_gid;
124 #ifdef WTMP
125 wlogin(uname, req);
126 #endif
127
128 #ifdef USER_CACHE
129 add_cache_entry(p);
130 #endif
131
132 return(&r);
133 }
134
135 pr_init_results *pcnfsd_pr_init_1_svc(pi_arg, req)
136 pr_init_args *pi_arg;
137 struct svc_req *req;
138 {
139 static pr_init_results pi_res;
140
141 pi_res.stat =
142 (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
143
144 return(&pi_res);
145 }
146
147 pr_start_results *pcnfsd_pr_start_1_svc(ps_arg, req)
148 pr_start_args *ps_arg;
149 struct svc_req *req;
150 {
151 static pr_start_results ps_res;
152 char *dummyptr;
153
154 ps_res.stat =
155 (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
156 ps_arg ->file, ps_arg->opts, &dummyptr);
157
158 return(&ps_res);
159 }
160
161