auth.c (648B)
1 /* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */ 2 /* See COPYRIGHT */ 3 4 #include <u.h> 5 #include <libc.h> 6 #include <fcall.h> 7 #include <9pclient.h> 8 #include "fsimpl.h" 9 10 CFid* 11 fsauth(CFsys *fsys, char *uname, char *aname) 12 { 13 Fcall tx, rx; 14 void *freep; 15 CFid *afid; 16 17 if((afid = _fsgetfid(fsys)) == nil) 18 return nil; 19 20 tx.type = Tauth; 21 tx.afid = afid->fid; 22 tx.uname = uname; 23 tx.aname = aname; 24 25 if(_fsrpc(fsys, &tx, &rx, &freep) < 0){ 26 _fsputfid(afid); 27 return nil; 28 } 29 if(rx.type == Rerror){ 30 werrstr("%s", rx.ename); 31 free(freep); 32 _fsputfid(afid); 33 return nil; 34 } 35 afid->qid = rx.aqid; 36 free(freep); 37 return afid; 38 }