add fsamount, nsamount; use ndb for authdial; use explicit %#
diff --git a/src/libauth/fsamount.c b/src/libauth/fsamount.c
new file mode 100644
index 0000000..bece208
--- /dev/null
+++ b/src/libauth/fsamount.c
@@ -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;
+}
+
diff --git a/src/libauth/mkfile b/src/libauth/mkfile
index 2512e9c..5e5c13d 100644
--- a/src/libauth/mkfile
+++ b/src/libauth/mkfile
@@ -16,9 +16,11 @@
 	auth_rpc.$O\
 	auth_userpasswd.$O\
 	auth_wep.$O\
+	fsamount.$O\
 	login.$O\
 #	newns.$O\
 #	noworld.$O\
+	nsamount.$O\
 
 HFILES=\
 	$PLAN9/include/auth.h\
diff --git a/src/libauth/nsamount.c b/src/libauth/nsamount.c
new file mode 100644
index 0000000..1447904
--- /dev/null
+++ b/src/libauth/nsamount.c
@@ -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;
+}
+