This file is indexed.

/usr/share/doc/userv/spec.html/ch-config.html is in userv 1.1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<title>User service daemon and client specification - Service-side configuration</title>

<link href="index.html" rel="start">
<link href="ch-envir.html" rel="prev">
<link href="ch-ipass.html" rel="next">
<link href="index.html#contents" rel="contents">
<link href="index.html#copyright" rel="copyright">
<link href="ch-intro.html" rel="chapter" title="1 Introduction">
<link href="ch-client.html" rel="chapter" title="2 Client program usage">
<link href="ch-envir.html" rel="chapter" title="3 Execution environment of the service program">
<link href="ch-config.html" rel="chapter" title="4 Service-side configuration">
<link href="ch-ipass.html" rel="chapter" title="5 Information passed through the client/daemon combination">
<link href="ch-notes.html" rel="chapter" title="6 Applications and notes on use">
<link href="ch-client.html#s2.1" rel="section" title="2.1 Options">
<link href="ch-client.html#s-optoverride" rel="section" title="2.2 Security-overriding options">
<link href="ch-envir.html#s3.1" rel="section" title="3.1 File descriptors">
<link href="ch-envir.html#s3.2" rel="section" title="3.2 Environment">
<link href="ch-config.html#s4.1" rel="section" title="4.1 Configuration file syntax">
<link href="ch-config.html#s-directives" rel="section" title="4.2 Configuration file directives">
<link href="ch-config.html#s-configerrors" rel="section" title="4.3 Errors in the configuration file">
<link href="ch-config.html#s-defaults" rel="section" title="4.4 Defaults">
<link href="ch-notes.html#s-examples" rel="section" title="6.1 Examples">
<link href="ch-notes.html#s-standards" rel="section" title="6.2 Standard services and directory management">
<link href="ch-notes.html#s-reducepriv" rel="section" title="6.3 Reducing the number of absolutely privileged subsystems">
<link href="ch-notes.html#s-noexcess" rel="section" title="6.4 Do not give away excessive privilege to userv-using facilities">
<link href="ch-notes.html#s-notreally" rel="section" title="6.5 userv can often replace sudo, but not really">
<link href="ch-notes.html#s-stdinerr" rel="section" title="6.6 Error handling and input streams (eg stdin)">
<link href="ch-notes.html#s-nogeneral" rel="section" title="6.7 Don't give access to general-purpose utilities">
<link href="ch-config.html#s-dirs-immediate" rel="subsection" title="4.2.1 Immediate directives">
<link href="ch-config.html#s-dirs-delayed" rel="subsection" title="4.2.2 Directives with delayed effect">
<link href="ch-config.html#s-dirs-control" rel="subsection" title="4.2.3 Control structure directives">
<link href="ch-config.html#s-dirs-execution" rel="subsection" title="4.2.4 Directives for changing execution settings">

</head>

<body>

<p><a name="ch-config"></a></p>
<hr>

<p>
[ <a href="ch-envir.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch-intro.html">1</a> ]
[ <a href="ch-client.html">2</a> ]
[ <a href="ch-envir.html">3</a> ]
[ 4 ]
[ <a href="ch-ipass.html">5</a> ]
[ <a href="ch-notes.html">6</a> ]
[ <a href="ch-ipass.html">next</a> ]
</p>

<hr>

<h1>
User service daemon and client specification
<br>Chapter 4 - Service-side configuration
</h1>

<hr>

<p>
Which services may be run by whom and under what conditions is controlled by
configuration files.
</p>

<p>
The daemon will read these files in order.  Certain directives in the files
modify the daemon's execution settings for invoking the service, for example
allowing certain file descriptors to be specified by the client or specifying
which program to execute to provide the service.
</p>

<p>
The <em>last</em> instance of each such setting will take effect.  The
directives which specify which program to execute will not stop the
configuration file from being read; they will be remembered and will only take
effect if they are not overridden by a later directive.
</p>

<p>
The daemon will first read <samp>/etc/userv/system.default</samp>.  Then, by
default (this behaviour may be modified), it will read a per-user file
<samp>~/.userv/rc</samp>, if it exists and the service user's shell is in
<samp>/etc/shells</samp>.  Finally it will read
<samp>/etc/userv/system.override</samp>.
</p>

