aboutsummaryrefslogtreecommitdiff
path: root/src/libauth/fsamount.c
blob: bece208a305d138dab08ab0d1d4c5026fa3acc2f (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
#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;
}