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