factotum 14 KB

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