1 /* $NetBSD: pcnfsd.x,v 1.7 2018/01/23 21:27:20 sevan Exp $ */
2
3 /* The maximum number of bytes in a user name argument */
4 const IDENTLEN = 32;
5 /* The maximum number of bytes in a password argument */
6 const PASSWORDLEN = 64;
7 /* The maximum number of bytes in a print client name argument */
8 const CLIENTLEN = 64;
9 /* The maximum number of bytes in a printer name argument */
10 const PRINTERNAMELEN = 64;
11 /* The maximum number of bytes in a print user name argument */
12 const USERNAMELEN = 64;
13 /* The maximum number of bytes in a print spool file name argument */
14 const SPOOLNAMELEN = 64;
15 /* The maximum number of bytes in a print options argument */
16 const OPTIONSLEN = 64;
17 /* The maximum number of bytes in a print spool directory path */
18 const SPOOLDIRLEN = 255;
19 /* The maximum number of secondary GIDs returned by a V2 AUTH */
20 const EXTRAGIDLEN = 16;
21 /* The maximum number of bytes in a home directory spec */
22 const HOMEDIRLEN = 255;
23 /* The maximum number of bytes in a misc. comments string */
24 const COMMENTLEN = 255;
25 /* The maximum number of bytes in a print job id */
26 const PRINTJOBIDLEN = 255;
27 /* The maximum number of printers returned by a LIST operation */
28 const PRLISTMAX = 32;
29 /* The maximum number of print jobs returned by a QUEUE operation */
30 const PRQUEUEMAX = 128;
31 /* The maximum number of entries in the facilities list */
32 const FACILITIESMAX = 32;
33 /* The maximum length of an operator message */
34 const MESSAGELEN = 512;
35
36
37
38 typedef string ident<IDENTLEN>;
39 /*
40 ** The type ident is used for passing an encoded user name for
41 ** authentication. The server should decode the string by replacing each
42 ** octet with the value formed by performing an exclusive-or of the octet
43 ** value with the value 0x5b and and'ing the result with 0x7f.
44 */
45
46 typedef string message<MESSAGELEN>;
47 /*
48 ** The type message is used for passing an alert message to the
49 ** system operator on the server. The text may include newlines.
50 */
51
52 typedef string password<PASSWORDLEN>;
53 /*
54 ** The type password is used for passing an encode password for
55 ** authentication. The server should decode the password as described
56 ** above.
57 */
58
59 typedef string client<CLIENTLEN>;
60 /*
61 ** The type client is used for passing the hostname of a client for
62 ** printing. The server may use this name in constructing the spool
63 ** directory name.
64 */
65
66 typedef string printername<PRINTERNAMELEN>;
67 /*
68 ** The type printername is used for passing the name of a printer on which
69 ** the client wishes to print.
70 */
71
72 typedef string username<USERNAMELEN>;
73 /*
74 ** The type username is used for passing the user name for a print job.
75 ** The server may use this in any way it chooses: it may attempt to change
76 ** the effective identity with which it is running to username or may
77 ** simply arrange for the text to be printed on the banner page.
78 */
79
80 typedef string comment<COMMENTLEN>;
81 /*
82 ** The type comment is used to pass an uninterpreted text string which
83 ** may be used by displayed to a human user or used for custom
84 ** extensions to the PCNFSD service. If you elect to extend PCNFSD
85 ** service in this way, please do so in a way which will avoid
86 ** problems if your client attempts to interoperate with a server
87 ** which does not support your extension. One way to do this is to
88 ** use the
89 */
90
91 typedef string spoolname<SPOOLNAMELEN>;
92 /*
93 ** The type spoolname is used for passing the name of a print spool file
94 ** (a simple filename not a pathname) within the spool directory.
95 */
96
97 typedef string printjobid<PRINTJOBIDLEN>;
98 /*
99 ** The type printjobid is used for passing the id of a print job.
100 */
101
102 typedef string homedir<OPTIONSLEN>;
103 /*
104 ** The type homedir is used to return the home directory for the user.
105 ** If present, it should be in the form "hostname:path", where hostname
106 ** and path are in a suitable form for communicating with the mount server.
107 */
108
109 typedef string options<OPTIONSLEN>;
110 /*
111 ** The type options is used for passing implementation-specific print
112 ** control information. The option string is a set of printable ASCII
113 ** characters. The first character should be ignored by the server; it is
114 ** reserved for client use. The second character specifies the type of
115 ** data in the print file. The following types are defined (an
116 ** implementation may define additional values):
117 **
118 ** p - PostScript data. The client will ensure that a valid
119 ** PostScript header is included.
120 ** d - Diablo 630 data.
121 ** x - Generic printable ASCII text. The client will have filtered
122 ** out all non-printable characters other than CR, LF, TAB,
123 ** BS and VT.
124 ** r - Raw print data. The client performs no filtering.
125 ** u - User-defined. Reserved for custom extensions. A vanilla
126 ** pcnfsd server will treat this as equivalent to "r"
127 **
128 ** If diablo data (type 'd') is specified, a formatting specification
129 ** string will be appended. This has the form:
130 ** ppnnnbbb
131 ** pp
132 ** Pitch - 10, 12 or 15.
133 ** nnn
134 ** The ``normal'' font to be used - encoded as follows:
135 ** Courier crn
136 ** Courier-Bold crb
137 ** Courier-Oblique con
138 ** Courier-BoldObliqu cob
139 ** Helvetica hrn
140 ** Helvetica-Bold hrb
141 ** Helvetica-Oblique hon
142 ** Helvetica-BoldOblique hob
143 ** Times-Roman trn
144 ** Times-Bold trb
145 ** Times-Italic ton
146 ** Times-BoldItalic tob
147 ** bbb
148 ** The ``bold'' font to be used - encoded in the same way. For example,
149 ** the string ``nd10hrbcob'' specifies that the print data is in Diablo
150 ** 630 format, it should be printed at 10 pitch, ``normal'' text should be
151 ** printed in Helvetica-Bold, and ``bold'' text should be printed in
152 ** Courier-BoldOblique.
153 */
154
155 enum arstat {
156 AUTH_RES_OK = 0,
157 AUTH_RES_FAKE = 1,
158 AUTH_RES_FAIL = 2
159 };
160 /*
161 ** The type arstat is returned by PCNFSD_AUTH. A value of AUTH_RES_OK
162 ** indicates that the server was able to verify the ident and password
163 ** successfully.AUTH_RES_FAIL is returned if a verification failure
164 ** occurred. The value AUTH_RES_FAKE may be used if the server wishes to
165 ** indicate that the verification failed, but that the server has
166 ** synthesised acceptable values for uid and gid which the client may use
167 ** if it wishes.
168 */
169
170 enum alrstat {
171 ALERT_RES_OK = 0,
172 ALERT_RES_FAIL = 1
173 };
174 /*
175 ** The type alrstat is returned by PCNFSD_ALERT. A value of ALERT_RES_OK
176 ** indicates that the server was able to notify the system operator
177 ** successfully. ALERT_RES_FAIL is returned if a failure occurred
178 */
179 enum pirstat {
180 PI_RES_OK = 0,
181 PI_RES_NO_SUCH_PRINTER = 1,
182 PI_RES_FAIL = 2
183 };
184 /*
185 ** The type pirstat is returned by a number of print operations. PI_RES_OK
186 ** indicates that the operation was performed successfully. PI_RES_FAIL
187 ** indicates that the printer name was valid, but the operation could
188 ** not be performed. PI_RES_NO_SUCH_PRINTER indicates that the printer
189 ** name was not recognised.
190 */
191
192 enum pcrstat {
193 PC_RES_OK = 0,
194 PC_RES_NO_SUCH_PRINTER = 1,
195 PC_RES_NO_SUCH_JOB = 2,
196 PC_RES_NOT_OWNER = 3,
197 PC_RES_FAIL = 4
198 };
199 /*
200 ** The type pcrstat is returned by a CANCEL, REQUEUE, HOLD, or RELEASE
201 ** print operation.
202 ** PC_RES_OK indicates that the operation was performed successfully.
203 ** PC_RES_NO_SUCH_PRINTER indicates that the printer name was not recognised.
204 ** PC_RES_NO_SUCH_JOB means that the job does not exist, or is not
205 ** associated with the specified printer.
206 ** PC_RES_NOT_OWNER means that the user does not have permission to
207 ** manipulate the job.
208 ** PC_RES_FAIL means that the job could not be manipulated for an unknown
209 ** reason.
210 */
211
212
213 enum psrstat {
214 PS_RES_OK = 0,
215 PS_RES_ALREADY = 1,
216 PS_RES_NULL = 2,
217 PS_RES_NO_FILE = 3,
218 PS_RES_FAIL = 4
219 };
220 /*
221 ** The type psrstat is returned by PCNFSD_PR_START. A value of PS_RES_OK
222 ** indicates that the server has started printing the job. It is possible
223 ** that the reply from a PCNFSD_PR_START call may be lost, in which case
224 ** the client will repeat the call. If the spool file is still in
225 ** existence, the server will return PS_RES_ALREADY indicating that it has
226 ** already started printing. If the file cannot be found, PS_RES_NO_FILE
227 ** is returned. PS_RES_NULL indicates that the spool file was empty,
228 ** while PS_RES_FAIL denotes a general failure. PI_RES_FAIL is returned
229 ** if spool directory could not be created. The value
230 ** PI_RES_NO_SUCH_PRINTER indicates that the printer name was not
231 ** recognised.
232 */
233
234 enum mapreq {
235 MAP_REQ_UID = 0,
236 MAP_REQ_GID = 1,
237 MAP_REQ_UNAME = 2,
238 MAP_REQ_GNAME = 3
239 };
240 /*
241 ** The type mapreq identifies the type of a mapping request.
242 ** MAP_REQ_UID requests that the server treat the value in the
243 ** id field as a uid and return the corresponding username in name.
244 ** MAP_REQ_GID requests that the server treat the value in the
245 ** id field as a gid and return the corresponding groupname in name.
246 ** MAP_REQ_UNAME requests that the server treat the value in the
247 ** name field as a username and return the corresponding uid in id.
248 ** MAP_REQ_GNAME requests that the server treat the value in the
249 ** name field as a groupname and return the corresponding gid in id.
250 */
251
252 enum maprstat {
253 MAP_RES_OK = 0,
254 MAP_RES_UNKNOWN = 1,
255 MAP_RES_DENIED = 2
256 };
257 /*
258 ** The type maprstat indicates the success or failure of
259 ** an individual mapping request.
260 */
261
262 /*
263 **********************************************************
264 ** Version 1 of the PCNFSD protocol.
265 **********************************************************
266 */
267 struct auth_args {
268 ident id;
269 password pw;
270 };
271 struct auth_results {
272 arstat stat;
273 unsigned int uid;
274 unsigned int gid;
275 };
276
277 struct pr_init_args {
278 client system;
279 printername pn;
280 };
281 struct pr_init_results {
282 pirstat stat;
283 spoolname dir;
284 };
285
286 struct pr_start_args {
287 client system;
288 printername pn;
289 username user;
290 spoolname file;
291 options opts;
292 };
293 struct pr_start_results {
294 psrstat stat;
295 };
296
297
298 /*
299 **********************************************************
300 ** Version 2 of the PCNFSD protocol.
301 **********************************************************
302 */
303
304 struct v2_info_args {
305 comment vers;
306 comment cm;
307 };
308
309 struct v2_info_results {
310 comment vers;
311 comment cm;
312 int facilities<FACILITIESMAX>;
313 };
314
315 struct v2_pr_init_args {
316 client system;
317 printername pn;
318 comment cm;
319 };
320 struct v2_pr_init_results {
321 pirstat stat;
322 spoolname dir;
323 comment cm;
324 };
325
326 struct v2_pr_start_args {
327 client system;
328 printername pn;
329 username user;
330 spoolname file;
331 options opts;
332 int copies;
333 comment cm;
334 };
335 struct v2_pr_start_results {
336 psrstat stat;
337 printjobid id;
338 comment cm;
339 };
340
341
342
343 typedef struct pr_list_item *pr_list;
344
345 struct pr_list_item {
346 printername pn;
347 printername device;
348 client remhost; /* empty if local */
349 comment cm;
350 pr_list pr_next;
351 };
352
353 struct v2_pr_list_results {
354 comment cm;
355 pr_list printers;
356 };
357
358 struct v2_pr_queue_args {
359 printername pn;
360 client system;
361 username user;
362 bool just_mine;
363 comment cm;
364 };
365
366 typedef struct pr_queue_item *pr_queue;
367
368 struct pr_queue_item {
369 int position;
370 printjobid id;
371 comment size;
372 comment status;
373 client system;
374 username user;
375 spoolname file;
376 comment cm;
377 pr_queue pr_next;
378 };
379
380 struct v2_pr_queue_results {
381 pirstat stat;
382 comment cm;
383 bool just_yours;
384 int qlen;
385 int qshown;
386 pr_queue jobs;
387 };
388
389
390 struct v2_pr_cancel_args {
391 printername pn;
392 client system;
393 username user;
394 printjobid id;
395 comment cm;
396 };
397 struct v2_pr_cancel_results {
398 pcrstat stat;
399 comment cm;
400 };
401
402
403 struct v2_pr_status_args {
404 printername pn;
405 comment cm;
406 };
407 struct v2_pr_status_results {
408 pirstat stat;
409 bool avail;
410 bool printing;
411 int qlen;
412 bool needs_operator;
413 comment status;
414 comment cm;
415 };
416
417 struct v2_pr_admin_args {
418 client system;
419 username user;
420 printername pn;
421 comment cm;
422 };
423 struct v2_pr_admin_results {
424 pirstat stat;
425 comment cm;
426 };
427
428 struct v2_pr_requeue_args {
429 printername pn;
430 client system;
431 username user;
432 printjobid id;
433 int qpos;
434 comment cm;
435 };
436
437 struct v2_pr_requeue_results {
438 pcrstat stat;
439 comment cm;
440 };
441
442 struct v2_pr_hold_args {
443 printername pn;
444 client system;
445 username user;
446 printjobid id;
447 comment cm;
448 };
449 struct v2_pr_hold_results {
450 pcrstat stat;
451 comment cm;
452 };
453
454 struct v2_pr_release_args {
455 printername pn;
456 client system;
457 username user;
458 printjobid id;
459 comment cm;
460 };
461 struct v2_pr_release_results {
462 pcrstat stat;
463 comment cm;
464 };
465
466
467 typedef struct mapreq_arg_item *mapreq_arg;
468
469 struct mapreq_arg_item {
470 mapreq req;
471 int id;
472 username name;
473 mapreq_arg mapreq_next;
474 };
475
476 typedef struct mapreq_res_item *mapreq_res;
477
478 struct mapreq_res_item {
479 mapreq req;
480 maprstat stat;
481 int id;
482 username name;
483 mapreq_res mapreq_next;
484 };
485
486 struct v2_mapid_args {
487 comment cm;
488 mapreq_arg req_list;
489 };
490
491
492 struct v2_mapid_results {
493 comment cm;
494 mapreq_res res_list;
495 };
496
497 struct v2_auth_args {
498 client system;
499 ident id;
500 password pw;
501 comment cm;
502 };
503 struct v2_auth_results {
504 arstat stat;
505 unsigned int uid;
506 unsigned int gid;
507 unsigned int gids<EXTRAGIDLEN>;
508 homedir home;
509 int def_umask;
510 comment cm;
511 };
512
513 struct v2_alert_args {
514 client system;
515 printername pn;
516 username user;
517 message msg;
518 };
519 struct v2_alert_results {
520 alrstat stat;
521 comment cm;
522 };
523
524
525 /*
526 **********************************************************
527 ** Protocol description for the PCNFSD program
528 **********************************************************
529 */
530 /*
531 ** Version 1 of the PCNFSD protocol.
532 **
533 ** -- PCNFSD_NULL() = 0
534 ** Null procedure - standard for all RPC programs.
535 **
536 ** -- PCNFSD_AUTH() = 1
537 ** Perform user authentication - map username, password into uid, gid.
538 **
539 ** -- PCNFSD_PR_INIT() = 2
540 ** Prepare for remote printing: identify exporting spool directory.
541 **
542 ** -- PCNFSD_PR_START() = 3
543 ** Submit a spooled print job for printing: the print data is
544 ** in a file created in the spool directory.
545 **
546 ** Version 2 of the -- PCNFSD protocol.
547 **
548 ** -- PCNFSD2_NULL() = 0
549 ** Null procedure - standard for all RPC programs.
550 **
551 ** -- PCNFSD2_INFO() = 1
552 ** Determine which services are supported by this implementation
553 ** of PCNFSD.
554 **
555 ** -- PCNFSD2_PR_INIT() = 2
556 ** Prepare for remote printing: identify exporting spool directory.
557 **
558 ** -- PCNFSD2_PR_START() = 3
559 ** Submit a spooled print job for printing: the print data is
560 ** in a file created in the spool directory.
561 **
562 ** -- PCNFSD2_PR_LIST() = 4
563 ** List all printers known on the server.
564 **
565 ** -- PCNFSD2_PR_QUEUE() = 5
566 ** List all or part of the queued jobs for a printer.
567 **
568 ** -- PCNFSD2_PR_STATUS() = 6
569 ** Determine the status of a printer.
570 **
571 ** -- PCNFSD2_PR_CANCEL() = 7
572 ** Cancel a print job.
573 **
574 ** -- PCNFSD2_PR_ADMIN() = 8
575 ** Perform an implementation-dependent printer administration
576 ** operation.
577 **
578 ** -- PCNFSD2_PR_REQUEUE() = 9
579 ** Change the queue position of a previously-submitted print job.
580 **
581 ** -- PCNFSD2_PR_HOLD() = 10
582 ** Place a "hold" on a previously-submitted print job. The job
583 ** will remain in the queue, but will not be printed.
584 **
585 ** -- PCNFSD2_PR_RELEASE() = 11
586 ** Release the "hold" on a previously-held print job.
587 **
588 ** -- PCNFSD2_MAPID() = 12
589 ** Perform one or more translations between user and group
590 ** names and IDs.
591 **
592 ** -- PCNFSD2_AUTH() = 13
593 ** Perform user authentication - map username, password into uid, gid;
594 ** may also return secondary gids, home directory, umask.
595 **
596 ** -- PCNFSD2_ALERT() = 14
597 ** Send a message to the system operator.
598 */
599 program PCNFSDPROG {
600 version PCNFSDVERS {
601 void PCNFSD_NULL(void) = 0;
602 auth_results PCNFSD_AUTH(auth_args) = 1;
603 pr_init_results PCNFSD_PR_INIT(pr_init_args) = 2;
604 pr_start_results PCNFSD_PR_START(pr_start_args) = 3;
605 } = 1;
606 /*
607 ** Version 2 of the PCNFSD protocol.
608 */
609 version PCNFSDV2 {
610 void PCNFSD2_NULL(void) = 0;
611 v2_info_results PCNFSD2_INFO(v2_info_args) = 1;
612 v2_pr_init_results PCNFSD2_PR_INIT(v2_pr_init_args) = 2;
613 v2_pr_start_results PCNFSD2_PR_START(v2_pr_start_args) = 3;
614 v2_pr_list_results PCNFSD2_PR_LIST(void) = 4;
615 v2_pr_queue_results PCNFSD2_PR_QUEUE(v2_pr_queue_args) = 5;
616 v2_pr_status_results PCNFSD2_PR_STATUS(v2_pr_status_args) = 6;
617 v2_pr_cancel_results PCNFSD2_PR_CANCEL(v2_pr_cancel_args) = 7;
618 v2_pr_admin_results PCNFSD2_PR_ADMIN(v2_pr_admin_args) = 8;
619 v2_pr_requeue_results PCNFSD2_PR_REQUEUE(v2_pr_requeue_args) = 9;
620 v2_pr_hold_results PCNFSD2_PR_HOLD(v2_pr_hold_args) = 10;
621 v2_pr_release_results PCNFSD2_PR_RELEASE(v2_pr_release_args) = 11;
622 v2_mapid_results PCNFSD2_MAPID(v2_mapid_args) = 12;
623 v2_auth_results PCNFSD2_AUTH(v2_auth_args) = 13;
624 v2_alert_results PCNFSD2_ALERT(v2_alert_args) = 14;
625 } = 2;
626
627 } = 150001;
628
629 /*
630 ** The following forces a publically-visible msg_out()
631 */
632 %#if RPC_SVC
633 % static void _msgout(const char *);
msg_out(msg)634 % void msg_out(msg) const char *msg; {_msgout(msg);}
635 %#endif
636 %#if RPC_HDR
637 % extern void msg_out(const char *);
638 %#endif
639
640 /*
641 ** This allows initialization prior to running the service. (see PR 12758)
642 */
643 %#if RPC_SVC
644 %#define main mymain
645 %#endif
646