plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

plan9.c (753B)


      1 #include "std.h"
      2 #include "dat.h"
      3 #include <bio.h>
      4 
      5 int
      6 memrandom(void *p, int n)
      7 {
      8 	uchar *cp;
      9 
     10 	for(cp = (uchar*)p; n > 0; n--)
     11 		*cp++ = fastrand();
     12 	return 0;
     13 }
     14 
     15 Attr*
     16 addcap(Attr *a, char *from, Ticket *t)
     17 {
     18 	return addattr(a, "cuid=%q suid=%q cap=''", t->cuid, t->suid);
     19 }
     20 
     21 int
     22 _authdial(char *net, char *authdom)
     23 {
     24 	return authdial(net, authdom);
     25 }
     26 
     27 Key*
     28 plan9authkey(Attr *a)
     29 {
     30 	char *dom;
     31 	Key *k;
     32 
     33 	/*
     34 	 * The only important part of a is dom.
     35 	 * We don't care, for example, about user name.
     36 	 */
     37 	dom = strfindattr(a, "dom");
     38 	if(dom)
     39 		k = keylookup("proto=p9sk1 role=server user? dom=%q", dom);
     40 	else
     41 		k = keylookup("proto=p9sk1 role=server user? dom?");
     42 	if(k == nil)
     43 		werrstr("could not find plan 9 auth key dom %q", dom);
     44 	return k;
     45 }