<p>
When it has read all of these files it will act according to the currently
values of of the execution settings.
</p>

<hr>

<h2><a name="s4.1"></a>4.1 Configuration file syntax</h2>

<p>
The configuration file is a series of directives, usually one per line.  The
portion of a line following a hash character <samp>#</samp> is taken as a
comment and ignored.  Each directive consists of a series of tokens separated
by linear whitespace (spaces and tabs); tokens may be words consisting of
non-space characters, or, where a string is required, a string in double
quotes.  Double-quoted strings may contain the following backslash escapes:
</p>
<dl>
<dt><samp>\n</samp></dt>
<dd>
<p>
newline
</p>
</dd>
<dt><samp>\t</samp></dt>
<dd>
<p>
tab
</p>
</dd>
<dt><samp>\r</samp></dt>
<dd>
<p>
carriage return
</p>
</dd>
<dt><samp>\<var>OOO</var></samp></dt>
<dd>
<p>
character whose octal code is <var>OOO</var>
</p>
</dd>
<dt><samp>\x<var>XX</var></samp></dt>
<dd>
<p>
character whose hex code is <var>XX</var>
</p>
</dd>
<dt><samp>\<var>punctuation</var></samp></dt>
<dd>
<p>
literal punctuation character (eg <samp>\\</samp>, <samp>\&quot;</samp>)
</p>
</dd>
<dt><samp>\<var>newline</var></samp> (ie, backslash at end of line)</dt>
<dd>
<p>
string continues on next line
</p>
</dd>
</dl>

