Exemplo n.º 1
0
AuthInfo*
auth_proxy(int fd, AuthGetkey *getkey, char *fmt, ...)
{
	int afd;
	char *p;
	va_list arg;
	AuthInfo *ai;
	AuthRpc *rpc;

	quotefmtinstall();	/* just in case */
	va_start(arg, fmt);
	p = vsmprint(fmt, arg);
	va_end(arg);

	afd = open("/mnt/factotum/rpc", ORDWR);
	if(afd < 0){
		werrstr("opening /mnt/factotum/rpc: %r");
		free(p);
		return nil;
	}

	rpc = auth_allocrpc(afd);
	if(rpc == nil){
		free(p);
		return nil;
	}

	ai = fauth_proxy(fd, rpc, getkey, p);
	free(p);
	auth_freerpc(rpc);
	close(afd);
	return ai;
}
Exemplo n.º 2
0
AuthInfo*
auth_proxy(FFid *f, AuthGetkey *getkey, char *fmt, ...)
{
	int afd;
	char *p, *ftm, *rpcpath;
	va_list arg;
	AuthInfo *ai;
	AuthRpc *rpc;

	va_start(arg, fmt);
	vasprintf(&p, fmt, arg);
	va_end(arg);

	ai = nil;
	ftm = getenv("FACTOTUM");
	asprintf(&rpcpath, "%s/rpc", ftm);
	afd = open(rpcpath, ORDWR);
	if(afd < 0){
		free(p);
		free(rpcpath);
		return nil;
	}

	rpc = auth_allocrpc(afd);
	if(rpc){
		ai = fauth_proxy(f, rpc, getkey, p);
		auth_freerpc(rpc);
	}
	close(afd);
	free(p);
	free(rpcpath);
	return ai;
}
Exemplo n.º 3
0
static int
famount(int fd, AuthRpc *rpc, char *mntpt, int flags, char *aname)
{
	int afd;
	AuthInfo *ai;
	int ret;

	afd = fauth(fd, aname);
	if(afd >= 0){
		ai = fauth_proxy(afd, rpc, amount_getkey, "proto=p9any role=client");
		if(ai != nil)
			auth_freeAI(ai);
	}
	ret = mount(fd, afd, mntpt, flags, aname);
	if(afd >= 0)
		close(afd);
	return ret;
}
Exemplo n.º 4
0
AuthInfo*
auth_proxy(int fd, AuthGetkey *getkey, char *fmt, ...)
{
	char *p;
	va_list arg;
	AuthInfo *ai;
	AuthRpc *rpc;

	quotefmtinstall();	/* just in case */
	va_start(arg, fmt);
	p = vsmprint(fmt, arg);
	va_end(arg);

	rpc = auth_allocrpc();
	if(rpc == nil){
		free(p);
		return nil;
	}

	ai = fauth_proxy(fd, rpc, getkey, p);
	free(p);
	auth_freerpc(rpc);
	return ai;
}