summaryrefslogtreecommitdiff
path: root/sys/src/cmd/unix/u9fs/authrhosts.c
blob: de150850e6442dffee7bb7436e2e190129516a93 (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
34
35
36
37
38
#include <plan9.h>
#include <fcall.h>
#include <u9fs.h>

/*
 * return whether the user is authenticated.
 * uses berkeley-style rhosts ``authentication''.
 * this is only a good idea behind a firewall,
 * where you trust your network, and even then
 * not such a great idea.  it's grandfathered.
 */

static char*
rhostsauth(Fcall *rx, Fcall *tx)
{
	USED(rx);
	USED(tx);

	return "u9fs rhostsauth: no authentication required";
}

static char*
rhostsattach(Fcall *rx, Fcall *tx)
{
	USED(tx);

	if(ruserok(remotehostname, 0, rx->uname, rx->uname) < 0){
		fprint(2, "ruserok(%s, %s) not okay\n", remotehostname, rx->uname);
		return "u9fs: rhosts authentication failed";
	}
	return 0;
}

Auth authrhosts = {
	"rhosts",
	rhostsauth,
	rhostsattach,
};