mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
add fsamount, nsamount; use ndb for authdial; use explicit %#
This commit is contained in:
parent
59518849d8
commit
42400cf81f
3 changed files with 68 additions and 0 deletions
33
src/libauth/fsamount.c
Normal file
33
src/libauth/fsamount.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <auth.h>
|
||||
#include <thread.h>
|
||||
#include <9pclient.h>
|
||||
#include "authlocal.h"
|
||||
|
||||
CFsys*
|
||||
fsamount(int fd, char *aname)
|
||||
{
|
||||
CFid *afid, *fid;
|
||||
AuthInfo *ai;
|
||||
CFsys *fs;
|
||||
|
||||
fs = fsinit(fd);
|
||||
if(fs == nil)
|
||||
return nil;
|
||||
if((afid = fsauth(fs, getuser(), aname)) == nil)
|
||||
goto noauth;
|
||||
ai = fsauth_proxy(afid, amount_getkey, "proto=p9any role=client");
|
||||
if(ai != nil)
|
||||
auth_freeAI(ai);
|
||||
noauth:
|
||||
fid = fsattach(fs, afid, getuser(), aname);
|
||||
fsclose(afid);
|
||||
if(fid == nil){
|
||||
_fsunmount(fs);
|
||||
return nil;
|
||||
}
|
||||
fssetroot(fs, fid);
|
||||
return fs;
|
||||
}
|
||||
|
|
@ -16,9 +16,11 @@ OFILES=\
|
|||
auth_rpc.$O\
|
||||
auth_userpasswd.$O\
|
||||
auth_wep.$O\
|
||||
fsamount.$O\
|
||||
login.$O\
|
||||
# newns.$O\
|
||||
# noworld.$O\
|
||||
nsamount.$O\
|
||||
|
||||
HFILES=\
|
||||
$PLAN9/include/auth.h\
|
||||
|
|
33
src/libauth/nsamount.c
Normal file
33
src/libauth/nsamount.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <auth.h>
|
||||
#include <thread.h>
|
||||
#include <9pclient.h>
|
||||
#include "authlocal.h"
|
||||
|
||||
CFsys*
|
||||
nsamount(char *name, char *aname)
|
||||
{
|
||||
CFid *afid, *fid;
|
||||
AuthInfo *ai;
|
||||
CFsys *fs;
|
||||
|
||||
fs = nsinit(name);
|
||||
if(fs == nil)
|
||||
return nil;
|
||||
if((afid = fsauth(fs, getuser(), aname)) == nil)
|
||||
goto noauth;
|
||||
ai = fsauth_proxy(afid, amount_getkey, "proto=p9any role=client");
|
||||
if(ai != nil)
|
||||
auth_freeAI(ai);
|
||||
noauth:
|
||||
fid = fsattach(fs, afid, getuser(), aname);
|
||||
fsclose(afid);
|
||||
if(fid == nil){
|
||||
_fsunmount(fs);
|
||||
return nil;
|
||||
}
|
||||
fssetroot(fs, fid);
|
||||
return fs;
|
||||
}
|
||||
|
Loading…
Reference in a new issue