chiark / gitweb /
f7c2321e3bb65223a6596c969151f5164dfcbed3
[userv.git] / spec.sgml
1 <!doctype debiandoc system>
2 <book>
3 <title>User service daemon and client specification
4 <author>Ian Jackson <email>ian@chiark.greenend.org.uk
5 <version>draft 0.17
6
7 <abstract>
8 This is a specification for a Unix system facility to allow one
9 program to invoke another when only limited trust exists
10 between them.
11
12 <copyright>
13 Copyright 1996-1997 Ian Jackson.
14 <p>
15
16 <prgn/userv/ is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or (at
19 your option) any later version.
20 <p>
21
22 This program is distributed in the hope that it will be useful, but
23 <em/without any warranty/; without even the implied warranty of
24 <em/merchantability/ or <em/fitness for a particular purpose/.  See
25 the GNU General Public License for more details.
26 <p>
27
28 You should have received a copy of the GNU General Public License
29 along with <prgn/userv/; if not, write to the Free Software
30 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31
32 <toc sect>
33
34 <chapt id="intro">Introduction
35 <p>
36 There is a daemon which invokes user service programs (henceforth
37 `services') in response to requests by callers of a companion client
38 program (henceforth the `client') and according to rules set forth in
39 system-wide and user-specific configuration files.  The companion
40 client program is setuid root, and negotiates with the daemon through
41 an <prgn/AF_UNIX/ socket and associated objects in a system-wide
42 private directory set aside for the purpose.  The user who wishes the
43 service to be performed and calls the client is called the `calling
44 user'; the process which calls the client is called the `calling
45 process'.
46
47 <p>
48 The daemon and the client are responsible for ensuring that
49 information is safely carried across the security boundary between the
50 two users, and that the processes on either side cannot interact with
51 each other in any unexpected ways.
52
53 <chapt id="client">Client program usage
54
55 <p>
56 <example>
57 userv <var/options/ [--] <var/service-user/ <var/service-name/ [<var/argument/ ...]
58 userv <var/options/ -B|--builtin [--] <var/builtin-service/ [<var/info-argument/ ...]
59 </example>
60 <p>
61
62 <var/service-user/ specifies which user is to provide the service.
63 The user may be a login name or a numeric uid, or <tt/-/ to indicate
64 that the service user is to be the same as the calling user.
65 <p>
66
67 The service name is interpreted by the userv<footnote><prgn/userv/ is
68 short for `user services', and is pronounced `you-serve'.</footnote>
69 daemon on behalf of the service user.  It will often be the name of a
70 program.
71
72 <sect>Options
73 <p>
74
75 Single-letter options may be combined as is usual with Unix programs,
76 and the value for such an option may appear in the same argument or in
77 the next.
78
79 <taglist>
80 <tag/<tt/-B//
81 <tag/<tt/--builtin//
82 <item>
83 Requests that a builtin service be provided.  This is equivalent to
84 using the <prgn/--override/ option to specify a string consisting of
85 <prgn/execute-builtin/ followed by the <var/builtin-service/
86 requested, and requesting a service user of <tt/-/ (indicating the
87 calling user).
88 <p>
89
90 If the builtin service being requested requires a
91 <var/service-argument/ then this must be supplied to the client in the
92 same argument as the <var/builtin-service/.  See <ref
93 id="dirs-execution"> for details of the builtin services available,
94 and <ref id="optoverride"> for details of the <prgn/--override/
95 options.
96 <p>
97
98 The actual service name passed will be the <var/builtin-service/; note
99 that this actual service name (as opposed to the override data) and
100 the <var/info-argument/s supplied will be ignored by most builtin
101 services; the override mechanism and <prgn/execute-builtin/ will be
102 used to ensure that the right builtin service is called with the right
103 <var/service-argument/s.
104
105 <tag/<tt/-f<var/fd/[<var/modifiers/]=<var/filename///
106 <tag/<tt/--file <var/fd/[<var/modifiers/]=<var/filename///
107 <item>
108 Requests that data be copied in and out of the service using pipes.
109 For each file or descriptor this will be done by creating a pipe, one
110 end of which is passed to the service program and the other end of
111 which is passed to a copy of <prgn/cat/ invoked by the client; the
112 other file descriptor passed to <prgn/cat/ will be one inherited by
113 the client program from the caller or one opened by the client program
114 on behalf of the caller.
115 <p>
116
117 The descriptor in the service program that should be connected must be
118 specified as <var/fd/, either as a decimal number or as one of the
119 strings <tt/stdin/, <tt/stdout/ or <tt/stderr/.  The next argument is
120 a filename which will be opened by the client with the privileges of
121 the calling user.
122
123 <p>
124 <var/modifiers/ is used to specify whether the file or descriptor is
125 to be read from or written to.  It consists of a series of words
126 separated by commas.  A comma may separate the <var/modifiers/ from
127 the <var/fd/ and is required if <var/fd/ is not numeric.
128
129 <p>
130 The modifier words are:
131 <taglist compact>
132 <tag/<tt/read//
133 <item>
134 <tt/O_RDONLY/: Allow reading and not writing.  May not be used with
135 <tt/write/ or things that imply it.
136
137 <tag/<tt/write//
138 <item>
139 <tt/O_WRONLY/: Allow writing and not reading.  <em/Doesn't truncate or
140 create/ without <tt/truncate/ or <tt/create/.  <tt/write/ or things
141 that imply it may not be used with <tt/read/.
142
143 <tag/<tt/overwrite//
144 <item>
145 Equivalent to <tt/write,create,truncate/.
146
147 <tag/<tt/create//
148 <tag/<tt/creat//
149 <item>
150 <tt/O_CREAT/: Creates the file if necessary.  Implies <tt/write/.
151
152 <tag/<tt/exclusive//
153 <tag/<tt/excl//
154 <item>
155 <tt/O_EXCL/: Fails if the file already exists.  Implies <tt/write/ and
156 <tt/create/.  May not be used with <tt/truncate/.
157
158 <tag/<tt/truncate//
159 <tag/<tt/trunc//
160 <item>
161 <tt/O_TRUNC/: Truncate any existing file.  Implies <tt/write/.
162 May not be used with <tt/exclusive/.
163
164 <tag/<tt/append//
165 <item>
166 <tt/O_APPEND/: All writes will append to the file.  Implies <tt/write/
167 (but not <tt/create/).
168
169 <tag/<tt/sync//
170 <item>
171 <tt/O_SYNC/: Do writes synchronously.  Implies <tt/write/.
172
173 <tag/<tt/wait//
174 <tag/<tt/nowait//
175 <tag/<tt/close//
176 <item>
177
178 These modifiers control the behaviour of the client, with respect to
179 the pipes carrying data to and from the service, when the service
180 terminates.  See below.
181
182 <tag/<tt/fd//
183 <item>
184 The <var/filename/ is not a filename but a numeric file descriptor.
185 One or both of <tt/read/ and <tt/write/ must be specified, and no
186 other words are allowed.  The <var/filename/ may also be <tt/stdin/,
187 <tt/stdout/ or <tt/stderr/ for file descriptor 0, 1 or 2 respectively.
188
189 </taglist>
190 <p>
191
192 If no <var/modifiers/ which imply <tt/read/ or <tt/write/ are used it
193 is as if <tt/read/ had been specified, except that if the
194 filedescriptor 1 or 2 of the service is being opened (either specified
195 numerically or with <tt/stdout/ or <tt/stderr/) it is as if
196 <tt/overwrite/ had been specified (or <tt/write/ if only <tt/fd/ was
197 specified).
198 <p>
199
200 The client will also use <tt/O_NOCTTY/ when opening files specified by
201 the caller, to avoid changing its controlling terminal.
202 <p>
203
204 By default stdin, stdout and stderr of the service will be connected
205 to the corresponding descriptors on the client.  Diagnostics from
206 the client and daemon will also appear on stderr.
207 <p>
208
209 If <tt/wait/ is specified, the client will wait for the pipe to be
210 closed, and only exit after this has happened.  This means that either
211 the receiving end of the pipe connection was closed while data was
212 still available at the sending end, or that the end of file was
213 reached on the reading file descriptor.  Errors encountered reading or
214 writing in the client at this stage will be considered a system error
215 and cause the client to exit with status 255, but will not cause
216 disconnection at the service side since the service has already
217 exited.
218 <p>
219
220 If <tt/close/ is specified the client will immediately close the pipe
221 connection by killing the relevant copy of <prgn/cat/.  If the service
222 uses the descriptor it will get <prgn/SIGPIPE/ (or <prgn/EPIPE/) for a
223 writing descriptor or end of file for a reading one; the descriptor
224 opened by or passed to the client will also be closed.
225 <p>
226
227 If <tt/nowait/ is specified then the client will not wait and the
228 connection will remain open after the client terminates.  Data may
229 continue to be passed between the inheritors of the relevant
230 descriptor on the service side and the corresponding file or
231 descriptor on the client side until either side closes their
232 descriptor.  This should not usually be specified for stderr (or
233 stdout if <tt/--signals stdout/ is used) since diagnostics from
234 the service side may arrive after the client has exited and be
235 confused with expected output.
236 <p>
237
238 The default is <tt/wait/ for writing file descriptors and <tt/close/
239 for reading ones.
240
241 <tag/<tt/-w<var/fd/=<var/action///
242 <tag/<tt/--fdwait<var/fd/=<var/action///
243 <item>
244 Sets the action on termination of the service for the specified file
245 descriptor; <var/action/ must be <tt/wait/, <tt/nowait/ or <tt/close/
246 as described above.  The file descriptor must be specified as open
247 when this option is encountered; this option is overridden by any
248 later <prgn/--file/ or <prgn/--fdwait/ option - even by a
249 <prgn/--file/ which does not specify an action on termination (in this
250 case the default will be used, as described above).
251
252 <tag/<tt/-D<var/name/=<var/value///
253 <tag/<tt/--defvar <var/name/=<var/value///
254 <item>
255 Set a user-defined variable <var/name/ to <var/value/.  These
256 user-defined variables are made available in the configuration
257 language as the parameters <tt/u-<var/name// and are passed to the
258 service in environment variables <tt/USERV_U_<var/name//.  <var/name/
259 may contain only alphanumerics and underscores, and must start with a
260 letter.  If several definitions are given for the same <var/name/ then
261 only the last is effective.
262
263 <tag/<tt/-t <var/seconds///
264 <tag/<tt/--timeout <var/seconds///
265 <item>
266 Time out the service if it takes longer than <var/seconds/ seconds (a
267 positive integer, in decimal).  Timeout will produce a diagnostic on
268 stderr and an exit status of 255.  If <var/seconds/ is zero then no
269 timeout will be implemented (this is the default).
270
271 <tag/<tt/-S/ <var/method//
272 <tag/<tt/--signals/ <var/method//
273 <item>
274 Affects the handling of the exit status when the service terminates
275 due to a signal.  (The client will always finish by calling
276 <prgn/_exit/, so that only numbers from 0 to 255 can be returned and
277 not the full range of numbers and signal indications which can be
278 returned by the <prgn/wait/ family of system calls.)
279 <p>
280
281 The <var/method/ may be one of the following:
282 <taglist compact>
283 <tag/<var/status/
284 <item>
285 The client's exit status will be <var/status/.  This will not be
286 distinguishable from the service really having exited with code
287 <var/status/.  This method is the default, with a <var/status/ of 254.
288
289 <tag/<tt/number//
290 <tag/<tt/number-nocore//
291 <item>
292 The client's exit status will be the number of the signal which caused
293 the termination of the service.  If <tt/number/ is used rather than
294 <tt/number-nocore/ then 128 will be added if the service dumped core.
295 <tt/number/ is very like the exit code mangling done by the Bourne
296 shell.
297
298 <tag/<tt/highbit//
299 <item>The client's exit status will be the number of the signal with
300 128 added.  If the service exits normally with an exit code of greater
301 than 127 then 127 will be returned.
302
303 <tag/<tt/stdout//
304 <item>
305 The service's numeric wait status as two decimal numbers (high byte
306 first) and a textual description of its meaning will be printed to the
307 client's standard output.  It will be preceded by a newline and
308 followed by an extra newline, and the numbers are separated from each
309 other and from the textual description by single spaces.  The exit
310 status of the client will be zero, unless a system error occurs in
311 which case no exit status and description will be printed to stdout,
312 and an error message will be printed to stderr as usual.
313 </taglist>
314
315 <p>
316 Problems such as client usage errors, the service not being found or
317 permission being denied or failure of a system call are system errors.
318 An error message describing the problem will be printed on the
319 client's stderr, and the client's exit status will be 255.  If the
320 client dies due to a signal this should be treated as a serious system
321 error.
322
323 <tag/<tt/-H//
324 <tag/<tt/--hidecwd//
325 <item>
326 Prevents the calling process's current directory name from being
327 passed to the service; the null string will be passed instead.
328
329 <tag/<tt/-P//
330 <tag/<tt/--sigpipe//
331 <item>
332 If the service program is terminated due to a <prgn/SIGPIPE/ the exit
333 status of the client will be zero, even if it would have been
334 something else according to the exit status method specified.  This
335 option has no effect on the code and description printed if the exit
336 status method <tt/stdout/ is in use.
337
338 <tag/<tt/-h//
339 <tag/<tt/--help//
340 <tag/<tt/--copyright//
341 <item>
342 <tt/-h/ or <tt/--help/ prints the client's usage message;
343 <tt/--copyright/ prints the copyright and lack of warranty notice.
344
345 </taglist>
346
347 <sect id="optoverride">Security-overriding options
348 <p>
349
350 There are also some options which are available for debugging and to
351 allow the system administrator to override a user's policy.  These
352 options are available only if the client is called by root or if the
353 calling user is the same as the service user.
354
355 <taglist>
356
357 <tag/<tt/--override <var/configuration-data///
358 <tag/<tt/--override-file <var/filename///
359 <item>
360 Do not read the usual configuration files.  Instead, the client sends
361 <var/configuration-data/ (followed by a newline) or the contents of
362 <var/filename/ (which is opened in the context of the client) to the
363 daemon and the daemon uses that data instead.  The
364 <var/configuration-data/ must all be in one argument.  It will have a
365 single newline appended so that a single directive can easily be
366 given, but if more than one directive is required it will have to
367 contain one or more real newlines.
368
369 <tag/<tt/--spoof-user <var/user///
370 <item>
371 Pretend to the service that it is being called by <var/user/ (which
372 may be a username or a uid).  This will also affect the group and
373 supplementary groups supplied to the service; they will be the
374 standard group and supplementary groups for <var/user/.
375
376 </taglist>
377
378
379 <chapt id="envir">Execution environment of the service program
380 <p>
381
382 The daemon which is handling the service user side of things will read
383 configuration files to decide what to do.  If it decides to allow the
384 service to be provided it will fork a subprocess to execute the
385 service.
386 <p>
387
388 The service will have no controlling terminal, but it will be a
389 process group leader.
390 <p>
391
392 If the client is killed or times out or a file or descriptor being
393 read or written by the client process gets an error then the service
394 will be disconnected from the client.  The client will return an exit
395 status of 255 and some the service's pipes may be closed at the other
396 end.  The service will become a child of <prgn/init/.  The service may
397 well not notice the disconnection, though writing to a pipe after this
398 may produce a <prgn/SIGPIPE/ and the facility exists to have a
399 <prgn/SIGHUP/ sent to the service on disconnection.
400
401 <sect>File descriptors
402 <p>
403
404 The service program's standard filedescriptors, and possibly other
405 file descriptors, will be connected to pipes or to
406 <prgn>/dev/null</>.  The <prgn/userv/ client/daemon pair will arrange
407 that data is copied between the files or file descriptors specified to
408 to the client by the caller and these these pipes.
409 <p>
410
411 Pipes which may be written to will be closed if a write error occurs
412 on the corresponding client-side file or descriptor, which may result
413 in a <prgn/SIGPIPE/ in the service program; pipes open for reading
414 will get <prgn/EOF/ if the client-side file descriptor gets <prgn/EOF/
415 or an error.
416 <p>
417
418 If the service closes one of its reading file descriptors the writing
419 end of the corresponding pipe will generate a <prgn/SIGPIPE/ when
420 attempts are made by the client/daemon pair to write to it.  This will
421 not be considered an error; rather, the relevant pipe will be
422 discarded and the corresponding file or file descriptor held by the
423 client will be closed.
424 <p>
425
426 Likewise, if one of the file descriptors held by the client for
427 writing by the service is a pipe whose other end is closed by the
428 caller then the client/daemon pair will see an error when trying to
429 copy data provided by the service.  This too will not be considered an
430 error; rather, the pipe correspondong to that descriptor will be
431 closed and any further writes will cause the service to get a
432 <prgn/SIGPIPE/.
433 <p>
434
435 Note that not all write errors or broken pipes on file descriptors may
436 be visible to the service, since buffered data may be discarded by the
437 operating system and there will be a finite interval between the error
438 happening and the service being disconnected from the client or the
439 next write causing a <prgn/SIGPIPE/.
440 <p>
441
442 Read errors on file descriptors (and disconnection) will only be
443 visible to the service and distinguishable from normal end of file if
444 <prgn/disconnect-hup/ is in effect.
445 <p>
446
447 Read and write errors (other than broken pipes, as described above)
448 will always be visible to the caller; they are system errors, and will
449 therefore cause the client to print an error message to stderr and
450 return with an exit status of 255.
451 <p>
452
453 If the main service program process exits while it still has running
454 children any file descriptors held by those children can remain open,
455 depending on the use of <tt/wait/, <tt/nowait/ or <tt/close/ for the
456 relevant file descriptor in the client's arguments.  By default
457 writing filedescriptors remain open and the client will wait for them
458 to be closed at the service end, and reading file descriptors are
459 closed immediately.  These leftover child processes will not get a any
460 <prgn/SIGHUP/ even if a read or write error occurs or the client
461 disconnects before then.
462
463 <sect>Environment
464 <p>
465
466 The service will have some information in environment variables:
467 <taglist compact>
468 <tag/<tt/USERV_USER//
469 <item>
470 The login name of the calling user.  If the <prgn/LOGNAME/ variable is
471 set (or, if that is unset, if the <prgn/USER/ variable is set) in the
472 environment passed to the client by the caller then the password entry
473 for that login name will be looked up; if that password entry's uid is
474 the same as that of the calling process then that login name will be
475 used, otherwise (or if neither <prgn/LOGNAME/ nor <prgn/USER/ is set)
476 the calling process's uid will be looked up to determine their login
477 name (and if this lookup fails then the service will not be invoked).
478
479 <tag/<tt/USERV_UID//
480 <item>
481 The uid of the calling process.
482
483 <tag/<tt/USERV_GID//
484 <item>
485 The gid and supplementary group list of the calling process: first the
486 group in gid and then those in the supplementary group list, in
487 decimal, separated by spaces.
488
489 <tag/<tt/USERV_GROUP//
490 <item>
491 The group names of the calling process, listed in the same way as the
492 ids are in <prgn/USERV_GID/.  If no name can be found for any of the
493 calling process's group(s) then the service will not be invoked.
494
495 <tag/<tt/USERV_CWD//
496 <item>
497 The client's current working directory name (this directory may not be
498 accessible to the service).  If it could not be determined or the
499 <prgn/--hidecwd/ flag was used then this variable will be set to an
500 empty string (this is not considered an error).
501
502 <tag/<tt/USERV_SERVICE//
503 <item>
504 The service name requested by the caller.
505
506 <tag/<tt/USERV_U_<var/name///
507 <item>
508 The value supplied to the client by the caller using -D<var/name/.
509
510 </taglist>
511
512 <prgn/HOME/, <prgn/PATH/, <prgn/SHELL/, <prgn/LOGNAME/ and <prgn/USER/
513 will be set appropriately (according to the details of the service
514 user).
515
516
517 <chapt id="config">Service-side configuration
518 <p>
519
520 Which services may be run by whom and under what conditions is
521 controlled by configuration files.
522 <p>
523
524 The daemon will read these files in order.  Certain directives in the
525 files modify the daemon's execution settings for invoking the service,
526 for example allowing certain file descriptors to be specified by the
527 client or specifying which program to execute to provide the service.
528 <p>
529
530 The <em/last/ instance of each such setting will take effect.  The
531 directives which specify which program to execute will not stop the
532 configuration file from being read; they will be remembered and will
533 only take effect if they are not overridden by a later directive.
534 <p>
535
536 The daemon will first read <tt>/etc/userv/system.default</>.  Then, by
537 default (this behaviour may be modified), it will read a per-user file
538 <tt>~/.userv/rc</>, if it exists and the service user's shell is in
539 <tt>/etc/shells</>.  Finally it will read
540 <tt>/etc/userv/system.override</>.
541 <p>
542
543 When it has read all of these files it will act according to the
544 currently values of of the execution settings.
545
546 <sect>Configuration file syntax
547 <p>
548
549 The configuration file is a series of directives, usually one per
550 line.  The portion of a line following a hash character <tt/#/ is
551 taken as a comment and ignored.  Each directive consists of a series
552 of tokens separated by linear whitespace (spaces and tabs); tokens may
553 be words consisting of non-space characters, or, where a string is
554 required, a string in double quotes.  Double-quoted strings may
555 contain the following backslash escapes:
556
557 <taglist compact>
558 <tag/<tt/\n//<item>newline
559 <tag/<tt/\t//<item>tab
560 <tag/<tt/\r//<item>carriage return
561 <tag/<tt/\<var/OOO///<item>character whose octal code is <var/OOO/
562 <tag/<tt/\x<var/XX///<item>character whose hex code is <var/XX/
563 <tag/<tt/\<var/punctuation///<item>literal punctuation character (eg <tt/\\/, <tt/\"/)
564 <tag/<tt/\<var/newline// (ie, backslash at end of line)/
565 <item>string continues on next line
566 </taglist>
567 <p>
568
569 Relative pathnames in directives are relative to the service program's
570 current directory (usually the service user's home directory).
571 Pathnames starting with the two characters <tt>~/</> are taken to be
572 relative to the service user's home directory.
573
574 <sect id="directives">Configuration file directives
575 <p>
576
577 <sect1 id="dirs-immediate">Immediate directives
578 <p>
579
580 The following directives take effect immediately:
581
582 <taglist>
583 <tag/<tt/cd <var/pathname///
584 <item>
585 Change directory in the service program.  <prgn/cd/ is cumulative.  It
586 is an error if the directory cannot be changed to.
587 <p>
588
589 <prgn/cd/ should not be used between <prgn/execute-from-directory/ and
590 the invocation of the service program, as the test for the
591 availability of the service program would be done with the old current
592 directory and the actual execution with the new (probably causing an
593 error).
594
595 <tag/<tt/eof//
596 <item>
597 Stop reading the configuration file in question, as if end of file had
598 been reached.  Any control constructs (<prgn/if/, <prgn/catch-quit/ or
599 <prgn/errors-push/) which were started in that file will be considered
600 finished.  Parsing will continue in the file which caused the file
601 containing the <prgn/eof/ to be read.
602
603 <tag/<tt/quit//
604 <item>
605 Stop reading configuration files and act immediately on the current
606 settings.  The behaviour of <prgn/quit/ is subject to the
607 <prgn/catch-quit/ control construct.
608
609 <tag/<tt/include <var/filename///
610 <tag/<tt/include-ifexist <var/filename///
611 <item>
612 Read the configuration file <var/filename/, and then return to this
613 file and continue parsing it with the next directive.  It is an error
614 if the file cannot be opened and read, unless <prgn/include-ifexist/
615 is used and the file does not exist, in which case the directive is
616 silently ignored.
617
618 <tag/<tt/include-lookup <var/parameter/ <var/directory///
619 <tag/<tt/include-lookup-all <var/parameter/ <var/directory///
620 <item>
621 Read the configuration file in <var/directory/ whose name is the value
622 of <var/parameter/ (see the description of <prgn/if/, <ref
623 id="dirs-control">).  If <var/parameter/ has several values they will
624 be tried in order; with <prgn/include-lookup/ this search will stop
625 when one is found, but with <prgn/include-lookup-all/ the search will
626 continue and any files appropriate to other values will be read too.
627 <p>
628
629 If none of the parameter's values had a corresponding file then the
630 file <tt/:default/ will be read, if it exists.  If <var/parameter/'s
631 list of values was empty then the file <tt/:none/ will be tried first
632 and read if it exists, otherwise <tt/:default/ will be tried.
633 <p>
634
635 It is not an error for any of the files (including <tt/:default/) not
636 to exist, but it is an error if a file exists and cannot be read or if
637 the directory cannot be accessed.
638
639 <p>
640 A translation will be applied to values before they are used to
641 construct a filename, so that the lookup cannot access dotfiles or
642 files in other directories: values starting with full stops will have
643 a colon prepended (making <tt/:./), colons will be doubled, and each
644 slash will be replaced with a colon followed by a hyphen <tt>:-</>.  A
645 parameter value which is the empty string will be replaced with
646 <tt/:empty/ (note that this is different from a parameter not having
647 any values).
648
649 <tag/<tt/include-directory <var/directory///
650 <item>
651 Read configuration from all files in directory <var/directory/ which
652 are plain files whose names consist only of alphanumerics and hyphens
653 and start with an alphanumeric.  They will be read in lexical order.
654 It is an error for the directory not to exist or for it or any of the
655 files found not to be read successfully, or for anything with an
656 appropriate name not to be a plain file or a symbolic link to a plain
657 file.
658
659 <tag/<tt/error <var/text ...///
660 <item>
661 Causes an error whose message includes the descriptive string
662 <var/text/.  <var/text/ may consist of several tokens with intervening
663 whitespace.  The whitespace will be included in the message as found
664 in the configuration file: all the characters until the end of the
665 line will be included verbatim, unless they are part of a
666 double-quoted string, in which case the usual meaning of the string
667 (i.e., after backslash escape processing) will be used.  Comments and
668 linear whitespace at the end of the line (or just before the comment)
669 will still be ignored.
670
671 <tag/<tt/message <var/text ...///
672 <item>
673 Causes a message including the descriptive string <var/text/ to be
674 delivered as if it were an error message, but does not actually cause
675 an error.
676 </taglist>
677
678 <sect1 id="dirs-delayed">Directives with delayed effect
679 <p>
680
681 The following directives have no immediate effect, but are remembered
682 and have an effect on later processing of the configuration files.
683
684 <taglist>
685 <tag/<tt/user-rcfile <var/filename///
686 <item>
687 Specifies that the file <var/filename/ should be read instead of the
688 user's <tt>~/.userv/rc</>.  This does <em/not/ happen immediately;
689 instead, the setting is remembered and used after the
690 <prgn/system.default/ configuration file has been read.  This
691 directive has no effect in a user's configuration file or in the
692 <prgn/system.override/ file, as the user's configuration file has
693 already been found and read by then and will not be re-read.
694
695 <tag/<tt/errors-to-stderr//
696 <item>
697 Causes error messages to be delivered to the client's stderr.
698
699 <tag/<tt/errors-to-file/ <var/filename//
700 <item>
701 Error messages will be written to <var/filename/, which will be opened
702 in the context of and with the privileges of the service user.
703
704 <tag/<tt/errors-to-syslog/ [<var/facility/ [<var/level/]]/
705 <item>
706 Error messages will be delivered using <prgn/syslog/.  The default
707 <var/facility/ is <tt/daemon/; the default <var/level/ is <tt/error/.
708 </taglist>
709
710 <sect1 id="dirs-control">Control structure directives
711 <p>
712
713 The following directives are used to create control structures.  If
714 the end of the file is encountered before the end of any control
715 structure which was started inside it then that control structure is
716 considered finished.  This is not an error.
717
718 <taglist>
719 <tag/<tt/if <var/condition///
720 <tag/<tt/elif <var/condition///
721 <tag/<tt/else//
722 <tag/<tt/fi//
723 <item>
724 Lines following <prgn/if/ are interpreted only if the condition is
725 true.  Many conditions are properties of parameter values.  Most
726 parameters have a single string as a value; however, some may yield
727 zero or several strings, in which case the condition is true if it is
728 true of any of the strings individually.  Parameters are described
729 below.
730 <p>
731
732 The conditions are:
733
734 <taglist compact>
735 <tag/<tt/glob <var/parameter/ <var/glob-pattern/ ...//
736 <item>
737 The value of the parameter whose name is given matches one of the glob
738 patterns (anchored at both ends; backslashes can be used to escape
739 metacharacters).
740
741 <tag/<tt/range <var/parameter/ <var/min/ <var/max///
742 <item>
743 The value of the parameter is a nonnegative integer and lies within
744 the range specified.  <var/min/ or <var/max/ may be <tt/$/ to indicate
745 no lower or upper limit, respectively.
746
747 <tag/<tt/grep <var/parameter/ <var/filename///
748 <item>
749 The <var/filename/ refers to a file one of whose lines is the value of
750 the parameter (leading or trailing whitespace on each line and empty
751 lines in the file are ignored).  It is an error for the file not to be
752 opened and read.
753
754 <tag/<tt/! <var/condition///
755 <item>
756 The <var/condition/ is <em/not/ true.
757
758 <tag/Conjunctions: <tt/&amp;/ and <tt/|//
759 <item>
760 <example>
761 ( <var/condition/
762 &amp; <var/condition/
763 &amp; <var/condition/
764 ...
765 )
766 </example>
767 is true if all the listed conditions are true; where <tt/|/ is used it
768 is true if any of them is true.  Newlines must be used to separate one
769 condition from the next, as shown, and the parentheses are mandatory.
770 These conjunctions do not do lazy evaluation.
771 </taglist>
772 <p>
773
774 The parameters are:
775
776 <taglist compact>
777 <tag/<tt/service//
778 <item>
779 The service name specified when the client was called.
780
781 <tag/<tt/calling-user//
782 <item>
783 Two strings: the login name of the calling user (determined as for
784 <prgn/USERV_USER/, above) and the calling uid (represented in
785 decimal).
786
787 <tag/<tt/calling-group//
788 <item>
789 Several strings: the primary and supplementary group names and gids
790 (in decimal) of the calling process.  All the group names come first,
791 and then the gids.  If the first supplementary group is the same as
792 the primary group then it is elided.
793
794 <tag/<tt/calling-user-shell//
795 <item>
796 The calling user's shell, as listed in the password entry for the
797 calling login name (as determined for <prgn/USERV_USER/, above).
798
799 <tag/<tt/service-user//
800 <item>
801 Two strings: the name of the service user (as specified to the client)
802 and their uid (represented in decimal).
803
804 <tag/<tt/service-group//
805 <item>
806 Several strings: the primary and supplementary group names and gids
807 (in decimal) of the service user.
808
809 <tag/<tt/service-user-shell//
810 <item>
811 The service user's shell, as listed in their password entry.
812
813 <tag/<tt/u-<var/name///
814 <item>
815 The value of the user-defined variable <var/name/ passed by the caller
816 using the <prgn/--defvar/ command-line option to the client.  If the
817 variable was not defined then this parameter is an empty list of
818 strings; in this case any condition which tests it will be false, and
819 <tt/include-lookup/ on it will read the <tt/:none/ file, or
820 <tt/:default/ if <tt/:none/ is not found.
821
822 </taglist>
823
824 <tag/<tt/errors-push/ <var/filename//
825 <tag/<tt/srorre//
826 <item>
827 Stacks the error handling behaviour currently in effect.  Any changes
828 to error handling will take effect only between <prgn/errors-push/ and
829 <prgn/srorre/.
830
831 <tag/<tt/catch-quit//
832 <tag/<tt/hctac//
833 <item>
834 Any use of <prgn/quit/ inside <prgn/catch-quit/ will merely cause the
835 parsing to continue at <prgn/hctac/ instead.  Any control constructs
836 started since the <prgn/catch-quit/ will be considered finished if a
837 <prgn/quit/ is found.
838 <p>
839
840 If an error occurs inside <prgn/catch-quit/ the execution settings
841 will be reset (as if by the <prgn/reset/ directive) and parsing will
842 likewise continue at <prgn/hctac/.
843 <p>
844
845 If a lexical or syntax error is detected in the same configuration
846 file as the <prgn/catch-quit/, while looking for the <prgn/hctac/
847 after an error or <prgn/quit/, that new error will not be caught.
848
849 </taglist>
850
851 <sect1 id="dirs-execution">Directives for changing execution settings
852 <p>
853
854 The following directives modify the execution settings; the server
855 will remember the fact that the directive was encountered and act on
856 it only after all the configuration has been parsed.  The <em/last/
857 directive which modifies any particuar setting will take effect.
858
859 <taglist>
860 <tag/<tt/reject//
861 <item>
862 Reject the request.  <prgn/execute/, <prgn/execute-from-directory/ and
863 <prgn/execute-from-path/ will change this setting.
864
865 <tag/<tt/execute <var/pathname/ [<var/argument/ ...]//
866 <item>
867 Execute the program <var/pathname/, with the arguments as specified,
868 followed by any arguments given to the client if
869 <prgn/no-suppress-args/ is in effect.  It is an error for the
870 execution to fail when it is attempted (after all the configuration
871 has been parsed).  If <var/pathname/ does not contain a slash it will
872 be searched for on the service user's path.
873
874 <tag/<tt/execute-from-directory <var/pathname/ [<var/argument/ ...]//
875 <item>
876 Take all the characters after the last slash of the service name
877 specified when the client was called, and execute that program in the
878 directory named by <var/pathname/ as if it had been specified for
879 <var/execute/.  The part of the service name used may contain only
880 alphanumerics and hyphens and must start with an alphanumeric (and it
881 must be non-empty), otherwise it is an error.
882 <p>
883
884 This directive is ignored if the relevant program does not exist in
885 the directory specified; in this case the program to execute is left
886 at its previous setting (or unset, if it was not set before).
887 <p>
888
889 It is an error for the test for the existence of the program to fail
890 other than with a `no such file or directory' indication.  It is also
891 an error for the execution to fail if and when it is attempted (after
892 all the configuration has been parsed).
893
894 <tag/<tt/execute-from-path//
895 <item>
896 <var/service/ is interpreted as a program on the default <prgn/PATH/
897 (or as a pathname of an executable, if it contains a <tt>/</>).  This
898 directive is <em/very dangerous/, and is only provided to make the
899 <prgn/--override/ options effective.  It should not normally be used.
900 It is an error for the execution to fail when it is attempted (after
901 all the configuration has been parsed).
902
903 <tag/<tt/execute-builtin <var/service-name/ <var/service-arguments//
904 <item>
905 Executes the builtin service <var/service-name/.  These builtin
906 services display information about the server and/or the request, and
907 ignore any arguments passed from the service side except possibly to
908 print them as part of their output.  They write their results to their
909 standard output (i.e., wherever file descriptor 1 is directed).  The
910 builtin services are:
911
912 <taglist compact>
913 <tag/<tt/execute//
914 <item>
915 Displays the execution settings, defined variables,
916 arguments, etc. with which the builtin service was invoked.
917
918 <tag/<tt/environment//
919 <item>
920 Displays the environment variable settings with which the builtin
921 service was invoked.
922
923 <tag/<tt/parameter <var/parameter///
924 <item>
925 Displays the values of the service configuration language parameter
926 specified.
927
928 <tag/<tt/version//
929 <item>
930 Displays the version string and compilation details of the uservd
931 server program.
932
933 <tag/<tt/reset//
934 <item>
935 Displays the default reset configuration (evaluated when <prgn/reset/
936 is found in a configuration file, or when an error is caught by
937 <prgn/catch-quit/).
938
939 <tag/<tt/toplevel//
940 <item>
941 Displays the top-level default configuration (the configuration data,
942 evaluated by the server, which calls all the other configuration
943 files).
944
945 <tag/<tt/override//
946 <item>
947 Displays the top-level override configuration (the configuration data,
948 evaluated by the server, which causes all the other configuration data
949 to be parsed).
950 </taglist>
951
952 In the future other builtin services may be defined which do more than
953 just print information.
954
955 <tag/<tt/set-environment//
956 <tag/<tt/no-set-environment//
957 <item>
958 Runs <tt>/etc/environment</> to set the service user's environment.
959 This adds the overhead of invoking a shell, but doesn't cause any
960 shell (de)mangling of the service's arguments.  This is achieved by
961 invoking
962 <example>
963 .../program arg arg arg ...
964 </example>
965 as
966 <example>
967 /bin/sh -c '. /etc/environment; exec "$@"' - .../program arg arg arg ...
968 </example>
969 <prgn/no-set-environment/ cancels the effect of
970 <prgn/set-environment/.
971
972 <tag/<tt/no-suppress-args//
973 <tag/<tt/suppress-args//
974 <item>
975 Include any arguments given to the client as arguments to the program
976 invoked as a result of an <prgn/execute/,
977 <prgn/execute-from-directory/ or <prgn/execute-from-path/ directive.
978 <prgn/suppress-args/ undoes the effect of <prgn/no-suppress-args/.
979
980 <tag/<tt/require-fd <var/fd-range/ read|write//
981 <item>
982 Insist that the filedescriptor(s) be opened for reading resp. writing.
983 It is an error if any descriptor marked as required when the service
984 is about to be invoked (after the configuration has been parsed) was
985 not specified when the client was invoked.  Each file descriptor has a
986 separate setting, and the last one of <prgn/require-fd/,
987 <prgn/allow-fd/, <prgn/ignore-fd/, <prgn/null-fd/ or <prgn/reject-fd/
988 which affected a particular file descriptor will take effect.
989 <p>
990
991 <var/fd-range/ may be a single number, two numbers separated by a
992 hyphen, or one number followed by a hyphen (indicating all descriptors
993 from that number onwards).  It may also be one of the words
994 <tt/stdin/, <tt/stdout/ or <tt/stderr/.  Open-ended file descriptor
995 rangers are allowed only with <prgn/reject-fd/ and <prgn/ignore-fd/,
996 as otherwise the service program would find itself with a very large
997 number of file descriptors open.
998 <p>
999
1000 When the configuration has been parsed, and before the service is
1001 about to be executed, stderr (fd 2) must be required or allowed
1002 (<prgn/require-fd/ or <prgn/allow-fd/) for writing; this is so that
1003 the error message printed by the server's child process if it cannot
1004 <prgn/exec/ the service program is not lost.
1005
1006 <tag/<tt/allow-fd <var/fd-range/ [read|write]//
1007 <item>
1008 Allow the descriptor(s) to be opened for reading resp. writing, or
1009 either if neither <tt/read/ nor <tt/write/ is specified.  If a
1010 particular descriptor not specified by the client then it will be open
1011 onto <tt>/dev/null</> (for reading, writing, or both, depending on
1012 whether <tt/read/, <tt/write/ or neither was specified).
1013
1014 <tag/<tt/null-fd <var/fd-range/ [read|write]//
1015 <item>
1016 Specify that the descriptor(s) be opened onto <prgn>/dev/null</> for
1017 reading resp. writing, or both if neither <tt/read/ nor <tt/write/
1018 is specified.  Any specification of these file descriptors by the
1019 client will be silently ignored; the client will see its ends of the
1020 descriptors being closed immediately.
1021
1022 <tag/<tt/reject-fd <var/fd-range///
1023 <item>
1024 Do not allow the descriptor(s) to be specified by the client.  It is
1025 an error if any descriptor(s) marked for rejection are specified when
1026 the service is about to be invoked (after the configuration has been
1027 parsed).
1028
1029 <tag/<tt/ignore-fd <var/fd-range///
1030 <item>
1031 Silently ignore any specification by the client of those
1032 descriptor(s).  The pipes corresponding to these descriptors will be
1033 closed just before the service is invoked.
1034
1035 <tag/<tt/disconnect-hup//
1036 <tag/<tt/no-disconnect-hup//
1037 <item>
1038 Causes the service's process group to get a <prgn/SIGHUP/ if the
1039 client disconnects before the main service process terminates.
1040 <prgn/no-disconnect-hup/ cancels <prgn/disconnect-hup/.
1041 <p>
1042
1043 If one of the reading descriptors specified when the client is called
1044 gets a read error, or if the service is disconnected for some other
1045 reason, then the <prgn/SIGHUP/ will be delivered <em/before/ the
1046 writing end(s) of the service's reading pipe(s) are closed, so that
1047 the client can distinguish disconnection from reading EOF on a pipe.
1048
1049 <tag/<tt/reset//
1050 <item>
1051 Resets the execution settings to the default.  This is equivalent to:
1052 <example>
1053 cd ~/
1054 reject
1055 no-set-environment
1056 suppress-args
1057 allow-fd 0 read
1058 allow-fd 1-2 write
1059 reject-fd 3-
1060 disconnect-hup
1061 </example>
1062
1063 </taglist>
1064
1065 If no <prgn/execute/, <prgn/execute-from-path/,
1066 <prgn/execute-from-directory/ or <prgn/builtin/ is interpreted before
1067 all the files are read then the request is rejected.
1068
1069
1070 <sect id="configerrors">Errors in the configuration file
1071 <p>
1072
1073 If a syntax error or other problem occurs when processing a
1074 configuration file then a diagnostic will be issued, to wherever the
1075 error messages are currently being sent (see the <prgn/errors-/ family
1076 of directives, above).
1077 <p>
1078
1079 The error will cause processing of the configuration files to cease at
1080 that point, unless the error was inside a <prgn/catch-quit/ construct.
1081 In this case the settings controlling the program's execution will be
1082 reset to the defaults as if a <prgn/reset/ directive had been issued,
1083 and parsing continues after <prgn/hctac/.
1084
1085
1086 <sect id="defaults">Defaults
1087 <p>
1088
1089 The default configuration processing is as if the daemon were parsing
1090 an overall configuration file whose contents were as follows:
1091
1092 <example>
1093 reset
1094 user-rcfile ~/.userv/rc
1095 errors-to-stderr
1096 include /etc/userv/system.default
1097 if grep service-user-shell /etc/shells
1098    errors-push
1099      catch-quit
1100        include-ifexist <var/file specified by most recent user-rcfile directive/
1101      hctac
1102    srorre
1103 fi
1104 include /etc/userv/system.override
1105 quit
1106 </example>
1107 <p>
1108
1109 If one of the <prgn/--override/ options to the client is used then it
1110 will instead be as if the daemon were parsing an overall configuration
1111 as follows:
1112
1113 <example>
1114 reset
1115 errors-to-stderr
1116 include <var/file containing configuration data sent by client/
1117 quit
1118 </example>
1119
1120
1121 <chapt id="ipass">Information passed through the client/daemon combination
1122 <p>
1123
1124 The information described below is the only information which passes
1125 between the caller and the service.
1126
1127 <list>
1128 <item>
1129 The service name supplied by the caller is available in the
1130 configuration language for deciding whether and which service program
1131 to invoke, in the <prgn/service/ parameter, and is used by the
1132 <prgn/execute-from-directory/ and <prgn/execute-from-path/
1133 configuration directives.  It is usually used to select which service
1134 program to invoke.  It is also passed to the service program in the
1135 <prgn/USERV_SERVICE/ environment variable.
1136
1137 <item>
1138 File descriptors specified by the client and allowed according to the
1139 configuration language will be connected.  Each file descriptor is
1140 opened for reading or writing.  Communication is via pipes, one end of
1141 each pipe being open on the appropriate file descriptor in the service
1142 program (when it is invoked) and the other end being held by the
1143 client process, which will read and write files it opens on behalf of
1144 its caller or file descriptors it is passed by its caller.
1145 <p>
1146
1147 Data may be passed into the service through reading pipes and out of
1148 it through writing pipes.  These pipes can remain open only until the
1149 service and client have terminated, or can be made to stay open after
1150 the client has terminated and (if the service program forks) the main
1151 service process has exited; the behaviour is controlled by options
1152 passed to the client by its caller.
1153 <p>
1154
1155 The caller can arrange that a writing pipe be connected to a pipe or
1156 similar object and cause attempts to write to that descriptor by the
1157 service to generate a <prgn/SIGPIPE/ (or <prgn/EPIPE/ if
1158 <prgn/SIGPIPE/ is caught or ignored) in the service.
1159 <p>
1160
1161 Likewise, the service can close filedescriptors specified for reading,
1162 which will cause the corresponding filedescriptors passed by the
1163 caller to be closed, so that if these are pipes processes which write
1164 to them will receive <prgn/SIGPIPE/ or <prgn/EPIPE/.
1165
1166 <item>
1167 If <prgn/no-suppress-args/ is set then arguments passed to the client
1168 by its caller will be passed on, verbatim, to the service.
1169
1170 <item>
1171 Fatal signals and system call failures experienced by the client will
1172 result in the disconnection of the service from the client and
1173 possibly some of the communication file descriptors described above;
1174 if <prgn/disconnect-hup/ is set then the service will also be sent a
1175 <prgn/SIGHUP/.
1176
1177 <item>
1178 The value of the <prgn/LOGNAME/ (or <prgn/USER/) environment variable
1179 as passed to the client will be used as the login name of the calling
1180 user if the uid of the calling process matches the uid corresponding
1181 to that login name.  Otherwise the calling uid's password entry will
1182 be used to determine the calling user's login name.
1183 <p>
1184
1185 This login name and the calling uid are available in the configuration
1186 language in the <prgn/calling-user/ parameter and are passed to the
1187 service program in environment variables <prgn/USERV_USER/ and
1188 <prgn/USERV_UID/.
1189 <p>
1190
1191 The shell corresponding to that login name (according to the password
1192 entry) is available as in the configuration language's
1193 <prgn/calling-user-shell/ parameter.
1194 <p>
1195
1196 If no relevant password entry can be found then no service will be
1197 invoked.
1198
1199 <item>
1200 The numeric values and textual names for calling gid and supplementary
1201 group list are available in the configuration language in the
1202 <prgn/calling-group/ parameter and are passed to the service in
1203 environment variables.
1204 <p>
1205
1206 If no name can be found for a numeric group to which the calling
1207 process belongs then no service will be invoked.
1208
1209 <item>
1210 The name of the current working directory in which the client was
1211 invoked is passed, if available and not hidden using <prgn/--hidecwd/,
1212 to the service program in the <prgn/USERV_CWD/ variable.  This grants no
1213 special access to that directory unless it is a subdirectory of a
1214 directory which is executable (searchable) but not readable by the
1215 service user.
1216
1217 <item>
1218 Settings specified by the caller using the <tt/--defvar
1219 <var/name/=<var/value// option to the client are available in the
1220 configuration language as the corresponding <tt/u-<var/name//
1221 parameters and are passed to the service program in environment
1222 variables <tt/USERV_U_<var/name//.
1223
1224 <item>
1225 If the calling user is root or the same as the service user then
1226 options may be given to the client which bypass the usual security
1227 features; in this case other information may pass between the caller
1228 and the service.
1229
1230 </list>
1231
1232 <chapt id="notes">Applications and notes on use
1233 <p>
1234
1235 <sect id="reducepriv">Reducing the number of absolutely privileged subsystems
1236 <p>
1237
1238 Currently most Unix systems have many components which need to run as
1239 root, even though most of their activity does not strictly require
1240 it.  This gives rise to a large and complex body of code which must be
1241 trusted with the security of the system.
1242 <p>
1243
1244 Using <prgn/userv/ many of these subsystems no longer need any unusual
1245 privilege.
1246 <p>
1247
1248 <prgn/cron/ and <prgn/at/, <prgn/lpr/ and the system's mail transfer
1249 agent (<prgn/sendmail/, <prgn/smail/, <prgn/exim/ or the like) all
1250 fall into this category.
1251
1252 <sect id="noexcess">Do not give away excessive privilege to <prgn/userv/-using facilities
1253 <p>
1254
1255 There is a danger that people reimplementing the facilities I mention
1256 above using <prgn/userv/ will discard much of the security benefit by
1257 using a naive implementation technique.  This will become clearer with
1258 an example:
1259 <p>
1260
1261 Consider the <prgn/lpr/ program.  In current systems this needs to
1262 have an absolutely privileged component in order to support delayed
1263 printing without copying: when the user queues a file to be printed
1264 the filename is stored in the print queue, rather than a copy of it,
1265 and the printer daemon accesses the file directly when it is ready to
1266 print the job.  In order that the user can print files which are not
1267 world-readable the daemon is given root privilege so that it can open
1268 the file in the context of the user, rather than its own.
1269 <p>
1270
1271 A simple-minded approach to converting this scheme to use <prgn/userv/
1272 might involve giving the printer daemon (the <prgn/lp/ user) the
1273 ability to read the file by allowing them to run <prgn/cat/ (or a
1274 special-purpose file-reading program) as any user.  The <prgn/lpr/
1275 program would use a <prgn/userv/ service to store the filename in the
1276 printer daemon's queues, and the daemon would read the file later when
1277 it felt like it.
1278 <p>
1279
1280 However, this would allow the printer daemon to read any file on the
1281 system, whether or not someone had asked for it to be printed.  Since
1282 many files will contain passwords and other security-critical
1283 information this is nearly as bad as giving the daemon root access in
1284 the first place.  Any security holes in the print server which allow a
1285 user to execute commands as the <prgn/lp/ user will give the user the
1286 ability to read any file on the system.
1287 <p>
1288
1289 Instead, it is necessary to keep a record of which files the daemon
1290 has been asked to print <em/outside/ the control of the print daemon.
1291 This record could be kept by a new root-privileged component, but this
1292 is not necessary: the record of which files a user has asked to be
1293 printed can be kept under the control of the user in question.  The
1294 submission program <prgn/lpr/ will make a record in an area under the
1295 user's control before communicating with the print server, and the
1296 print server would be given the ability to run a special file-reading
1297 program which would only allow files to be read which were listed in
1298 the user's file of things they'd asked to print.
1299 <p>
1300
1301 Now security holes in most of the printing system do not critically
1302 affect the security of the entire system: they only allow the attacker
1303 to read and interfere with print jobs.  Bugs in the programs run by the
1304 print server to read users' files (and to remove entries from the list
1305 of files when it has done with them) will still be serious, but this
1306 program can be quite simple.
1307 <p>
1308
1309 Similar considerations apply to many <prgn/userv/-based versions of
1310 facilities which currently run as root.
1311 <p>
1312
1313 It is debatable whether the user-controlled state should be kept in
1314 the user's filespace (in dotfiles, say) or kept in a separate area set
1315 aside for the purpose; however, using the user's home directory (and
1316 probably creating a separate subdirectory of it as a dotfile to
1317 contain many subsystems' state) has fewer implications for the rest of
1318 the system and makes it entirely clear where the security boundaries
1319 lie.
1320
1321 <sect id="notreally"><prgn/userv/ is not a replacement for <prgn/really/ and <prgn/sudo/
1322 <p>
1323
1324 <prgn/userv/ is not intended as a general-purpose system
1325 administration tool with which system administrators can execute
1326 privileged programs when they need to.  It is unsuitable for this
1327 purpose precisely because it enforces a strong separation between the
1328 calling and the called program, which is undesirable in this context.
1329 <p>
1330
1331 Its facilities for restricting activities to running certain programs
1332 may at first glance seem to provide similar functionality to
1333 <prgn/sudo/<footnote><prgn/sudo/ is a program which allows users to
1334 execute certain programs as root, according to configuration files
1335 specified by the system administrator.</footnote>.  However, the
1336 separation mentioned above is a problem here too, particular for
1337 interaction - it can be hard for a <prgn/userv/ service program to
1338 interact with its real caller or the user in question.
1339
1340 <sect id="nogeneral">Don't give access to general-purpose utilities
1341 <p>
1342
1343 Do not specify general purpose programs like <prgn/mv/ or <prgn/cat/
1344 in <prgn/execute-/ directives without careful thought about their
1345 arguments, and certainly not if <prgn/no-suppress-args/ is specified.
1346 If you do so it will give the caller much more privilige than you
1347 probably intend.
1348 <p>
1349
1350 It is a shame that I have to say this here, but inexperienced
1351 administrators have made similar mistakes with programs like
1352 <prgn/sudo/.
1353
1354 </book>