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