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