<p>
Relative pathnames in directives are relative to the service program's current
directory (usually the service user's home directory).  Pathnames starting with
the two characters <samp>~/</samp> are taken to be relative to the service
user's home directory.
</p>

<hr>

<h2><a name="s-directives"></a>4.2 Configuration file directives</h2>

<hr>

<h3><a name="s-dirs-immediate"></a>4.2.1 Immediate directives</h3>

<p>
The following directives take effect immediately:
</p>
<dl>
<dt><samp>cd <var>pathname</var></samp></dt>
<dd>
<p>
Change directory in the service program.  <code>cd</code> is cumulative.  It is
an error if the directory cannot be changed to.
</p>

<p>
<code>cd</code> should not be used between <code>execute-from-directory</code>
and the invocation of the service program, as the test for the availability of
the service program would be done with the old current directory and the actual
execution with the new (probably causing an error).
</p>
</dd>
</dl>
<dl>
<dt><samp>eof</samp></dt>
<dd>
<p>
Stop reading the configuration file in question, as if end of file had been
reached.  Any control constructs (<code>if</code>, <code>catch-quit</code> or
<code>errors-push</code>) which were started in that file will be considered
finished.  Parsing will continue in the file which caused the file containing
the <code>eof</code> to be read.
</p>
</dd>
</dl>
<dl>
<dt><samp>quit</samp></dt>
<dd>
<p>
Stop reading configuration files and act immediately on the current settings.
The behaviour of <code>quit</code> is subject to the <code>catch-quit</code>
control construct.
</p>
</dd>
</dl>
<dl>
<dt><samp>include <var>filename</var></samp></dt>
<dt><samp>include-ifexist <var>filename</var></samp></dt>
<dd>
<p>
Read the configuration file <var>filename</var>, and then return to this file
and continue parsing it with the next directive.  It is an error if the file
cannot be opened and read, unless <code>include-ifexist</code> is used and the
file does not exist, in which case the directive is silently ignored.
</p>
</dd>
</dl>
<dl>
<dt><samp>include-lookup <var>parameter</var> <var>directory</var></samp></dt>
<dt><samp>include-lookup-all <var>parameter</var> <var>directory</var></samp></dt>
<dd>
<p>
Read the configuration file in <var>directory</var> whose name is the value of
<var>parameter</var> (see the description of <code>if</code>, <a
href="#s-dirs-control">Control structure directives, Section 4.2.3</a>).  If
<var>parameter</var> has several values they will be tried in order; with
<code>include-lookup</code> this search will stop when one is found, but with
<code>include-lookup-all</code> the search will continue and any files
appropriate to other values will be read too.
</p>

<p>
If none of the parameter's values had a corresponding file then the file
<samp>:default</samp> will be read, if it exists.  If <var>parameter</var>'s
list of values was empty then the file <samp>:none</samp> will be tried first
and read if it exists, otherwise <samp>:default</samp> will be tried.
</p>

<p>
It is not an error for any of the files (including <samp>:default</samp>) not
to exist, but it is an error if a file exists and cannot be read or if the
directory cannot be accessed.
</p>

<p>
A translation will be applied to values before they are used to construct a
filename, so that the lookup cannot access dotfiles or files in other
directories: values starting with full stops will have a colon prepended
(making <samp>:.</samp>), colons will be doubled, and each slash will be
replaced with a colon followed by a hyphen <samp>:-</samp>.  A parameter value
which is the empty string will be replaced with <samp>:empty</samp> (note that
this is different from a parameter not having any values).
</p>
</dd>
</dl>
<dl>
<dt><samp>include-directory <var>directory</var></samp></dt>
<dd>
<p>
Read configuration from all files in directory <var>directory</var> which are
plain files whose names consist only of alphanumerics and hyphens and start
with an alphanumeric.  They will be read in lexical order.  It is an error for
the directory not to exist or for it or any of the files found not to be read
successfully, or for anything with an appropriate name not to be a plain file
or a symbolic link to a plain file.
</p>
</dd>
</dl>
<dl>
<dt><samp>error <var>text ...</var></samp></dt>
<dd>
<p>
Causes an error whose message includes the descriptive string <var>text</var>.
<var>text</var> may consist of several tokens with intervening whitespace.  The
whitespace will be included in the message as found in the configuration file:
all the characters until the end of the line will be included verbatim, unless
they are part of a double-quoted string, in which case the usual meaning of the
string (i.e., after backslash escape processing) will be used.  Comments and
linear whitespace at the end of the line (or just before the comment) will
still be ignored.
</p>
</dd>
</dl>
<dl>
<dt><samp>message <var>text ...</var></samp></dt>
<dd>
<p>
Causes a message including the descriptive string <var>text</var> to be
delivered as if it were an error message, but does not actually cause an error.
</p>
</dd>
</dl>

<hr>

<h3><a name="s-dirs-delayed"></a>4.2.2 Directives with delayed effect</h3>

<p>
The following directives have no immediate effect, but are remembered and have
an effect on later processing of the configuration files.
</p>
<dl>
<dt><samp>user-rcfile <var>filename</var></samp></dt>
<dd>
<p>
Specifies that the file <var>filename</var> should be read instead of the
user's <samp>~/.userv/rc</samp>.  This does <em>not</em> happen immediately;
instead, the setting is remembered and used after the
<code>system.default</code> configuration file has been read.  This directive
has no effect in a user's configuration file or in the
<code>system.override</code> file, as the user's configuration file has already
been found and read by then and will not be re-read.
</p>
</dd>
</dl>
<dl>
<dt><samp>errors-to-stderr</samp></dt>
<dd>
<p>
Causes error messages to be delivered to the client's stderr.
</p>
</dd>
</dl>
<dl>
<dt><samp>errors-to-file</samp> <var>filename</var></dt>
<dd>
<p>
Error messages will be written to <var>filename</var>, which will be opened in
the context of and with the privileges of the service user.
</p>
</dd>
</dl>
<dl>
<dt><samp>errors-to-syslog</samp> [<var>facility</var> [<var>level</var>]]</dt>
<dd>
<p>
Error messages will be delivered using <code>syslog</code>.  The default
<var>facility</var> is <samp>user</samp>; the default <var>level</var> is
<samp>error</samp>.
</p>
</dd>
</dl>

<hr>

<h3><a name="s-dirs-control"></a>4.2.3 Control structure directives</h3>

<p>
The following directives are used to create control structures.  If the end of
the file is encountered before the end of any control structure which was
started inside it then that control structure is considered finished.  This is
not an error.
</p>
<dl>
<dt><samp>if <var>condition</var></samp></dt>
<dt><samp>elif <var>condition</var></samp></dt>
<dt><samp>else</samp></dt>
<dt><samp>fi</samp></dt>
<dd>
<p>
Lines following <code>if</code> are interpreted only if the condition is true.
Many conditions are properties of parameter values.  Most parameters have a
single string as a value; however, some may yield zero or several strings, in
which case the condition is true if it is true of any of the strings
individually.  Parameters are described below.
</p>

<p>
The conditions are:
</p>
<dl>
<dt><samp>glob <var>parameter</var> <var>glob-pattern</var> ...</samp></dt>
<dd>
<p>
The value of the parameter whose name is given matches one of the glob patterns
(anchored at both ends; backslashes can be used to escape metacharacters).
</p>
</dd>
<dt><samp>range <var>parameter</var> <var>min</var> <var>max</var></samp></dt>
<dd>
<p>
The value of the parameter is a nonnegative integer and lies within the range
specified.  <var>min</var> or <var>max</var> may be <samp>$</samp> to indicate
no lower or upper limit, respectively.
</p>
</dd>
<dt><samp>grep <var>parameter</var> <var>filename</var></samp></dt>
<dd>
<p>
The <var>filename</var> refers to a file one of whose lines is the value of the
parameter (leading or trailing whitespace on each line and empty lines in the
file are ignored).  It is an error for the file not to be opened and read.
</p>
</dd>
<dt><samp>! <var>condition</var></samp></dt>
<dd>
<p>
The <var>condition</var> is <em>not</em> true.
</p>
</dd>
<dt>Conjunctions: <samp>&amp;</samp> and <samp>|</samp></dt>
<dd>
<pre>
     ( <var>condition</var>
     &amp; <var>condition</var>
     &amp; <var>condition</var>
     ...
     )
</pre>
<p>
is true if all the listed conditions are true; where <samp>|</samp> is used it
is true if any of them is true.  Newlines must be used to separate one
condition from the next, as shown, and the parentheses are mandatory.  These
conjunctions do not do lazy evaluation.
</p>
</dd>
</dl>

<p>
The parameters are:
</p>
<dl>
<dt><samp>service</samp></dt>
<dd>
<p>
The service name specified when the client was called.
</p>
</dd>
<dt><samp>calling-user</samp></dt>
<dd>
<p>
Two strings: the login name of the calling user (determined as for
<code>USERV_USER</code>, above) and the calling uid (represented in decimal).
</p>
</dd>
<dt><samp>calling-group</samp></dt>
<dd>
<p>
Several strings: the primary and supplementary group names and gids (in
decimal) of the calling process.  All the group names come first, and then the
gids.  If the first supplementary group is the same as the primary group then
it is elided.
</p>
</dd>
<dt><samp>calling-user-shell</samp></dt>
<dd>
<p>
The calling user's shell, as listed in the password entry for the calling login
name (as determined for <code>USERV_USER</code>, above).
</p>
</dd>
<dt><samp>service-user</samp></dt>
<dd>
<p>
Two strings: the name of the service user (as specified to the client) and
their uid (represented in decimal).
</p>
</dd>
<dt><samp>service-group</samp></dt>
<dd>
<p>
Several strings: the primary and supplementary group names and gids (in
decimal) of the service user.
</p>
</dd>
<dt><samp>service-user-shell</samp></dt>
<dd>
<p>
The service user's shell, as listed in their password entry.
</p>
</dd>
<dt><samp>u-<var>name</var></samp></dt>
<dd>
<p>
The value of the user-defined variable <var>name</var> passed by the caller
using the <code>--defvar</code> command-line option to the client.  If the
variable was not defined then this parameter is an empty list of strings; in
this case any condition which tests it will be false, and
<samp>include-lookup</samp> on it will read the <samp>:none</samp> file, or
<samp>:default</samp> if <samp>:none</samp> is not found.
</p>
</dd>
</dl>
</dd>
</dl>
<dl>
<dt><samp>errors-push</samp> <var>filename</var></dt>
<dt><samp>srorre</samp></dt>
<dd>
<p>
Stacks the error handling behaviour currently in effect.  Any changes to error
handling will take effect only between <code>errors-push</code> and
<code>srorre</code>.
</p>
</dd>
</dl>
<dl>
<dt><samp>catch-quit</samp></dt>
<dt><samp>hctac</samp></dt>
<dd>
<p>
Any use of <code>quit</code> inside <code>catch-quit</code> will merely cause
the parsing to continue at <code>hctac</code> instead.  Any control constructs
started since the <code>catch-quit</code> will be considered finished if a
<code>quit</code> is found.
</p>

<p>
If an error occurs inside <code>catch-quit</code> the execution settings will
be reset (as if by the <code>reset</code> directive) and parsing will likewise
continue at <code>hctac</code>.
</p>

<p>
If a lexical or syntax error is detected in the same configuration file as the
<code>catch-quit</code>, while looking for the <code>hctac</code> after an
error or <code>quit</code>, that new error will not be caught.
</p>
</dd>
</dl>

<hr>

<h3><a name="s-dirs-execution"></a>4.2.4 Directives for changing execution settings</h3>

<p>
The following directives modify the execution settings; the server will
remember the fact that the directive was encountered and act on it only after
all the configuration has been parsed.  The <em>last</em> directive which
modifies any particuar setting will take effect.
</p>
<dl>
<dt><samp>reject</samp></dt>
<dd>
<p>
Reject the request.  <code>execute</code>, <code>execute-from-directory</code>
and <code>execute-from-path</code> will change this setting.
</p>
</dd>
</dl>
<dl>
<dt><samp>execute <var>program</var> [<var>argument</var> ...]</samp></dt>
<dd>
<p>
Execute the program <var>program</var>, with the arguments as specified,
followed by any arguments given to the client if <code>no-suppress-args</code>
is in effect.  It is an error for the execution to fail when it is attempted
(after all the configuration has been parsed).  If <var>program</var> does not
contain a slash it will be searched for on the service user's path.
</p>
</dd>
</dl>
<dl>
<dt><samp>execute-from-directory <var>pathname</var> [<var>argument</var> ...]</samp></dt>
<dd>
<p>
Take all the characters after the last slash of the service name specified when
the client was called, and execute that program in the directory named by
<var>pathname</var> as if it had been specified for <var>execute</var>.  The
part of the service name used may contain only alphanumerics and hyphens and
must start with an alphanumeric (and it must be non-empty), otherwise it is an
error.
</p>

<p>
This directive is ignored if the relevant program does not exist in the
directory specified; in this case the program to execute is left at its
previous setting (or unset, if it was not set before).
</p>

<p>
It is an error for the test for the existence of the program to fail other than
with a `no such file or directory' indication.  It is also an error for the
execution to fail if and when it is attempted (after all the configuration has
been parsed).
</p>
</dd>
</dl>
<dl>
<dt><samp>execute-from-path</samp></dt>
<dd>
<p>
<var>service</var> is interpreted as a program on the default <code>PATH</code>
(or as a pathname of an executable, if it contains a <samp>/</samp>).  This
directive is <em>very dangerous</em>, and is only provided to make the
<code>--override</code> options effective.  It should not normally be used.  It
is an error for the execution to fail when it is attempted (after all the
configuration has been parsed).
</p>
</dd>
</dl>
<dl>
<dt><samp>execute-builtin <var>service-name</var> <var>service-arguments</var></samp></dt>
<dd>
<p>
Executes the builtin service <var>service-name</var>.  These builtin services
display information about the server and/or the request, and ignore any
arguments passed from the service side except possibly to print them as part of
their output.  They write their results to their standard output (i.e.,
wherever file descriptor 1 is directed).  The builtin services are:
</p>
<dl>
<dt><samp>execute</samp></dt>
<dd>
<p>
Displays the execution settings, defined variables, arguments, etc.  with which
the builtin service was invoked.
</p>
</dd>
<dt><samp>environment</samp></dt>
<dd>
<p>
Displays the environment variable settings with which the builtin service was
invoked.
</p>
</dd>
<dt><samp>parameter <var>parameter</var></samp></dt>
<dd>
<p>
Displays the values of the service configuration language parameter specified.
</p>
</dd>
<dt><samp>version</samp></dt>
<dd>
<p>
Displays the version string and compilation details of the uservd server
program.
</p>
</dd>
<dt><samp>reset</samp></dt>
<dd>
<p>
Displays the default reset configuration (evaluated when <code>reset</code> is
found in a configuration file, or when an error is caught by
<code>catch-quit</code>).
</p>
</dd>
<dt><samp>toplevel</samp></dt>
<dd>
<p>
Displays the top-level default configuration (the configuration data, evaluated
by the server, which calls all the other configuration files).
</p>
</dd>
<dt><samp>override</samp></dt>
<dd>
<p>
Displays the top-level override configuration (the configuration data,
evaluated by the server, which causes all the other configuration data to be
parsed).
</p>
</dd>
<dt><samp>help</samp></dt>
<dd>
<p>
Displays a list of the understood builtin service names and arguments.
</p>
</dd>
</dl>

<p>
In the future other builtin services may be defined which do more than just
print information.
</p>
</dd>
</dl>
<dl>
<dt><samp>set-environment</samp></dt>
<dt><samp>no-set-environment</samp></dt>
<dd>
<p>
Runs <samp>/etc/environment</samp> to set the service user's environment.  This
adds the overhead of invoking a shell, but doesn't cause any shell (de)mangling
of the service's arguments.  This is achieved by invoking
</p>

<pre>
     .../program arg arg arg ...
</pre>

<p>
as
</p>

<pre>
     /bin/sh -c '. /etc/environment; exec &quot;$@&quot;' - .../program arg arg arg ...
</pre>

<p>
<code>no-set-environment</code> cancels the effect of
<code>set-environment</code>.
</p>
</dd>
</dl>
<dl>
<dt><samp>no-suppress-args</samp></dt>
<dt><samp>suppress-args</samp></dt>
<dd>
<p>
Include any arguments given to the client as arguments to the program invoked
as a result of an <code>execute</code>, <code>execute-from-directory</code> or
<code>execute-from-path</code> directive.  <code>suppress-args</code> undoes
the effect of <code>no-suppress-args</code>.
</p>
</dd>
</dl>
<dl>
<dt><samp>require-fd <var>fd-range</var> read|write</samp></dt>
<dd>
<p>
Insist that the filedescriptor(s) be opened for reading resp.  writing.  It is
an error if any descriptor marked as required when the service is about to be
invoked (after the configuration has been parsed) was not specified when the
client was invoked.  Each file descriptor has a separate setting, and the last
one of <code>require-fd</code>, <code>allow-fd</code>, <code>ignore-fd</code>,
<code>null-fd</code> or <code>reject-fd</code> which affected a particular file
descriptor will take effect.
</p>

<p>
<var>fd-range</var> may be a single number, two numbers separated by a hyphen,
or one number followed by a hyphen (indicating all descriptors from that number
onwards).  It may also be one of the words <samp>stdin</samp>,
<samp>stdout</samp> or <samp>stderr</samp>.  Open-ended file descriptor rangers
are allowed only with <code>reject-fd</code> and <code>ignore-fd</code>, as
otherwise the service program would find itself with a very large number of
file descriptors open.
</p>

<p>
When the configuration has been parsed, and before the service is about to be
executed, stderr (fd 2) must be required or allowed (<code>require-fd</code> or
<code>allow-fd</code>) for writing; this is so that the error message printed
by the server's child process if it cannot <code>exec</code> the service
program is not lost.
</p>
</dd>
</dl>
<dl>
<dt><samp>allow-fd <var>fd-range</var> [read|write]</samp></dt>
<dd>
<p>
Allow the descriptor(s) to be opened for reading resp.  writing, or either if
neither <samp>read</samp> nor <samp>write</samp> is specified.  If a particular
descriptor not specified by the client then it will be open onto
<samp>/dev/null</samp> (for reading, writing, or both, depending on whether
<samp>read</samp>, <samp>write</samp> or neither was specified).
</p>
</dd>
</dl>
<dl>
<dt><samp>null-fd <var>fd-range</var> [read|write]</samp></dt>
<dd>
<p>
Specify that the descriptor(s) be opened onto <code>/dev/null</code> for
reading resp.  writing, or both if neither <samp>read</samp> nor
<samp>write</samp> is specified.  Any specification of these file descriptors
by the client will be silently ignored; the client will see its ends of the
descriptors being closed immediately.
</p>
</dd>
</dl>
<dl>
<dt><samp>reject-fd <var>fd-range</var></samp></dt>
<dd>
<p>
Do not allow the descriptor(s) to be specified by the client.  It is an error
if any descriptor(s) marked for rejection are specified when the service is
about to be invoked (after the configuration has been parsed).
</p>
</dd>
</dl>
<dl>
<dt><samp>ignore-fd <var>fd-range</var></samp></dt>
<dd>
<p>
Silently ignore any specification by the client of those descriptor(s).  The
pipes corresponding to these descriptors will be closed just before the service
is invoked.
</p>
</dd>
</dl>
<dl>
<dt><samp>disconnect-hup</samp></dt>
<dt><samp>no-disconnect-hup</samp></dt>
<dd>
<p>
Causes the service's process group to get a <code>SIGHUP</code> if the client
disconnects before the main service process terminates.
<code>no-disconnect-hup</code> cancels <code>disconnect-hup</code>.
</p>

<p>
If one of the reading descriptors specified when the client is called gets a
read error, or if the service is disconnected for some other reason, then the
<code>SIGHUP</code> will be delivered <em>before</em> the writing end(s) of the
service's reading pipe(s) are closed, so that the client can distinguish
disconnection from reading EOF on a pipe.
</p>
</dd>
</dl>
<dl>
<dt><samp>reset</samp></dt>
<dd>
<p>
Resets the execution settings to the default.  This is equivalent to:
</p>

<pre>
     cd ~/
     reject
     no-set-environment
     suppress-args
     allow-fd 0 read
     allow-fd 1-2 write
     reject-fd 3-
     disconnect-hup
</pre>
</dd>
</dl>

<p>
If no <code>execute</code>, <code>execute-from-path</code>,
<code>execute-from-directory</code> or <code>builtin</code> is interpreted
before all the files are read then the request is rejected.
</p>

<hr>

<h2><a name="s-configerrors"></a>4.3 Errors in the configuration file</h2>

<p>
If a syntax error or other problem occurs when processing a configuration file
then a diagnostic will be issued, to wherever the error messages are currently
being sent (see the <code>errors-</code> family of directives, above).
</p>

<p>
The error will cause processing of the configuration files to cease at that
point, unless the error was inside a <code>catch-quit</code> construct.  In
this case the settings controlling the program's execution will be reset to the
defaults as if a <code>reset</code> directive had been issued, and parsing
continues after <code>hctac</code>.
</p>

<hr>

<h2><a name="s-defaults"></a>4.4 Defaults</h2>

<p>
The default configuration processing is as if the daemon were parsing an
overall configuration file whose contents were as follows:
</p>

<pre>
     reset
     user-rcfile ~/.userv/rc
     errors-to-stderr
     include /etc/userv/system.default
     if grep service-user-shell /etc/shells
        errors-push
          catch-quit
            include-ifexist <var>file specified by most recent user-rcfile directive</var>
          hctac
        srorre
     fi
     include /etc/userv/system.override
     quit
</pre>

<p>
If one of the <code>--override</code> options to the client is used then it
will instead be as if the daemon were parsing an overall configuration as
follows:
</p>

<pre>
     reset
     errors-to-stderr
     include <var>file containing configuration data sent by client</var>
     quit
</pre>

<hr>

<p>
[ <a href="ch-envir.html">previous</a> ]
[ <a href="index.html#contents">Contents</a> ]
[ <a href="ch-intro.html">1</a> ]
[ <a href="ch-client.html">2</a> ]
[ <a href="ch-envir.html">3</a> ]
[ 4 ]
[ <a href="ch-ipass.html">5</a> ]
[ <a href="ch-notes.html">6</a> ]
[ <a href="ch-ipass.html">next</a> ]
</p>

<hr>

<p>
User service daemon and client specification
</p>

<address>
1.1.1<br>
<br>
Ian Jackson <code><a href="mailto:ian@davenant.greenend.org.uk">ian@davenant.greenend.org.uk</a></code><br>
<br>
</address>
<hr>

</body>

</html>