]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/examples/portal/README
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / examples / portal / README
1 $FreeBSD$
2
3 This contains a couple of examples for using the portal filing system.
4
5 The portal file system provides a way of obtaining a file descriptor
6 to a filesystem object (i.e. something that is accessed by open(2),
7 pipe(2), socket(2) or socketpair(2)) via the filesystem namespace.
8 At present the only file descriptor supported are TCP sockets and
9 files.
10
11 NOTE!!!! The portal file system is experimental in nature and should
12 not be considered secure, use with caution.
13
14 First off mount the filesystem using something like:
15
16 # mount_portalfs /usr/share/examples/portal/portal.conf /p
17
18 Then you should be able to do things like
19 # cat /p/tcp/localhost/daytime
20 Sun Nov 22 17:50:09 1998
21 (assuming inetd is running the daytime service, by default it is off)
22
23 Welcome to FreeBSD!
24
25 # mkdir -p /tmp/root
26 # cd /tmp/root
27 # mkdir bin p
28 # cp /bin/sh /bin/cat bin
29 # mount_portalfs /usr/share/examples/portal/portal.conf /tmp/root/p
30 # chroot /tmp/root
31 # pwd
32 /
33 # echo *
34 bin p
35 # cat /etc/motd
36 cat: /etc/motd: No such file or directory
37 # cat /p/fs/etc/motd
38 FreeBSD 2.2.6-RELEASE (COMPUTER) #0: Sat Aug 22 17:11:37 BST 1998
39
40 Welcome to FreeBSD!
41
42 Finally, a very simple example of the listening server is available,
43 fire up two xterms. In the first
44
45 xterm-1$ cat /p/tcplisten/ANY/6666
46 (the ANY is a wildcard just like using INADDR_ANY, any resolvable host
47 can be used).
48
49 In the second xterm
50 xterm-2$ echo "hello there" >/p/tcp/localhost/6666
51
52 You should see the "hello there" string appear on the first terminal.
53
54 Unprivilged users can't create servers on privalged ports.
55 xterm-1$ cat /p/tcplisten/ANY/666
56 cat: /p/tcplisten/ANY/666: Operation not permitted
57
58 but root can
59 xterm-1# cat /p/tcplisten/ANY/666
60
61 In the second
62 xterm-2$ echo "hello there" >/p/tcp/localhost/666
63 should produce the expected response.
64
65 You can also swap the client/server read and write commands etc.