238 lines · 4.5 KB · Text
RawDownload
.TH AUTHSRV 2.SH NAMEauthdial, 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.Bint	authdial(char *netroot, char *ad);.PP.Bint	passtokey(char key[DESKEYLEN], char *password).PP.Buchar	nvcsum(void *mem, int len).PP.Bint	readnvram(Nvrsafe *nv, int flag);.PPP.Bint	convT2M(Ticket *t, char *msg, char *key).PP.Bvoid	convM2T(char *msg, Ticket *t, char *key).PP.Bint	convA2M(Authenticator *a, char *msg, char *key).PP.Bvoid	convM2A(char *msg, Authenticator *a, char *key).PP.Bint	convTR2M(Ticketreq *tr, char *msg).PP.Bvoid	convM2TR(char *msg, Ticketreq *tr).PP.Bint	convPR2M(Passwordreq *pr, char *msg, char *key).PP.Bvoid	convM2PR(char *msg, Passwordreq *pr, char *key).PP.Bint	_asgetticket(int fd, char *trbuf, char *tbuf);.PP.Bint	_asrdresp(int fd, char *buf, int len);.SH DESCRIPTION.I Authdialdials an authentication server over thenetwork rooted at.IR net ,default.BR /net  .The authentication domain,.IR ad ,specifies which server to call.If.I adis non-nil,the connection server.B cs(see.IR ndb (8))is queried for an entry which contains.B authdom=\fIad\fPor.BR dom=\fIad\fP ,the former having precedence,and which also contains an.B authattribute.If it finds neither, it tries.BI p9auth. adin DNS as the authentication server.The string dialed is then.I netroot\fP!\fIserver\fP!ticketwhere.I serveris the value of the.B authattribute.If no entry is found, the error string isset to ``no authentication server found''and -1 is returned.If.I authdomis nil, the string.IB netroot !$auth! ticketis used to make the call..PP.I Passtokeyconverts.I passwordinto a DES key and stores the result in.IR key .It returns 0 if.I passwordcould not be converted,and 1 otherwise..PP.I Readnvramreads authentication information into the structure:.PP.EX.ta 4n +4n +8n +4n +4n +4n +4nstruct Nvrsafe{	char	machkey[DESKEYLEN];	/* was file server's authid's des key */	uchar	machsum;	char	authkey[DESKEYLEN];	/* authid's des key from password */	uchar	authsum;	/*	 * file server config string of device holding full configuration;	 * secstore key on non-file-servers.	 */	char	config[CONFIGLEN];	uchar	configsum;	char	authid[ANAMELEN];	/* auth userid, e.g., bootes */	uchar	authidsum;	char	authdom[DOMLEN]; /* auth domain, e.g., cs.bell-labs.com */	uchar	authdomsum;};.EE.PPOn Sparc, MIPS, and SGI machines this information isin non-volatile ram, accessible in the file.BR #r/nvram .On x86s and Alphas.I readnvramsuccessively opens the following areas stopping with thefirst to succeed:.PP\- the partition named by the.B $nvramenvironment variable(commonly set via.IR plan9.ini (8)).br\- the partition.B #S/sdC0/nvram.br\- a file called.B plan9.nvrin the partition.B #S/sdC0/9fat.br\- the partition.B #S/sd00/nvram.br\- a file called.B plan9.nvrin the partition.B #S/sd00/9fat.br\- a file called.B plan9.nvron a DOS floppy in drive 0.br\- a file called.B plan9.nvron a DOS floppy in drive 1.PPThe.IR nvcsum sof the fields.BR machkey ,.BR authid ,and.B authdommust match their respective checksum or that field is zeroed.If.I flagis.B NVwriteor at least one checksum fails and.I flagis.BR NVwriteonerr ,.I readnvramwill prompt for new values on.B #c/consand then write them back to the storage area.If.I flagis.BR NVwritemem ,.I readnvramwill write the values in.I *nvback to the storage area..PP.IR ConvT2M ,.IR convA2M ,.IR convTR2M ,and.I convPR2Mconvert tickets, authenticators, ticket requests, and password change requeststructures into transmittable messages..IR ConvM2T ,.IR convM2A ,.IR convM2TR ,and.I convM2PRare used to convert them back..I Keyis used for encrypting the message before transmission and decryptingafter reception..PPThe routine.I _asgetrespreceives 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..PPThe routine.I _asgetticketsends a ticket request message and then uses.I _asgetrespto 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 DIAGNOSTICSThese routines set.IR errstr .Integer-valued functions return -1 on error.