Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Nov 1998 21:03:16 +0000
From:      dmlb@ragnet.demon.co.uk
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Cc:        dmlb@ragnet.demon.co.uk
Subject:   misc/8796: Addition to /usr/share/examples
Message-ID:  <E0zhgf6-0000N0-00@ragnet.demon.co.uk>

next in thread | raw e-mail | index | archive | help

>Number:         8796
>Category:       misc
>Synopsis:       Additional example directory for /usr/share
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 22 13:10:00 PST 1998
>Last-Modified:
>Originator:     Duncan Barclay
>Organization:
>Release:        FreeBSD 2.2.6-RELEASE i386
>Environment:

	Examples documenting how to play with the portal filesystem.

>Description:

>How-To-Repeat:

>Fix:
	
	Shar archive of /usr/share/examples/portal

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	portal
#	portal/portal.conf
#	portal/README
#
echo c - portal
mkdir -p portal > /dev/null 2>&1
echo x - portal/portal.conf
sed 's/^X//' >portal/portal.conf << 'END-of-portal/portal.conf'
Xtcp/		tcp tcp/
Xtcplisten/	tcplisten tcplisten/
Xfs/		file fs/
END-of-portal/portal.conf
echo x - portal/README
sed 's/^X//' >portal/README << 'END-of-portal/README'
X
XThis contains a couple of examples for using the portal filing system.
X
XThe portal file system provides a way of obtaining a file descriptor
Xto a filesystem object (i.e. something that is accessed by open(2),
Xpipe(2), socket(2) or socketpair(2)) via the filesystem namespace.
XAt present the only file descriptor supported are TCP sockets and
Xfiles.
X
XFirst off mount the filesystem using something like:
X
X# mount_portal /usr/share/examples/portal/portal.conf /p
X
XThen you should be able to do things like
X# cat /p/tcp/localhost/daytime
XSun Nov 22 17:50:09 1998
X(assuming inetd is running the daytime service, by default it is off)
X
XOr, how about this security hole
X# cat /p/fs/etc/motd
XFreeBSD 2.2.6-RELEASE (COMPUTER) #0: Sat Aug 22 17:11:37 BST 1998
X
XWelcome to FreeBSD!
X
X# mkdir -p /tmp/root
X# cd /tmp/root
X# mkdir bin p
X# cp /bin/sh /bin/cat bin
X# mount_portal /usr/share/examples/portal/portal.conf /tmp/root/p
X# chroot /tmp/root
X# pwd
X/
X# echo *
Xbin p
X# cat /etc/motd
Xcat: /etc/motd: No such file or directory
X# cat /p/fs/etc/motd
XFreeBSD 2.2.6-RELEASE (COMPUTER) #0: Sat Aug 22 17:11:37 BST 1998
X
XWelcome to FreeBSD!
X
XFinally, a very simple example of the listening server is available,
Xfire up two xterms. In the first 
X
Xxterm-1$ cat /p/tcplisten/ANY/6666
X(the ANY is a wildcard just like using INADDR_ANY, any resolvable host
Xcan be used).
X
XIn the second xterm
Xxterm-2$ echo "hello there" >/p/tcp/localhost/6666
X
XYou should see the "hello there" string appear on the first terminal.
X
XUnprivilged users can't create servers on privalged ports.
Xxterm-1$ cat /p/tcplisten/ANY/666         
Xcat: /p/tcplisten/ANY/666: Operation not permitted
X
Xbut root can
Xxterm-1# cat /p/tcplisten/ANY/666
X
XIn the second
Xxterm-2$ echo "hello there" >/p/tcp/localhost/666
Xshould produce the expected response.
X
XYou can also swap the client/server read and write commands etc.
END-of-portal/README
exit

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0zhgf6-0000N0-00>