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