3 static void pcinit(int, char**);
4 static int pcnull(int, Rpccall*, Rpccall*);
5 static int pcinfo(int, Rpccall*, Rpccall*);
6 static int pcauth(int, Rpccall*, Rpccall*);
7 static int pc1auth(int, Rpccall*, Rpccall*);
8 static int pcfacilities[15];
9 static char no_comment[] = "Trust me.";
10 static char pc_vers[] = "@(#)pcnfsd_v2.c 1.6 - rpc.pcnfsd V2.0 (c) 1994 P9, GmbH";
11 static char pc_home[] = "merrimack:/";
13 static Procmap pcproc[] = { /* pcnfsd v2 */
20 static Procmap pc1proc[] = { /* pc-nfsd v1 */
29 150001, 2, pcinit, pcproc,
30 150001, 1, 0, pc1proc,
35 main(int argc, char *argv[])
37 server(argc, argv, myport, progmap);
41 pcinit(int argc, char **argv)
45 char *config = "config";
52 if(argopt(ARGC()) < 0)
53 sysfatal("usage: %s %s [-c config]", argv0, commonopts);
58 for(i=0; i<nelem(pcfacilities); i++)
60 for(p=pcproc; p->procp; p++)
61 pcfacilities[p->procno] = 100;
62 readunixidmaps(config);
66 pcnull(int n, Rpccall *cmd, Rpccall *reply)
78 x->s[i] = (x->s[i] ^ 0x5b) & 0x7f;
82 pcinfo(int n, Rpccall *cmd, Rpccall *reply)
84 uchar *argptr = cmd->args;
85 uchar *dataptr = reply->results;
89 chat("host=%I, port=%ld: pcinfo...",
90 cmd->host, cmd->port);
92 return garbage(reply, "count too small");
93 argptr += string2S(argptr, &vers);
94 argptr += string2S(argptr, &cm);
95 if(argptr != &((uchar *)cmd->args)[n])
96 return garbage(reply, "bad count");
97 chat("\"%.*s\",\"%.*s\"\n", utfnlen(vers.s, vers.n), vers.s, utfnlen(cm.s, cm.n), cm.s);
98 PLONG(sizeof(pc_vers)-1);
99 PPTR(pc_vers, sizeof(pc_vers)-1);
100 PLONG(sizeof(no_comment)-1);
101 PPTR(no_comment, sizeof(no_comment)-1);
102 PLONG(nelem(pcfacilities));
103 for(i=0; i<nelem(pcfacilities); i++)
104 PLONG(pcfacilities[i]);
105 return dataptr - (uchar *)reply->results;
109 pc1auth(int n, Rpccall *cmd, Rpccall *reply)
111 uchar *argptr = cmd->args;
112 uchar *dataptr = reply->results;
117 chat("host=%I, port=%ld: pcauth...",
118 cmd->host, cmd->port);
120 return garbage(reply, "count too small");
121 argptr += string2S(argptr, &id);
122 argptr += string2S(argptr, &pw);
123 if(argptr != &((uchar*)cmd->args)[n])
124 return garbage(reply, "bad count");
127 m = pair2idmap("pcnfsd", cmd->host);
130 uid = name2id(&m->u.ids, id.s);
133 chat("\"%.*s\",\"%.*s\" uid=%d\n", utfnlen(id.s, id.n), id.s, utfnlen(pw.s, pw.n), pw.s, uid);
134 PLONG(0); /* status */
135 PLONG(uid); /* uid */
136 PLONG(uid); /* gid */
137 return dataptr - (uchar*)reply->results;
141 pcauth(int n, Rpccall *cmd, Rpccall *reply)
143 uchar *argptr = cmd->args;
144 uchar *dataptr = reply->results;
145 String sys, id, pw, cm;
149 chat("host=%I, port=%ld: pcauth...",
150 cmd->host, cmd->port);
152 return garbage(reply, "count too small");
153 argptr += string2S(argptr, &sys);
154 argptr += string2S(argptr, &id);
155 argptr += string2S(argptr, &pw);
156 argptr += string2S(argptr, &cm);
157 if(argptr != &((uchar *)cmd->args)[n])
158 return garbage(reply, "bad count");
162 m = pair2idmap("pcnfsd", cmd->host);
165 uid = name2id(&m->u.ids, id.s);
168 chat("\"%.*s\",\"%.*s\",\"%.*s\",\"%.*s\"\n", utfnlen(sys.s, sys.n), sys.s,
169 utfnlen(id.s, id.n), id.s, utfnlen(pw.s, pw.n), pw.s, utfnlen(cm.s, cm.n), cm.s);
170 PLONG(0); /* status - OK */
172 PLONG(uid); /* gid */
173 PLONG(0); /* ngids */
174 PLONG(sizeof(pc_home)-1);
175 PPTR(pc_home, sizeof(pc_home)-1);
176 PLONG(0); /* umask */
177 PLONG(sizeof(no_comment)-1);
178 PPTR(no_comment, sizeof(no_comment)-1);
179 return dataptr - (uchar *)reply->results;