From owner-freebsd-hackers Sun Nov 22 04:31:02 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA06023 for freebsd-hackers-outgoing; Sun, 22 Nov 1998 04:31:02 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from post.mail.demon.net (post-11.mail.demon.net [194.217.242.40]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA06015 for ; Sun, 22 Nov 1998 04:30:58 -0800 (PST) (envelope-from dmlb@ragnet.demon.co.uk) Received: from [158.152.46.40] (helo=ragnet.demon.co.uk) by post.mail.demon.net with smtp (Exim 2.053 #1) id 0zhYem-0006zt-00; Sun, 22 Nov 1998 12:30:25 +0000 Received: from dmlb by ragnet.demon.co.uk with local (Exim 1.82 #1) id 0zhXZ3-0001En-00; Sun, 22 Nov 1998 11:20:25 +0000 Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <199811220148.UAA01381@spoon.beta.com> Date: Sun, 22 Nov 1998 11:20:25 -0000 (GMT) From: Duncan Barclay To: "Brian J. McGovern" Subject: RE: PortalFS Cc: freebsd-hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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