NameDateSize

..20-Dec-201637

portal.confH A D08-Mar-201584

READMEH A D08-Mar-20151.8 KiB

README

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