Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Nov 1998 11:20:25 -0000 (GMT)
From:      Duncan Barclay <dmlb@ragnet.demon.co.uk>
To:        "Brian J. McGovern" <mcgovern@spoon.beta.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   RE: PortalFS
Message-ID:  <XFMail.981122112025.dmlb@computer.my.domain>
In-Reply-To: <199811220148.UAA01381@spoon.beta.com>

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

On 22-Nov-98 Brian J. McGovern wrote:
> I'd be very interested in PortalFS. Problem is, I'm not an FS guru yet :)
> As a matter of fact, I don't think I've ever gotten PortalFS working quite
> right (maybe you could point out what I'm doing wrong...).
> 
> I take the portal config file from the mount_portal man page, stick it
> in /etc under portal.conf.
> 
> Then, I run mount_portal /etc/portal.conf /p
> 
> The mount command blocks, but then if I:
> 
>   int x;
>   x = open("/p/tcp/localhost/telnet",O_RDWR);
> 
>   x comes back as -1, with errno set (you'll have to excuse me, its been
> a long time since I tinkered).
> 
> However, as an end result, if you've got more portalfs tid-bits, and I can
> actually get the code working, I'd very much enjoy playing with it.
>       -Brian

I've checked my routines against 2.2.6 and current. Apart from some minor
Lite2 stuff everything hasn't changed.

The 2.x versions are all falling over sending the file descriptor back to the
kernel via a socket using sendmsg(2). I get 
Nov 22 11:07:54 computer portald[4459]: send: Invalid argument
in /var/log/messages

I will try and fix this today.

I have also written a tcplisten type which I submit too.

In the portal tcp code, sbin/mount_portal/pt_tcp.c, one can get a socket to a
reserved port by doing
        fd = open("/p/tcp/localhost/daytime/priv", O_RD);
In pt_tcp.c if a reserved port is asked for it does
        so = rresvport(...)
otherwise
        so = socket(...)
is used. My understanding of the use of the tcp portal is to open a
connection to a service already listening, so you don't need to use
rresvport. Is this a big hole? I have also thrown away root privs around
the connect.

diff -wur pt_tcp.c ncvs/c*               
@@ -126,6 +144,9 @@
        while (ipp[0]) {
                int so;
 
+               if (priv)
+                       so = rresvport((int *) 0);
+               else
                so = socket(AF_INET, SOCK_STREAM, 0);
                if (so < 0) {
                        syslog(LOG_ERR, "socket: %m");
@@ -133,13 +154,10 @@
                }
 
                sain.sin_addr = *ipp[0];
-               setuid (pcr->pcr_uid);
                if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
-                       setuid (geteuid ()); /* XXX getuid? */
                        *fdp = so;
                        return (0);
                }
-               setuid (geteuid ()); /* XXX getuid? */
                (void) close(so);
(+ is from current, - my code)

Which is right?

Duncan

---
________________________________________________________________________
Duncan Barclay          | God smiles upon the little children,
dmlb@ragnet.demon.co.uk | the alcoholics, and the permanently stoned.
________________________________________________________________________

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.981122112025.dmlb>