]> git.lizzy.rs Git - plan9front.git/blob - sys/man/4/factotum
libmp: add mpnrand() function to generate uniform random number 0 ≤ x < n
[plan9front.git] / sys / man / 4 / factotum
1 .TH FACTOTUM 4
2 .SH NAME
3 factotum, fgui, userpasswd \- authentication agent
4 .SH SYNOPSIS
5 .B auth/factotum
6 [
7 .B -DdknpuS
8 ] [
9 .B -a asaddr
10 ] [
11 .B -s
12 .I srvname
13 ] [
14 .B -m
15 .I mtpt
16 ]
17 .PP
18 .B auth/factotum
19 .B -g
20 .IB attribute = value
21 .B ...
22 .IB attribute ?
23 .B ...
24 .PP
25 .B auth/fgui
26 .PP
27 .B auth/userpasswd
28 .I fmt
29 .SH DESCRIPTION
30 .I Factotum
31 is a user-level file system that
32 acts as the authentication agent for a user.
33 It does so by managing a set of
34 .IR keys .
35 A key is a collection of information used to authenticate a particular action.
36 Stored as a list of
37 .IB attribute = value
38 pairs, a key typically contains a user, an authentication domain, a protocol, and
39 some secret data.
40 .PP
41 .I Factotum
42 presents a two level directory.  The first
43 level contains a single directory
44 .BR factotum ,
45 which in turn contains:
46 .TF needkey
47 .TP
48 .B rpc
49 each open represents a new private channel to
50 .I factotum
51 .TP
52 .B proto
53 when read lists the protocols available
54 .TP
55 .B confirm
56 for confiming the use of key
57 .TP
58 .B needkey
59 allows external programs to control the addition of new keys
60 .TP
61 .B log
62 a log of actions
63 .TP
64 .B ctl
65 for maintaining keys; when read, it returns a list of keys.
66 For secret attributes, only the attribute name follow by a
67 .L ?
68 is returned.
69 .PD
70 .PP
71 In any authentication, the caller typically acts as a client
72 and the callee as a server.  The server determines
73 the authentication domain, sometimes after a negotiation with
74 the client.  Authentication always requires the client to
75 prove its identity to the server.  Under some protocols, the
76 authentication is mutual.
77 Proof is accomplished using secret information kept by factotum
78 in conjunction with a cryptographic protocol.
79 .PP
80 .I Factotum
81 can act in the role of client for any process possessing the
82 same user id as it.  For select protocols such as
83 .B p9sk1
84 it can also act as a client for other processes provided
85 its user id may speak for the other process' user id (see
86 .IR authsrv (6)).
87 .I Factotum
88 can act in the role of server for any process.
89 .PP
90 .IR Factotum 's
91 structure is independent of
92 any particular authentication protocol.
93 .I Factotum
94 supports the following protocols:
95 .TF mschapv2
96 .TP
97 .B p9any
98 a metaprotocol used to negotiate which actual protocol to use.
99 .TP
100 .B p9sk1
101 a Plan 9 shared key protocol described in
102 .IR authsrv (6)'s
103 ``File Service'' section.
104 .TP
105 .B p9sk2
106 a variant of
107 .B p9sk1
108 described in
109 .IR authsrv (6)'s
110 ``Remote Execution'' section.
111 .TP
112 .B p9cr
113 a Plan 9 protocol that can use either
114 .B p9sk1
115 keys or SecureID tokens.
116 .TP
117 .B apop
118 the challenge/response protocol used by POP3 mail servers.
119 .TP
120 .B cram
121 the challenge/response protocol also used by POP3 mail servers.
122 .TP
123 .B chap
124 the challenge/response protocols used by PPP and PPTP.
125 .TP
126 .B mschap
127 a proprietary Microsoft challenge/response protocol also used by PPP, PPTP and CIFS.
128 .TP
129 .B mschapv2
130 version two of Microsofts challenge/response protocol used by WPA.
131 .TP
132 .B mschap2
133 Microsofts NTLMv2 challenge/response protocol used by CIFS.
134 .TP
135 .B rsa
136 RSA public key decryption, used by SSH and TLS.
137 .TP
138 .B pass
139 passwords in the clear.
140 .TP
141 .B vnc
142 .IR vnc (1)'s
143 challenge/response.
144 .TP
145 .B wep
146 WEP passwords for wireless ethernet cards.
147 .TP
148 .B wpapsk
149 WPA passwords for wireless ethernet cards.
150 .PD
151 .PP
152 The options are:
153 .TP
154 .B \-a
155 supplies the address of the authentication server to use.
156 Without this option, it will attempt to find an authentication server by
157 querying the connection server, the file
158 .BR <mtpt>/ndb ,
159 and finally the network database in
160 .BR /lib/ndb .
161 .TP
162 .B \-m
163 specifies the mount point to use, by default
164 .BR /mnt .
165 .TP
166 .B \-s
167 specifies the service name to use.
168 Without this option,
169 .I factotum
170 does not create a service file in
171 .BR /srv .
172 .TP
173 .B \-D
174 turns on 9P tracing, written to standard error.
175 .TP
176 .B \-d
177 turns on debugging, written to standard error.
178 .TP
179 .B \-g
180 causes the agent to prompt for the key, write it
181 to the
182 .B ctl
183 file, and exit.
184 The agent will prompt for values for any of the
185 attributes ending with a question mark
186 .RB ( ? )
187 and will append all the supplied
188 .I attribute = value
189 pairs.  See the section on key templates below.
190 .TP
191 .B \-n
192 don't look for a secstore.
193 .TP
194 .B \-S
195 indicates that the agent is running on a
196 CPU server.  On starting, it will attempt to get a
197 .B p9sk1
198 key from NVRAM using
199 .B readnvram
200 (see
201 .IR authsrv (2)),
202 prompting for anything it needs.
203 It will never subsequently prompt for a
204 key that it doesn't have.
205 This option is typically used by
206 the kernel at boot time.
207 .TP
208 .B \-k
209 causes the NVRAM to be written.
210 It is only valid with the
211 .B \-S
212 option.
213 This option is typically used by
214 the kernel at boot time.
215 .TP
216 .B \-u
217 causes the agent to prompt for user
218 id and writes it to
219 .BR /dev/hostowner .
220 It is mutually exclusive with
221 .B \-k
222 and
223 .BR \-S .
224 This option is typically used by
225 the kernel at boot time.
226 .TP
227 .B \-p
228 causes the agent not to mark itself `private'
229 via 
230 .IR proc (3),
231 so that it can be debugged.
232 It is implied by
233 .BR \-d .
234 .PD
235 .PP
236 .I Fgui
237 is a graphic user interface for confirming key usage and
238 entering new keys.  It hides the window in which it starts
239 and waits reading requests from
240 .B confirm
241 and
242 .BR needkey .
243 For each requests, it unhides itself and waits for
244 user input.
245 See the sections on key confirmation and key prompting below.
246 .PP
247 .I Userpasswd
248 queries and prints a cleartext user/password pair from factotum
249 for the
250 .B proto=pass
251 key tuple specified in
252 .IR fmt .
253 This can be used by shell scripts to do cleartext password
254 authentication.
255 .SS "Key Tuples
256 .PP
257 A
258 .I "key tuple
259 is a space delimited list of 
260 .IB attribute = value
261 pairs.  An attribute whose name begins with an exclamation point
262 .RB ( ! )
263 does not appear when reading the
264 .B ctl
265 file.
266 The required attributes depend on the authentication protocol.
267 .PP
268 .BR P9sk1 ,
269 .BR p9sk2 ,
270 and
271 .BR p9cr
272 all require a key with
273 .BR proto = p9sk1 ,
274 a
275 .B dom
276 attribute identifying the authentication domain, a
277 .B user
278 name valid in that domain, and either a
279 .B !password
280 or
281 .B !hex
282 attribute specifying the password or hexadecimal secret
283 to be used.  Here is an example:
284 .PP
285 .EX
286     proto=p9sk1 dom=avayalabs.com user=presotto !password=lucent
287 .EE
288 .PP
289 .BR Apop ,
290 .BR cram ,
291 .BR chap ,
292 and
293 .BR mschap ,
294 require a key with a
295 .B proto
296 attribute whose value matches the protocol,
297 in addition to
298 .BR server ,
299 .BR user ,
300 and
301 .B !password
302 attributes; 
303 e.g.
304 .PP
305 .EX
306     proto=apop server=mit.edu user=rsc !password=nerdsRus
307 .EE
308 Vnc is similar but does not require a
309 .B user
310 attribute.
311 .PP
312 .B Pass
313 requires a key with
314 .B proto=pass
315 in addition to
316 .B user
317 and
318 .B !password
319 attributes; e.g.
320 .PP
321 .EX
322     proto=pass user=tb !password=does.it.matter
323 .EE
324 .PP
325 .B Rsa
326 requires a key with
327 .B proto=rsa
328 in addition to all the hex attributes defining an RSA key:
329 .BR ek ,
330 .BR n ,
331 .BR !p ,
332 .BR !q ,
333 .BR !kp ,
334 .BR !kq ,
335 .BR !c2 ,
336 and
337 .BR !dk .
338 By convention, programs using the RSA protocol also require a
339 .B service
340 attribute set to
341 .BR ssh ,
342 .BR sshserve ,
343 or
344 .BR tls .
345 .PP
346 .B Wep
347 requires a
348 .BR key1 ,
349 .BR key2 ,
350 or
351 .BR key3
352 set to the password to be used.
353 Starting the protocol causes
354 .I factotum
355 to configure the wireless ethernet card
356 .B #l/ether0
357 for WEP encryption with the given password.
358 .PP
359 All keys can have additional attributes that act either as comments
360 or as selectors to distinguish them in the
361 .IR auth (2)
362 library calls.
363 .PP
364 The factotum owner can use any key stored by factotum.
365 Any key may have one or more
366 .B owner
367 attributes listing the users who can use the key
368 as though they were the owner.
369 For example, the TLS and SSH host keys on a server
370 often have an attribute
371 .B owner=*
372 to allow any user (and in particular,
373 .LR none )
374 to run the TLS or SSH server-side protocol.
375 .PP
376 Any key may have a
377 .B role
378 attribute for restricting how it can be used.
379 If this attribute is missing, the key can be used in any role.
380 The possible values are:
381 .TP
382 .B client
383 for authenticating outbound calls
384 .TP
385 .B server
386 for authenticating inbound calls
387 .TP
388 .B speakfor
389 for authenticating processes whose
390 user id does not match
391 .IR factotum 's.
392 .PP
393 If a key has a
394 .B disabled
395 attribute (with any value), the key is not used
396 during any protocols.  Factotum automatically marks
397 keys with
398 .B disabled=by.factotum
399 when they fail during certain authentication
400 protocols (in particular, the Plan 9 ones).
401 .PD
402 .PP
403 Whenever
404 .I factotum
405 runs as a server, it must have a
406 .B p9sk1
407 key in order to communicate with the authentication
408 server for validating passwords and challenge/responses of
409 other users.
410 .SS "Key Templates
411 Key templates are used by routines that interface to
412 .I factotum
413 such as
414 .B auth_proxy
415 and
416 .B auth_challenge
417 (see
418 .IR auth (2))
419 to specify which key and protocol to use for an authentication.
420 Like a key tuple, a key template is also a list of 
421 .IB attribute = value
422 pairs.
423 It must specify at least the protocol and enough
424 other attributes to uniquely identify a key, or set of keys, to use.
425 The keys chosen are those that match all the attributes specified
426 in the template.  The possible attribute/value formats are:
427 .TP 1i
428 .IB attr = val
429 The attribute
430 .I attr
431 must exist in the key and its value must exactly
432 match
433 .I val
434 .TP 1i
435 .IB attr ?
436 The attribute
437 .I attr
438 must exist in the key but its value doesn't matter.
439 .TP 1i
440 .I attr
441 The attribute
442 .I attr
443 must exist in the key with a null value
444 .PD
445 .PP
446 Key templates are also used by factotum to request a key either via
447 an RPC error or via the
448 .B needkey
449 interface.
450 The possible attribute/value formats are:
451 .TP 1i
452 .IB attr = val
453 This pair must remain unchanged
454 .TP 1i
455 .IB attr ?
456 This attribute needs a value
457 .TP 1i
458 .I attr
459 The pair must remain unchanged
460 .PD
461 .SS "Control and Key Management
462 .PP
463 A number of messages can be written to the control file.
464 The messages are:
465 .TP
466 .B "key \fIattribute-value-list\fP
467 add a new key.  This will replace any old key whose
468 public, i.e. non ! attributes, match.
469 .TP
470 .B "delkey \fIattribute-value-list\fP
471 delete a key whose attributes match those given.
472 .TP
473 .B debug
474 toggle debugging on and off, i.e., the debugging also
475 turned on by the
476 .B \-d
477 option.
478 .PP
479 By default when factotum starts it looks for a
480 .IR secstore (1)
481 account on $auth for the user and, if one exists,
482 prompts for a secstore password in order to fetch
483 the file
484 .IR factotum ,
485 which should contain control file commands.
486 An example would be
487 .EX
488   key dom=x.com proto=p9sk1 user=boyd !hex=26E522ADE2BBB2A229
489   key proto=rsa service=ssh size=1024 ek=3B !dk=...
490 .EE
491 where the first line sets a password for
492 challenge/response authentication, strong against dictionary
493 attack by being a long random string, and the second line
494 sets a public/private keypair for ssh authentication,
495 generated by
496 .B ssh_genkey
497 (see
498 .IR ssh (1)).
499 .PD
500 .SS "Confirming key use
501 .PP
502 The 
503 .B confirm
504 file provides a connection from
505 .I factotum
506 to a confirmation server, normally the program
507 .IR auth/fgui .
508 Whenever a key with the
509 .B confirm
510 attribute is used, 
511 .I factotum
512 requires confirmation of its use.  If no process has
513 .B confirm
514 opened, use of the key will be denied.
515 However, if the file is opened a request can be read from it
516 with the following format:
517 .PP
518 .B confirm
519 .BI tag= tagno
520 .I "<key template>
521 .PP
522 The reply, written back to
523 .BR confirm ,
524 consists of string:
525 .PP
526 .BI tag= tagno
527 .BI answer= xxx
528 .PP
529 If
530 .I xxx
531 is the string
532 .B yes
533 then the use is confirmed and the authentication will proceed.
534 Otherwise, it fails.
535 .PP
536 .B Confirm
537 is exclusive open and can only be opened by a process with
538 the same user id as
539 .IR factotum .
540 .SS "Prompting for keys
541 .PP
542 The 
543 .B needkey
544 file provides a connection from
545 .I factotum
546 to a key server, normally the program
547 .IR auth/fgui .
548 Whenever
549 .I factotum
550 needs a new key, it first checks to see if
551 .B needkey
552 is opened.  If it isn't, it returns a error to its client.
553 If the file is opened a request can be read from it
554 with the following format:
555 .PP
556 .B needkey
557 .BI tag= tagno
558 .I "<key template>
559 .PP
560 It is up to the reader to then query the user for any missing fields,
561 write the key tuple into the
562 .B ctl
563 file, and then reply by writing into the
564 .B needkey
565 file the string:
566 .PP
567 .BI tag= tagno
568 .PP
569 .B Needkey
570 is exclusive open and can only be opened by a process with
571 the same user id as
572 .IR factotum .
573 .SS "The RPC Protocol
574 Authentication is performed by
575 .IP 1)
576 opening
577 .BR rpc
578 .IP 2)
579 setting up the protocol and key to be used (see the
580 .B start
581 RPC below),
582 .IP 3)
583 shuttling messages back and forth between
584 .IR factotum
585 and the other party (see the
586 .B read
587 and
588 .B write
589 RPC's) until done
590 .IP 4)
591 if successful, reading back an
592 .I AuthInfo
593 structure (see
594 .IR authsrv (2)).
595 .PP
596 The RPC protocol is normally embodied by one of the
597 routines in
598 .IR auth (2).
599 We describe it here should anyone want to extend
600 the library.
601 .PP
602 An RPC consists of writing a request message to
603 .B rpc
604 followed by reading a reply message back.
605 RPC's are strictly ordered; requests and replies of
606 different RPC's cannot be interleaved.
607 Messages consist of a verb, a single space, and data.
608 The data format depends on the verb.  The request verbs are:
609 .TP
610 .B "start \fIattribute-value-list\fP
611 start a new authentication.
612 .I Attribute-value-pair-list
613 must include a
614 .B proto
615 attribute, a
616 .B role
617 attribute with value
618 .B client
619 or
620 .BR server ,
621 and enough other attributes to uniquely identify a key to use.
622 A
623 .B start
624 RPC is required before any others.    The possible replies are:
625 .RS
626 .TP
627 .B ok
628 start succeeded.
629 .TP
630 .B "error \fIstring\fP
631 where
632 .I string
633 is the reason.
634 .RE
635 .PD
636 .TP
637 .B read
638 get data from
639 .I factotum
640 to send to the other party.  The possible replies are:
641 .RS
642 .TP
643 .B ok
644 read succeeded, this is zero length message.
645 .TP
646 .B "ok \fIdata\fP
647 read succeeded, the data follows the space and is
648 unformatted.
649 .TP
650 .B "done
651 authentication has succeeded, no further RPC's are
652 necessary
653 .TP
654 .B "done haveai
655 authentication has succeeded, an
656 .B AuthInfo
657 structure (see
658 .IR auth (2))
659 can be retrieved with an
660 .B authinfo
661 RPC
662 .TP
663 .B "phase \fIstring\fP
664 its not your turn to read, get some data from
665 the other party and return it with a write RPC.
666 .TP
667 .B "error \fIstring\fP
668 authentication failed,
669 .I string
670 is the reason.
671 .TP
672 .B "protocol not started
673 a
674 .B start
675 RPC needs to precede reads and writes
676 .TP
677 .B "needkey \fIattribute-value-list\fP
678 a key matching the argument is needed.  This argument
679 may be passed as an argument to
680 .I factotum
681 .B -g
682 in order to prompt for a key.  After that, the
683 authentication may proceed, i.e., the read restarted.
684 .PD
685 .RE
686 .TP
687 .B "write \fIdata\fP
688 send data from the other party to
689 .IR factotum .
690 The possible replies are:
691 .RS
692 .TP
693 .B "ok
694 the write succeeded
695 .TP
696 .B "needkey \fIattribute-value-list\fP
697 see above
698 .TP
699 .B "toosmall \fIn\fP
700 the write is too short, get more data from the
701 other party and retry the write.
702 .I n
703 specifies the maximun total number of bytes.
704 .TP
705 .B "phase \fIstring\fP
706 its not your turn to write, get some data from
707 .I factotum
708 first.
709 .TP
710 .B "done
711 see above
712 .TP
713 .B "done haveai
714 see above
715 .RE
716 .TP
717 .B authinfo
718 retrieve the AuthInfo structure.  
719 The possible replies are:
720 .RS
721 .TP
722 .B "ok \fIdata\fP
723 .I data
724 is a marshaled form of the AuthInfo structure.
725 .TP
726 .B "error \fIstring\fP
727 where
728 .I string
729 is the reason for the error.
730 .PD
731 .RE
732 .TP
733 .B attr
734 retrieve the attributes used in the
735 .B start
736 RPC.
737 The possible replies are:
738 .RS
739 .TP
740 .B "ok \fIattribute-value-list\fP
741 .TP
742 .B "error \fIstring\fP
743 where
744 .I string
745 is the reason for the error.
746 .PD
747 .RE
748 .SH SOURCE
749 .B /sys/src/cmd/auth/factotum