chiark / gitweb /
@@ -1,3 +1,9 @@
[userv.git] / userv.1
1 .\"
2 .\" This manpage is copyright, like the rest of userv, - see the
3 .\" copyright section, below.
4 .Dd November 3, 1999
5 .Dt USERV 1
6 .Os "userv 1.0.0"
7 .Sh NAME
8 .Nm userv
9 .Nd request user services
10 .Sh SYNOPSIS
11 .Nm userv
12 .Op Ar option ...
13 .Op Fl -
14 .Ar service-user
15 .Ar service-name
16 .Op Ar argument ...
17 .Nm userv
18 .Op Ar option ...
19 .Fl B | -builtin
20 .Op Fl -
21 .Ar builtin-service
22 .Bk -words
23 .Op Ar info-argument ...
24 .Ek
25 .Sh DESCRIPTION
26 .Nm userv
27 is used to have a task performed under different userid while
28 maintaining limited trust between caller and callee.
29
30 .Ar service-user
31 specifies which user account is to perform the task.  The user may be
32 a login name or a numeric uid, or
33 .Ql -
34 to indicate that the service user is to be the same as the calling
35 user.
36
37 The service name is interpreted by the userv daemon on behalf of the
38 service user.  This is controlled by configuration files in the
39 service user's filespace; consult the userv specification for details.
40 .Ss Options
41 Single-letter options may be combined as is usual with Unix programs,
42 and the value for such an option may appear in the same argument or in
43 the next.
44 .Bl -tag -width Fl
45 .It Fl B | -builtin
46 Requests that a builtin service be provided.  This is equivalent to
47 using the
48 .Fl -override
49 option to specify a string consisting of
50 .Ql execute-builtin
51 followed by the
52 .Ar builtin-service
53 requested, and requesting a service user of 
54 .Ql -
55 (indicating the calling user).
56
57 If the builtin service being requested requires a
58 .Ar service-argument
59 then this must be supplied to the client in the
60 same argument as the
61 .Ar builtin-service .
62 See the specification, or the output of
63 .Bd -literal -offset indent -compact
64 userv -B help
65 .Ed
66 for details of the builtin services available,
67 and below for details of the
68 .Fl -override
69 options.
70
71 The actual service name passed will be the
72 .Ar builtin-service ;
73 note
74 that this actual service name (as opposed to the override data) and
75 the
76 .Ar info-argument Ns s
77 supplied will be ignored by most builtin
78 services; the override mechanism and
79 .Ql execute-builtin
80 will be
81 used to ensure that the right builtin service is called with the right
82 .Ar service-argument Ns s .
83 .It Xo
84 .Fl f | -file
85 .Sm off
86 .Ar fd Oo Ar fdmodifiers Oc = Ar filename
87 .Sm on
88 .Xc
89 Requests that data be copied in and out of the service using pipes.
90 For each file or descriptor this will be done by creating a pipe, one
91 end of which is passed to the service program and the other end of
92 which is passed to a copy of
93 .Nm cat
94 invoked by the client; the other file descriptor passed to
95 .Nm cat
96 will be one inherited by the client program from the caller or one
97 opened by the client program on behalf of the caller.
98
99 The descriptor in the service program that should be connected must be
100 specified as
101 .Ar fd ,
102 either as a decimal number or as one of the
103 strings
104 .Ql stdin ,
105 .Ql stdout
106 or
107 .Ql stderr .
108 The next argument is a filename which will be opened by the client
109 with the privileges of the calling user.
110
111 .Ar modifiers
112 is used to specify whether the file or descriptor is to be read from
113 or written to.  It consists of a series of words separated by commas.
114 A comma may separate the
115 .Ar modifiers
116 from
117 the
118 .Ar fd
119 and is required if
120 .Ar fd
121 is not numeric.
122 The modifier words are:
123 .Bl -tag -width Li
124 .It Ic read
125 .Dv O_RDONLY :
126 Allow reading and not writing.  May not be used with
127 .Ql write
128 or things that imply it.
129 .It Ic write
130 .Dv O_WRONLY :
131 Allow writing and not reading.
132 .Em Doesn't truncate or create
133 without
134 .Ql truncate
135 or
136 .Ql create .
137 .Ql write
138 or things that imply it may not be used with
139 .Ql read .
140 .It Ic overwrite
141 Equivalent to
142 .Ql write,create,truncate .
143 .It Ic create ,  creat
144 .Dv O_CREAT :
145 Creates the file if necessary.  Implies
146 .Ql write .
147 .It Ic exclusive , excl
148 .Dv O_TRUNC:
149 Truncate any existing file.  Implies
150 .Ql write .
151 May not be used with
152 .Ql exclusive .
153 .It Ic append
154 .Dv O_APPEND :
155 All writes will append to the file.  Implies
156 .Ql write
157 (but not
158 .Ql create ) .
159 .It Ic sync
160 .Dv O_SYNC :
161 Do writes synchronously.  Implies
162 .Ql write .
163 .It Ic wait , nowait , close
164 These modifiers control the behaviour of the client, with respect to
165 the pipes carrying data to and from the service, when the service
166 terminates.  See below.
167 .It Ic fd
168 The
169 .Ar filename
170 is not a filename but a numeric file descriptor.
171 One or both of
172 .Ql read
173 and
174 .Ql write
175 must be specified, and no
176 other words are allowed.  The
177 .Ar filename
178 may also be
179 .Ql stdin ,
180 .Ql stdout
181 or
182 .Ql stderr
183 for file descriptor 0, 1 or 2 respectively.
184 .El
185
186 If no
187 .Ar modifiers
188 which imply
189 .Ql read
190 or
191 .Ql write
192 are used it is as if
193 .Ql write
194 had been specified, except that if the filedescriptor 0 of the service
195 is being opened (either specified numerically or with
196 .Ql stdin )
197 it is as if
198 .Ql overwrite
199 had been specified (or
200 .Ql write
201 if only
202 .Ql fd
203 was specified).
204
205 The client will also use
206 .Dv O_NOCTTY
207 when opening files specified by the caller, to avoid changing its
208 controlling terminal.
209
210 By default
211 .Va stdin ,
212 .Va stdout
213 and
214 .Va stderr
215 of the service will be connected to the corresponding descriptors on
216 the client.  Diagnostics from the client and daemon will also appear
217 on
218 .Va stderr .
219
220 If
221 .Ql wait
222 is specified, the client will wait for the pipe to be closed, and only
223 exit after this has happened.  This means that either the receiving
224 end of the pipe connection was closed while data was still available
225 at the sending end, or that the end of file was reached on the reading
226 file descriptor.  Errors encountered reading or writing in the client
227 at this stage will be considered a system error and cause the client
228 to exit with status 255, but will not cause disconnection at the
229 service side since the service has already exited.
230
231 If
232 .Ql close
233 is specified the client will immediately close the pipe connection by
234 killing the relevant copy of
235 .Nm cat .
236 If the service uses the descriptor it will get
237 .Dv SIGPIPE
238 (or
239 .Er EPIPE )
240 for a writing descriptor or end of file for a reading one; the
241 descriptor opened by or passed to the client will also be closed.
242
243 If
244 .Ql nowait
245 is specified then the client will not wait and the
246 connection will remain open after the client terminates.  Data may
247 continue to be passed between the inheritors of the relevant
248 descriptor on the service side and the corresponding file or
249 descriptor on the client side until either side closes their
250 descriptor.  This should not usually be specified for
251 .Va stderr
252 (or
253 .Va stdout
254 if
255 .Ql "--signals stdout"
256 is used) since diagnostics from the service side may arrive after the
257 client has exited and be confused with expected output.
258
259 The default is
260 .Ql wait
261 for writing file descriptors and
262 .Ql close
263 for reading ones.
264 .It Xo
265 .Fl w | -fdwait
266 .Ar fd Ns = Ns Ar action
267 .Xc
268 Sets the action on termination of the service for the specified file
269 descriptor;
270 .Ar action
271 must be
272 .Ql wait ,
273 .Ql nowait
274 or
275 .Ql close
276 as described above.  The file descriptor must be specified as open
277 when this option is encountered; this option is overridden by any
278 later
279 .Fl -file
280 or
281 .Fl -fdwait
282 option - even by a
283 .Fl -file
284 which does not specify an action on termination (in this case the
285 default will be used, as described above).
286 .It Xo
287 .Fl D | -defvar
288 .Ar name Ns = Ns Ar value
289 .Xc
290 Set a user-defined variable
291 .Ar name
292 to
293 .Ar value .
294 These
295 user-defined variables are made available in the configuration
296 language as the parameters
297 .Ql u- Ns Ar name
298 and are passed to the
299 service in environment variables
300 .Ev USERV_U_ Ns Ar name .
301 .Ar name
302 may contain only alphanumerics and underscores, and must start with a
303 letter.  If several definitions are given for the same
304 .Ar name
305 then only the last is effective.
306 .It Fl t | -timeout Ar seconds
307 Time out the service if it takes longer than
308 .Ar seconds
309 seconds (a positive integer, in decimal).  Timeout will produce a
310 diagnostic on stderr and an exit status of 255.  If
311 .Ar seconds
312 is zero then no timeout will be implemented (this is the default).
313 .It Fl S | -signals Ar method
314 Affects the handling of the exit status when the service terminates
315 due to a signal.  (The client will always finish by calling
316 .Fn _exit ,
317 so that only numbers from 0 to 255 can be returned and not the full
318 range of numbers and signal indications which can be returned by the
319 .Fn wait
320 family of system calls.)
321
322 The
323 .Ar method
324 may be one of the following:
325 .Bl -tag -width Li
326 .It Ar status
327 The client's exit status will be
328 .Ar status .
329 This will not be distinguishable from the service really having exited
330 with code
331 .Ar status .
332 This method is the default, with a
333 .Ar status
334 of 254.
335 .It Ic number , number-nocore
336 The client's exit status will be the number of the signal which caused
337 the termination of the service.  If
338 .Ql number
339 is used rather than
340 .Ql number-nocore
341 then 128 will be added if the service dumped core.
342 .Ql number
343 is very like the exit code mangling done by the Bourne shell.
344 .It Ic highbit
345 The client's exit status will be the number of the signal with 128
346 added.  If the service exits normally with an exit code of greater
347 than 127 then 127 will be returned.
348 .It Ic stdout
349 The service's numeric wait status as two decimal numbers (high byte
350 first) and a textual description of its meaning will be printed to the
351 client's standard output.  It will be preceded by a newline and
352 followed by an extra newline, and the numbers are separated from each
353 other and from the textual description by single spaces.  The exit
354 status of the client will be zero, unless a system error occurs in
355 which case no exit status and description will be printed to
356 .Va stdout ,
357 and an error message will be printed to
358 .Va stderr
359 as usual.
360
361 Problems such as client usage errors, the service not being found or
362 permission being denied or failure of a system call are system errors.
363 An error message describing the problem will be printed on the
364 client's
365 .Va stderr ,
366 and the client's exit status will be 255.  If the client dies due to a
367 signal this should be treated as a serious system error.
368 .El
369 .It Fl H | -hidecwd
370 Prevents the calling process's current directory name from being
371 passed to the service; the null string will be passed instead.
372 .It Fl P | -sigpipe
373 If the service program is terminated due to a
374 .Dv SIGPIPE
375 the exit status of the client will be zero, even if it would have been
376 something else according to the exit status method specified.  This
377 option has no effect on the code and description printed if the exit
378 status method
379 .Ql stdout
380 is in use.
381 .It Fl h | -help
382 Prints the client's usage message.
383 .It Fl -copyright
384 Prints the copyright and lack of warranty notice.
385 .El
386 .Ss Security-overriding options
387 There are also some options which are available for debugging and to
388 allow the system administrator to override a user's policy.  These
389 options are available only if the client is called by root or if the
390 calling user is the same as the service user.
391 .Bl -tag -width Fl
392 .It Fl -override Ar configuration-data
393 .It Fl -override-file Ar file
394 Do not read the usual configuration files.  Instead, the client sends
395 .Ar configuration-data
396 (followed by a newline) or the contents of
397 .Ar filename
398 (which is opened in the context of the client) to the daemon and the
399 daemon uses that data instead.  The
400 .Ar configuration-data
401 must all be in one argument.  It will have a single newline appended
402 so that a single directive can easily be given, but if more than one
403 directive is required it will have to contain one or more real
404 newlines.
405 .It Fl -spoof-user Ar user
406 Pretend to the service that it is being called by
407 .Ar user
408 (which may be a username or a uid).  This will also affect the group
409 and supplementary groups supplied to the service; they will be the
410 standard group and supplementary groups for
411 .Ar user .
412 The
413 .Fl -spoof-user
414 option will
415 .Em not
416 affect which user is chosen if the service user is specified as just
417 .Ql - ;
418 in this case the service user will be the real calling user.
419 .El
420 .Sh ENVIRONMENT
421 .Bl -tag -width Ev
422 .It Ev LOGNAME , USER
423 These are used to determine the name of the calling user, to be passed
424 to the service in
425 .Ev USERV_USER .
426 Their values will only be used if they correspond to the calling UID.
427 .Sh FILES
428 .Bl -tag -width Pa
429 .It Pa /var/run/userv/socket
430 .Ux Ns -domain
431 socket used for communication between
432 .Nm
433 and
434 .Nm uservd .
435 .It Pa /var/run/userv/%x.%x.%x
436 Pipes used for connecting file descriptors in the client and the
437 service.
438 .El
439 .Sh SEE ALSO
440 .Xr uservd 8
441 .Rs
442 .%T "User service daemon and client specification"
443 .%A Ian Jackson
444 .Re
445 .Sh COPYRIGHT
446 GNU userv is Copyright (C)1996-2000 Ian Jackson, except that this
447 manpage is Copyright (C)2000 Ben Harris.
448
449 GNU userv is licensed under the terms of the GNU General Public
450 Licence, version 2 or (at your option) any later version, and it comes
451 with NO WARRANTY, not even the implied warranty of MERCHANTABILITY or
452 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
453 for details.
454
455 You should have received a copy of the GNU General Public License
456 along with userv, if not, write to the Free Software Foundation, 59
457 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
458 .Sh HISTORY
459 .Nm
460 was initially written in 1996 by Ian Jackson.  It became
461 .Tn GNU
462 .Nm
463 in 1999, and version 1.0 was released in 2000.