authsrv 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. .TH AUTHSRV 2
  2. .SH NAME
  3. authdial, passtokey, nvcsum, readnvram, convT2M, convM2T, convTR2M, convM2TR, convA2M, convM2A, convPR2M, convM2PR, _asgetticket, _asrdresp \- routines for communicating with authentication servers
  4. .SH SYNOPSIS
  5. .nf
  6. .PP
  7. .ft L
  8. #include <u.h>
  9. #include <libc.h>
  10. #include <authsrv.h>
  11. .fi
  12. .ta 8n +4n +4n +4n +4n +4n +4n
  13. .PP
  14. .B
  15. int authdial(char *netroot, char *ad);
  16. .PP
  17. .B
  18. int passtokey(char key[DESKEYLEN], char *password)
  19. .PP
  20. .B
  21. uchar nvcsum(void *mem, int len)
  22. .PP
  23. .B
  24. int readnvram(Nvrsafe *nv, int flag);
  25. .PPP
  26. .B
  27. int convT2M(Ticket *t, char *msg, char *key)
  28. .PP
  29. .B
  30. void convM2T(char *msg, Ticket *t, char *key)
  31. .PP
  32. .B
  33. int convA2M(Authenticator *a, char *msg, char *key)
  34. .PP
  35. .B
  36. void convM2A(char *msg, Authenticator *a, char *key)
  37. .PP
  38. .B
  39. int convTR2M(Ticketreq *tr, char *msg)
  40. .PP
  41. .B
  42. void convM2TR(char *msg, Ticketreq *tr)
  43. .PP
  44. .B
  45. int convPR2M(Passwordreq *pr, char *msg, char *key)
  46. .PP
  47. .B
  48. void convM2PR(char *msg, Passwordreq *pr, char *key)
  49. .PP
  50. .B
  51. int _asgetticket(int fd, char *trbuf, char *tbuf);
  52. .PP
  53. .B
  54. int _asrdresp(int fd, char *buf, int len);
  55. .SH DESCRIPTION
  56. .PP
  57. .I Authdial
  58. dials an authentication server over the
  59. network rooted at
  60. .IR net ,
  61. default
  62. .BR /net .
  63. The authentication domain,
  64. .IR ad ,
  65. specifies which server to call.
  66. If
  67. .I ad
  68. is non-nil,
  69. the connection server
  70. .B cs
  71. (see
  72. .IR ndb (8))
  73. is queried for an entry which contains
  74. .B authdom=\fIad\fP
  75. or
  76. .BR dom=\fIad\fP ,
  77. the former having precedence,
  78. and which also contains an
  79. .B auth
  80. attribute.
  81. The string dialed is then
  82. .I netroot\fP!\fIserver\fP!ticket
  83. where
  84. .I server
  85. is the value of the
  86. .B auth
  87. attribute.
  88. If no entry is found, the error string is
  89. set to ``no authentication server found''
  90. and -1 is returned.
  91. If
  92. .I authdom
  93. is nil, the string
  94. .IB netroot !$auth! ticket
  95. is used to make the call.
  96. .PP
  97. .I Passtokey
  98. converts
  99. .I password
  100. into a DES key and stores the result in
  101. .IR key .
  102. It returns 0 if
  103. .I password
  104. could not be converted,
  105. and 1 otherwise.
  106. .PP
  107. .I Readnvram
  108. reads authentication information into the structure:
  109. .PP
  110. .EX
  111. .ta 4n +4n +8n +4n +4n +4n +4n
  112. struct Nvrsafe
  113. {
  114. char machkey[DESKEYLEN]; /* was file server's authid's des key */
  115. uchar machsum;
  116. char authkey[DESKEYLEN]; /* authid's des key from password */
  117. uchar authsum;
  118. /*
  119. * file server config string of device holding full configuration;
  120. * secstore key on non-file-servers.
  121. */
  122. char config[CONFIGLEN];
  123. uchar configsum;
  124. char authid[ANAMELEN]; /* auth userid, e.g., bootes */
  125. uchar authidsum;
  126. char authdom[DOMLEN]; /* auth domain, e.g., cs.bell-labs.com */
  127. uchar authdomsum;
  128. };
  129. .EE
  130. .PP
  131. On Sparc, MIPS, and SGI machines this information is
  132. in non-volatile ram, accessible in the file
  133. .BR #r/nvram .
  134. On x86s and Alphas
  135. .I readnvram
  136. successively opens the following areas stopping with the
  137. first to succeed:
  138. .PP
  139. \- the partition named by the
  140. .B $nvram
  141. environment variable
  142. (commonly set via
  143. .IR plan9.ini (8))
  144. .br
  145. \- the partition
  146. .B #S/sdC0/nvram
  147. .br
  148. \- a file called
  149. .B plan9.nvr
  150. in the partition
  151. .B #S/sdC0/9fat
  152. .br
  153. \- the partition
  154. .B #S/sd00/nvram
  155. .br
  156. \- a file called
  157. .B plan9.nvr
  158. in the partition
  159. .B #S/sd00/9fat
  160. .br
  161. \- a file called
  162. .B plan9.nvr
  163. on a DOS floppy in drive 0
  164. .br
  165. \- a file called
  166. .B plan9.nvr
  167. on a DOS floppy in drive 1
  168. .PP
  169. The
  170. .IR nvcsum s
  171. of the fields
  172. .BR machkey ,
  173. .BR authid ,
  174. and
  175. .B authdom
  176. must match their respective checksum or that field is zeroed.
  177. If
  178. .I flag
  179. is
  180. .B NVwrite
  181. or at least one checksum fails and
  182. .I flag
  183. is
  184. .BR NVwriteonerr ,
  185. .I readnvram
  186. will prompt for new values on
  187. .B #c/cons
  188. and then write them back to the storage area.
  189. If
  190. .I flag
  191. is
  192. .BR NVwritemem ,
  193. .I readnvram
  194. will write the values in
  195. .I *nv
  196. back to the storage area.
  197. .PP
  198. .IR ConvT2M ,
  199. .IR convA2M ,
  200. .IR convTR2M ,
  201. and
  202. .I convPR2M
  203. convert tickets, authenticators, ticket requests, and password change request
  204. structures into transmittable messages.
  205. .IR ConvM2T ,
  206. .IR convM2A ,
  207. .IR convM2TR ,
  208. and
  209. .I convM2PR
  210. are used to convert them back.
  211. .I Key
  212. is used for encrypting the message before transmission and decrypting
  213. after reception.
  214. .PP
  215. The routine
  216. .I _asgetresp
  217. receives either a character array or an error string.
  218. On error, it sets errstr and returns -1. If successful,
  219. it returns the number of bytes received.
  220. .PP
  221. The routine
  222. .I _asgetticket
  223. sends a ticket request message and then uses
  224. .I _asgetresp
  225. to recieve an answer.
  226. .SH SOURCE
  227. .B /sys/src/libauthsrv
  228. .SH SEE ALSO
  229. .IR passwd (1),
  230. .IR cons (3),
  231. .IR dial (2),
  232. .IR authsrv (6),
  233. .SH DIAGNOSTICS
  234. These routines set
  235. .IR errstr .
  236. Integer-valued functions return -1 on error.