pcnfsd_v1.c revision 1.5 1 1.5 sevan /* $NetBSD: pcnfsd_v1.c,v 1.5 2018/01/23 21:06:25 sevan 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.5 sevan pcnfsd_null_1_svc(void *arg, struct svc_req *req)
65 1.1 jtc {
66 1.3 lukem static char dummy;
67 1.3 lukem return ((void *) &dummy);
68 1.1 jtc }
69 1.1 jtc
70 1.3 lukem auth_results *
71 1.5 sevan pcnfsd_auth_1_svc(auth_args *arg, struct svc_req *req)
72 1.1 jtc {
73 1.3 lukem static auth_results r;
74 1.1 jtc
75 1.3 lukem char uname[32];
76 1.3 lukem char pw[64];
77 1.3 lukem int c1, c2;
78 1.3 lukem struct passwd *p;
79 1.1 jtc
80 1.1 jtc
81 1.1 jtc r.stat = AUTH_RES_FAIL; /* assume failure */
82 1.3 lukem r.uid = (int) -2;
83 1.3 lukem r.gid = (int) -2;
84 1.1 jtc
85 1.1 jtc scramble(arg->id, uname);
86 1.1 jtc scramble(arg->pw, pw);
87 1.1 jtc
88 1.1 jtc #ifdef USER_CACHE
89 1.3 lukem if (check_cache(uname, pw, &r.uid, &r.gid)) {
90 1.3 lukem r.stat = AUTH_RES_OK;
91 1.1 jtc #ifdef WTMP
92 1.1 jtc wlogin(uname, req);
93 1.1 jtc #endif
94 1.3 lukem return (&r);
95 1.3 lukem }
96 1.1 jtc #endif
97 1.1 jtc
98 1.1 jtc p = get_password(uname);
99 1.4 plunky if (p == NULL)
100 1.3 lukem return (&r);
101 1.1 jtc
102 1.1 jtc c1 = strlen(pw);
103 1.1 jtc c2 = strlen(p->pw_passwd);
104 1.1 jtc if ((c1 && !c2) || (c2 && !c1) ||
105 1.3 lukem (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
106 1.3 lukem return (&r);
107 1.3 lukem }
108 1.1 jtc r.stat = AUTH_RES_OK;
109 1.1 jtc r.uid = p->pw_uid;
110 1.1 jtc r.gid = p->pw_gid;
111 1.1 jtc #ifdef WTMP
112 1.3 lukem wlogin(uname, req);
113 1.1 jtc #endif
114 1.1 jtc
115 1.1 jtc #ifdef USER_CACHE
116 1.1 jtc add_cache_entry(p);
117 1.1 jtc #endif
118 1.1 jtc
119 1.3 lukem return (&r);
120 1.1 jtc }
121 1.1 jtc
122 1.3 lukem pr_init_results *
123 1.5 sevan pcnfsd_pr_init_1_svc(pr_init_args *pi_arg, struct svc_req *req)
124 1.1 jtc {
125 1.3 lukem static pr_init_results pi_res;
126 1.1 jtc
127 1.1 jtc pi_res.stat =
128 1.3 lukem (pirstat) pr_init(pi_arg->system, pi_arg->pn, &pi_res.dir);
129 1.1 jtc
130 1.3 lukem return (&pi_res);
131 1.1 jtc }
132 1.1 jtc
133 1.3 lukem pr_start_results *
134 1.5 sevan pcnfsd_pr_start_1_svc(pr_start_args *ps_arg, struct svc_req *req)
135 1.1 jtc {
136 1.3 lukem static pr_start_results ps_res;
137 1.3 lukem char *dummyptr;
138 1.1 jtc
139 1.1 jtc ps_res.stat =
140 1.3 lukem (psrstat) pr_start2(ps_arg->system, ps_arg->pn, ps_arg->user,
141 1.3 lukem ps_arg->file, ps_arg->opts, &dummyptr);
142 1.1 jtc
143 1.3 lukem return (&ps_res);
144 1.1 jtc }
145