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