bye bye portal fs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bye bye portal fs

Thordur Bjornsson-2
not enabled, doesn't compile if enabled and generally
a bad idea.

OK?

Index: etc/changelist
===================================================================
RCS file: /var/cvs/src/etc/changelist,v
retrieving revision 1.71
diff -u -p -r1.71 changelist
--- etc/changelist 19 Jan 2011 18:34:58 -0000 1.71
+++ etc/changelist 4 Apr 2011 21:30:19 -0000
@@ -101,7 +101,6 @@
 /etc/pf.conf
 /etc/pf.os
 /etc/pkg.conf
-/etc/portal.conf
 /etc/printcap
 /etc/profile
 /etc/protocols
Index: sbin/Makefile
===================================================================
RCS file: /var/cvs/src/sbin/Makefile,v
retrieving revision 1.93
diff -u -p -r1.93 Makefile
--- sbin/Makefile 1 Nov 2010 05:25:49 -0000 1.93
+++ sbin/Makefile 4 Apr 2011 21:30:02 -0000
@@ -5,7 +5,7 @@ SUBDIR= atactl badsect bioctl ccdconfig
  fsck_msdos fsdb fsirand growfs ifconfig iked init iopctl ipsecctl  \
  isakmpd kbd ldattach lmccontrol mknod modload modunload mount \
  mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
- mount_nfs mount_ntfs mount_portal mount_procfs mount_udf \
+ mount_nfs mount_ntfs mount_procfs mount_udf \
  mount_vnd mount_nnpfs mountd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
  nfsd nologin pdisk pfctl pflogd ping ping6 quotacheck \
  raidctl reboot restore route rtsol savecore scan_ffs \
Index: sbin/mount_portal/Makefile
===================================================================
RCS file: sbin/mount_portal/Makefile
diff -N sbin/mount_portal/Makefile
--- sbin/mount_portal/Makefile 4 Jul 2001 06:32:18 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-# $OpenBSD: Makefile,v 1.7 1997/09/21 11:37:28 deraadt Exp $
-
-PROG= mount_portal
-SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
- pt_exec.c pt_file.c pt_tcp.c
-MAN= mount_portal.8
-MLINKS= mount_portal.8 portal.conf.5
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
-
-afterinstall:
- if [ ! -f ${DESTDIR}/etc/portal.conf ]; then \
- ${INSTALL} ${INSTALL_COPY} -o root -g wheel -m 644 \
-    ${.CURDIR}/portal.conf ${DESTDIR}/etc; \
- fi
Index: sbin/mount_portal/activate.c
===================================================================
RCS file: sbin/mount_portal/activate.c
diff -N sbin/mount_portal/activate.c
--- sbin/mount_portal/activate.c 24 Mar 2008 16:11:08 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,205 +0,0 @@
-/* $OpenBSD: activate.c,v 1.8 2008/03/15 16:19:02 deraadt Exp $ */
-/* $NetBSD: activate.c,v 1.5 1995/04/23 10:33:18 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: activate.c,v 1.2 1992/05/27 07:09:27 jsp Exp
- * @(#)activate.c 8.3 (Berkeley) 4/28/95
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/syslog.h>
-#include <sys/uio.h>
-
-#include "portald.h"
-
-/*
- * Scan the providers list and call the
- * appropriate function.
- */
-static int
-activate_argv(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
-{
- provider *pr;
-
- for (pr = providers; pr->pr_match; pr++)
- if (strcmp(v[0], pr->pr_match) == 0)
- return ((*pr->pr_func)(pcr, key, v, so, fdp));
-
- return (ENOENT);
-}
-
-static int
-get_request(int so, struct portal_cred *pcr, char *key, int klen)
-{
- struct iovec iov[2];
- struct msghdr msg;
- int n;
-
- iov[0].iov_base = (caddr_t)pcr;
- iov[0].iov_len = sizeof(*pcr);
- iov[1].iov_base = key;
- iov[1].iov_len = klen;
-
- (void)memset(&msg, 0, sizeof(msg));
- msg.msg_iov = iov;
- msg.msg_iovlen = 2;
-
- n = recvmsg(so, &msg, 0);
- if (n < 0)
- return (errno);
-
- if (n <= sizeof(*pcr))
- return (EINVAL);
-
- n -= sizeof(*pcr);
- key[n] = '\0';
-
- return (0);
-}
-
-static void
-send_reply(int so, int fd, int error)
-{
- int n;
- struct iovec iov;
- struct msghdr msg;
- struct cmsghdr *cmsg;
- struct {
- struct cmsghdr cmsg;
- u_char buf[CMSG_SPACE(sizeof(int))];
- } cmsgbuf;
-
- /*
- * Line up error code.  Don't worry about byte ordering
- * because we must be sending to the local machine.
- */
- iov.iov_base = (caddr_t)&error;
- iov.iov_len = sizeof(error);
-
- /*
- * Build a msghdr
- */
- (void)memset(&msg, 0, sizeof(msg));
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
-
- /*
- * If there is a file descriptor to send then
- * construct a suitable rights control message.
- */
- if (fd >= 0) {
- msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = sizeof(cmsgbuf.buf);
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_len = CMSG_LEN(sizeof(int));
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- *(int *)CMSG_DATA(cmsg) = fd;
- }
-
- /*
- * Send to kernel...
- */
- if ((n = sendmsg(so, &msg, 0)) < 0)
- syslog(LOG_ERR, "send: %m");
-#ifdef DEBUG
- (void)fprintf(stderr, "sent %d bytes\n", n);
-#endif
- sleep(1); /* XXX */
-#ifdef notdef
- if (shutdown(so, 2) < 0)
- syslog(LOG_ERR, "shutdown: %m");
-#endif
- /*
- * Throw away the open file descriptor
- */
- (void)close(fd);
-}
-
-void
-activate(qelem *q, int so)
-{
- struct portal_cred pcred;
- char key[MAXPATHLEN+1];
- int error;
- char **v;
- int fd = -1;
-
- /*
- * Read the key from the socket
- */
- error = get_request(so, &pcred, key, sizeof(key));
- if (error) {
- syslog(LOG_ERR, "activate: recvmsg: %m");
- goto drop;
- }
-
-#ifdef DEBUG
- (void)fprintf(stderr, "lookup key %s\n", key);
-#endif
-
- /*
- * Find a match in the configuration file
- */
- v = conf_match(q, key);
-
- /*
- * If a match existed, then find an appropriate portal
- * otherwise simply return ENOENT.
- */
- if (v) {
- error = activate_argv(&pcred, key, v, so, &fd);
- if (error)
- fd = -1;
- else if (fd < 0)
- error = -1;
- } else {
- error = ENOENT;
- }
-
- if (error >= 0)
- send_reply(so, fd, error);
-
-drop:;
- close(so);
-}
Index: sbin/mount_portal/conf.c
===================================================================
RCS file: sbin/mount_portal/conf.c
diff -N sbin/mount_portal/conf.c
--- sbin/mount_portal/conf.c 6 Jun 2004 00:12:03 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,317 +0,0 @@
-/* $OpenBSD: conf.c,v 1.8 2003/07/29 18:38:36 deraadt Exp $ */
-/* $NetBSD: conf.c,v 1.4 1995/04/23 10:33:19 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: conf.c,v 1.2 1992/05/27 07:09:27 jsp Exp
- * @(#)conf.c 8.2 (Berkeley) 3/27/94
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <regex.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-#define ALLOC(ty) (xmalloc(sizeof(ty)))
-
-typedef struct path path;
-struct path {
- qelem p_q; /* 2-way linked list */
- int p_lno; /* Line number of this record */
- char *p_args; /* copy of arg string (malloc) */
- char *p_key; /* Pathname to match (also p_argv[0]) */
- regex_t p_re; /* RE to match against pathname */
- int p_argc; /* number of elements in arg string */
- char **p_argv; /* argv[] pointers into arg string (malloc) */
-};
-
-static char *conf_file; /* XXX for regerror */
-
-/*
- * Add an element to a 2-way list,
- * just after (pred)
- */
-static void
-ins_que(qelem *elem, qelem *pred)
-{
- qelem *p = pred->q_forw;
- elem->q_back = pred;
- elem->q_forw = p;
- pred->q_forw = elem;
- p->q_back = elem;
-}
-
-/*
- * Remove an element from a 2-way list
- */
-static void
-rem_que(qelem *elem)
-{
- qelem *p = elem->q_forw;
- qelem *p2 = elem->q_back;
- p2->q_forw = p;
- p->q_back = p2;
-}
-
-/*
- * Error checking malloc
- */
-static void *
-xmalloc(size_t siz)
-{
- void *p = malloc(siz);
- if (p)
- return (p);
- syslog(LOG_ALERT, "malloc: failed to get %ld bytes", siz);
- exit(1);
-}
-
-/*
- * Insert the path in the list.
- * If there is already an element with the same key then
- * the *second* one is ignored (return 0).  If the key is
- * not found then the path is added to the end of the list
- * and 1 is returned.
- */
-static int
-pinsert(path *p0, qelem *q0)
-{
- qelem *q;
-
- if (p0->p_argc == 0)
- return (0);
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *)q;
- if (strcmp(p->p_key, p0->p_key) == 0)
- return (0);
- }
- ins_que(&p0->p_q, q0->q_back);
- return (1);
-}
-
-static path *
-palloc(char *cline, int lno)
-{
- int c;
- char *s;
- char *key;
- path *p;
- char **ap;
-
- /*
- * Implement comment chars
- */
- s = strchr(cline, '#');
- if (s)
- *s = 0;
-
- /*
- * Do a pass through the string to count the number
- * of arguments
- */
- c = 0;
- key = strdup(cline);
- if (key == NULL) {
- syslog(LOG_ALERT, "malloc: failed to get %ld bytes",
-    strlen(cline));
- exit(1);
- }
- for (s = key; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val)
- c++;
- }
- c++;
- free(key);
-
- if (c <= 1)
- return (0);
-
- /*
- * Now do another pass and generate a new path structure
- */
- p = ALLOC(path);
- p->p_argc = 0;
- p->p_argv = xmalloc(c * sizeof(char *));
- p->p_args = strdup(cline);
- if (p->p_args == NULL) {
- syslog(LOG_ALERT, "malloc: failed to get %ld bytes",
-    strlen(cline));
- exit(1);
- }
- ap = p->p_argv;
- for (s = p->p_args; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val) {
- *ap++ = val;
- p->p_argc++;
- }
- }
- *ap = 0;
-
-#ifdef DEBUG
- for (c = 0; c < p->p_argc; c++)
- (void)printf("%sv[%d] = %s\n", c?"\t":"", c, p->p_argv[c]);
-#endif
-
- p->p_key = p->p_argv[0];
- if ((c = regcomp(&(p->p_re), p->p_key, REG_EXTENDED))) {
- char errbuf[BUFSIZ];
-
- (void)regerror(c, &(p->p_re), errbuf, sizeof(errbuf));
- syslog(LOG_ERR, "%s:%d: regcomp %s: %s",
- conf_file, p->p_lno, p->p_key, errbuf);
- }
- p->p_lno = lno;
-
- return (p);
-}
-
-/*
- * Free a path structure
- */
-static void
-pfree(path *p)
-{
- free(p->p_args);
- regfree(&(p->p_re));
- free((void *)p->p_argv);
- free((void *)p);
-}
-
-/*
- * Discard all currently held path structures on q0.
- * and add all the ones on xq.
- */
-static void
-preplace(qelem *q0, qelem *xq)
-{
- /*
- * While the list is not empty,
- * take the first element off the list
- * and free it.
- */
- while (q0->q_forw != q0) {
- qelem *q = q0->q_forw;
- rem_que(q);
- pfree((path *)q);
- }
- while (xq->q_forw != xq) {
- qelem *q = xq->q_forw;
- rem_que(q);
- ins_que(q, q0);
- }
-}
-
-/*
- * Read the lines from the configuration file and
- * add them to the list of paths.
- */
-static void
-readfp(qelem *q0, FILE *fp)
-{
- char cline[LINE_MAX];
- int nread = 0;
- qelem q;
-
- /*
- * Make a new empty list.
- */
- q.q_forw = q.q_back = &q;
-
- /*
- * Read the lines from the configuration file.
- */
- while (fgets(cline, sizeof(cline), fp)) {
- path *p = palloc(cline, nread+1);
- if (p && !pinsert(p, &q))
- pfree(p);
- nread++;
- }
-
- /*
- * If some records were read, then throw
- * away the old list and replace with the
- * new one.
- */
- if (nread)
- preplace(q0, &q);
-}
-
-/*
- * Read the configuration file (conf) and replace
- * the existing path list with the new version.
- * If the file is not readable, then no changes take place
- */
-void
-conf_read(qelem *q, char *conf)
-{
- FILE *fp = fopen(conf, "r");
- if (fp) {
- conf_file = conf; /* XXX */
- readfp(q, fp);
- conf_file = NULL; /* XXX */
- (void)fclose(fp);
- } else {
- syslog(LOG_ERR, "open config file \"%s\": %m", conf);
- }
-}
-
-
-char **
-conf_match(qelem *q0, char *key)
-{
- qelem *q;
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *)q;
-
- if (regexec(&(p->p_re), key, 0, NULL, 0) == 0)
- return (p->p_argv+1);
- }
-
- return (0);
-}
Index: sbin/mount_portal/mount_portal.8
===================================================================
RCS file: sbin/mount_portal/mount_portal.8
diff -N sbin/mount_portal/mount_portal.8
--- sbin/mount_portal/mount_portal.8 31 May 2007 19:19:45 -0000 1.19
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,144 +0,0 @@
-.\" $OpenBSD: mount_portal.8,v 1.18 2007/05/19 07:15:34 jsg Exp $
-.\" $NetBSD: mount_portal.8,v 1.6 1995/08/18 15:01:19 pk Exp $
-.\"
-.\" Copyright (c) 1993, 1994
-.\" The Regents of the University of California.  All rights reserved.
-.\" All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94
-.\"
-.Dd $Mdocdate: May 31 2007 $
-.Dt MOUNT_PORTAL 8
-.Os
-.Sh NAME
-.Nm mount_portal
-.Nd mount the portal daemon
-.Sh SYNOPSIS
-.Nm mount_portal
-.Op Fl o Ar options
-.Ar config
-.Ar mount_point
-.Sh DESCRIPTION
-The
-.Nm
-command attaches an instance of the portal daemon
-to the global filesystem namespace.
-The conventional mount point is
-.Pa /p .
-This command is normally executed by
-.Xr mount 8
-at boot time.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl o Ar options
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.El
-.Pp
-The portal daemon provides an
-.Em open
-service.
-Objects opened under the portal mount point are
-dynamically created by the portal daemon according
-to rules specified in the named configuration file.
-Using this mechanism allows descriptors such as sockets
-to be made available in the filesystem namespace.
-.Pp
-The portal daemon works by being passed the full pathname
-of the object being opened.
-The daemon creates an appropriate descriptor according
-to the rules in the configuration file, and then passes the descriptor back
-to the calling process as the result of the
-.Fn open
-system call.
-.Sh NAMESPACE
-By convention, the portal daemon divides the namespace into sub-namespaces,
-each of which handles objects of a particular type.
-.Pp
-Currently, two sub-namespaces are implemented:
-.Pa tcp
-and
-.Pa fs .
-The
-.Pa tcp
-namespace takes a hostname and a port (slash separated) and
-creates an open TCP/IP connection.
-The
-.Pa fs
-namespace opens the named file, starting back at the root directory.
-This can be used to provide a controlled escape path from
-a chrooted environment.
-.Sh "CONFIGURATION FILE"
-The configuration file contains a list of rules.
-Each rule takes one line and consists of two or more
-whitespace separated fields.
-A hash
-.Pq Sq #
-character causes the remainder of a line to be ignored.
-Blank lines are ignored.
-.Pp
-The first field is a pathname prefix to match
-against the requested pathname.
-If a match is found, the second field
-tells the daemon what type of object to create.
-Subsequent fields are passed to the creation function.
-.Bd -literal
-# @(#)portal.conf 5.1 (Berkeley) 7/13/92
-tcp/ tcp tcp/
-fs/ file fs/
-.Ed
-.Sh FILES
-.Bl -tag -width /p/* -compact
-.It Pa /p/*
-.El
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8 ,
-.Xr umount 8
-.Rs
-.%A W. R. Stevens
-.%A J. Pendry
-.%T "Portals in 4.4BSD"
-.%J "USENIX Conference Proceedings"
-.%D 1995
-.Re
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
-.Sh CAVEATS
-This filesystem may not be NFS-exported.
Index: sbin/mount_portal/mount_portal.c
===================================================================
RCS file: sbin/mount_portal/mount_portal.c
diff -N sbin/mount_portal/mount_portal.c
--- sbin/mount_portal/mount_portal.c 27 Oct 2009 23:59:33 -0000 1.29
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,286 +0,0 @@
-/* $OpenBSD: mount_portal.c,v 1.28 2008/06/01 18:38:29 sobrado Exp $ */
-/* $NetBSD: mount_portal.c,v 1.8 1996/04/13 01:31:54 jtc Exp $ */
-
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/syslog.h>
-#include <sys/mount.h>
-
-#include <err.h>
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-#include "pathnames.h"
-#include "portald.h"
-
-const struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-extern char *__progname; /* from crt0.o */
-
-static char mountpt[MAXPATHLEN]; /* made available to signal handler */
-
-static void usage(void);
-
-static volatile sig_atomic_t readcf; /* Set when SIGHUP received */
-
-static void
-sigchld(int sig)
-{
- int save_errno = errno;
- struct syslog_data sdata = SYSLOG_DATA_INIT;
- pid_t pid;
-
- while ((pid = waitpid((pid_t) -1, NULL, WNOHANG)) > 0)
- ;
- if (pid < 0 && errno != ECHILD)
- syslog_r(LOG_WARNING, &sdata, "waitpid: %m");
- errno = save_errno;
-}
-
-static void
-sighup(int sig)
-{
-
- readcf = 1;
-}
-
-static void
-sigterm(int sig)
-{
- struct syslog_data sdata = SYSLOG_DATA_INIT;
-
- if (unmount(mountpt, MNT_FORCE) < 0)
- syslog_r(LOG_WARNING, &sdata,
-    "sigterm: unmounting %s failed: %m", mountpt);
- _exit(1);
-}
-
-int
-main(int argc, char *argv[])
-{
- struct portal_args args;
- struct sockaddr_un un;
- char *conf;
- int mntflags = 0;
- char tag[32];
- fd_set *fdsp;
- int fdssize;
-
- qelem q;
- int so;
- int error = 0;
-
- /*
- * Crack command line args
- */
- int ch;
-
- while ((ch = getopt(argc, argv, "o:")) != -1) {
- switch (ch) {
- case 'o':
- getmntopts(optarg, mopts, &mntflags);
- break;
- default:
- error = 1;
- break;
- }
- }
-
- if (optind != (argc - 2))
- error = 1;
-
- if (error)
- usage();
-
- /*
- * Get config file and mount point
- */
- conf = argv[optind];
- if (realpath(argv[optind+1], mountpt) == NULL)
- err(1, "realpath %s", argv[optind+1]);
-
- /*
- * Construct the listening socket
- */
- un.sun_family = AF_UNIX;
- if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path))
- errx(1, "portal socket name too long");
- (void)strlcpy(un.sun_path, _PATH_TMPPORTAL, sizeof un.sun_path);
- so = mkstemp(un.sun_path);
- if (so < 0)
- err(1, "can't create portal socket name: %s", un.sun_path);
- un.sun_len = strlen(un.sun_path);
- (void)close(so);
-
- so = socket(AF_UNIX, SOCK_STREAM, 0);
- if (so < 0)
- err(1, "socket(2)");
-
- (void)unlink(un.sun_path);
- /* XXX teeny race? */
- if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0)
- err(1, "bind(2)");
-
- (void)listen(so, 5);
-
- args.pa_socket = so;
-
- /*
- * Must fork before mount to get pid in name right.
- */
- daemon(0, 0);
-
- (void)snprintf(tag, sizeof(tag), "portal:%ld", (long)getpid());
- args.pa_config = tag;
-
- /*
- * Start logging (and change name)
- */
- openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON);
-
- if (mount(MOUNT_PORTAL, mountpt, mntflags, &args)) {
- if (errno == EOPNOTSUPP)
- syslog(LOG_ERR,
-    "mount: Filesystem not supported by kernel");
- else
- syslog(LOG_ERR, "mount: %m");
- exit(1);
- }
-
- q.q_forw = q.q_back = &q;
- readcf = 1;
-
- (void)signal(SIGCHLD, sigchld);
- (void)signal(SIGHUP, sighup);
- (void)signal(SIGTERM, sigterm);
-
- fdssize = howmany(so+1, NFDBITS) * sizeof(fd_mask);
- fdsp = (fd_set *)malloc(fdssize);
- if (fdsp == NULL)
- err(1, "malloc");
-
- /*
- * Just loop waiting for new connections and activating them
- */
- for (;;) {
- struct sockaddr_un un2;
- socklen_t salen = sizeof(un2);
- int so2;
- pid_t pid;
- int rc;
-
- /*
- * Check whether we need to re-read the configuration file
- */
- if (readcf) {
- readcf = 0;
- conf_read(&q, conf);
- continue;
- }
-
- /*
- * Accept a new connection
- * Will get EINTR if a signal has arrived, so just
- * ignore that error code
- */
- memset(fdsp, 0, fdssize);
- FD_SET(so, fdsp);
- rc = select(so+1, fdsp, NULL, NULL, NULL);
- if (rc < 0) {
- if (errno == EINTR)
- continue;
- syslog(LOG_ERR, "select: %m");
- exit(1);
- }
- if (rc == 0)
- break;
- so2 = accept(so, (struct sockaddr *) &un2, &salen);
- if (so2 < 0) {
- /*
- * The unmount function does a shutdown on the socket
- * which will generated ECONNABORTED on the accept.
- */
- if (errno == ECONNABORTED)
- break;
- if (errno != EINTR) {
- syslog(LOG_ERR, "accept: %m");
- exit(1);
- }
- continue;
- }
-
- /*
- * Now fork a new child to deal with the connection
- */
- eagain:;
- switch (pid = fork()) {
- case -1:
- if (errno == EAGAIN) {
- sleep(1);
- goto eagain;
- }
- syslog(LOG_ERR, "fork: %m");
- break;
- case 0:
- (void)close(so);
- activate(&q, so2);
- exit(0);
- default:
- (void)close(so2);
- break;
- }
- }
- free(fdsp);
- syslog(LOG_INFO, "%s unmounted", mountpt);
- exit(0);
-}
-
-static void
-usage(void)
-{
- (void)fprintf(stderr,
- "usage: %s [-o options] config mount_point\n", __progname);
- exit(1);
-}
Index: sbin/mount_portal/pathnames.h
===================================================================
RCS file: sbin/mount_portal/pathnames.h
diff -N sbin/mount_portal/pathnames.h
--- sbin/mount_portal/pathnames.h 2 Jun 2003 20:06:16 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-/* $OpenBSD: pathnames.h,v 1.4 1997/03/23 03:52:15 millert Exp $ */
-/* $NetBSD: pathnames.h,v 1.4 1995/04/23 10:33:21 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: pathnames.h,v 1.2 1992/05/27 07:09:27 jsp Exp
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- */
-
-#include <paths.h>
-
-#define _PATH_TMPPORTAL "/tmp/portalXXXXXXXXXX" /* Scratch socket name */
Index: sbin/mount_portal/portal.conf
===================================================================
RCS file: sbin/mount_portal/portal.conf
diff -N sbin/mount_portal/portal.conf
--- sbin/mount_portal/portal.conf 8 Dec 1996 22:22:38 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,9 +0,0 @@
-# $OpenBSD: portal.conf,v 1.2 1996/06/23 14:31:33 deraadt Exp $
-# $NetBSD: portal.conf,v 1.3 1995/03/18 14:57:59 cgd Exp $
-# from: Id: portal.conf,v 1.1 1992/05/27 06:50:13 jsp Exp
-# @(#)portal.conf 8.1 (Berkeley) 6/5/93
-#tcplisten/ tcplisten tcplisten/
-#tcp/ tcp tcp/
-#fs/ file fs/
-#pipe/ pipe
-#foo/ exec ./bar bar baz
Index: sbin/mount_portal/portald.h
===================================================================
RCS file: sbin/mount_portal/portald.h
diff -N sbin/mount_portal/portald.h
--- sbin/mount_portal/portald.h 2 Jun 2003 20:06:16 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-/* $OpenBSD: portald.h,v 1.5 2002/02/17 19:42:28 millert Exp $ */
-/* $NetBSD: portald.h,v 1.4 1995/04/23 10:33:23 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: portald.h,v 1.1 1992/05/25 21:43:09 jsp Exp
- * @(#)portald.h 8.1 (Berkeley) 6/5/93
- */
-
-#include <sys/cdefs.h>
-#include <miscfs/portal/portal.h>
-
-/*
- * Meta-chars in an RE.  Paths in the config file containing
- * any of these characters will be matched using regexec, other
- * paths will be prefix-matched.
- */
-#define RE_CHARS ".|()[]*+?\\^$"
-
-typedef struct qelem qelem;
-
-struct qelem {
- qelem *q_forw;
- qelem *q_back;
-};
-
-typedef struct provider provider;
-struct provider {
- char *pr_match;
- int (*pr_func)(struct portal_cred *, char *, char **, int, int *);
-};
-extern provider providers[];
-
-/*
- * Portal providers
- */
-extern int portal_exec(struct portal_cred *, char *, char **, int, int *);
-extern int portal_file(struct portal_cred *, char *, char **, int, int *);
-extern int portal_tcp(struct portal_cred *, char *, char **, int, int *);
-
-/*
- * Global functions
- */
-extern void activate(qelem *q, int so);
-extern char **conf_match(qelem *q, char *key);
-extern void conf_read(qelem *q, char *conf);
Index: sbin/mount_portal/pt_conf.c
===================================================================
RCS file: sbin/mount_portal/pt_conf.c
diff -N sbin/mount_portal/pt_conf.c
--- sbin/mount_portal/pt_conf.c 2 Jun 2003 20:06:16 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,49 +0,0 @@
-/* $OpenBSD: pt_conf.c,v 1.3 1997/03/23 03:52:16 millert Exp $ */
-/* $NetBSD: pt_conf.c,v 1.4 1995/04/23 10:33:24 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: pt_conf.c,v 1.2 1992/05/27 07:09:27 jsp Exp
- * @(#)pt_conf.c 8.1 (Berkeley) 6/5/93
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include "portald.h"
-
-provider providers[] = {
- { "exec", portal_exec },
- { "file", portal_file },
- { "tcp", portal_tcp },
- { 0, 0 }
-};
Index: sbin/mount_portal/pt_exec.c
===================================================================
RCS file: sbin/mount_portal/pt_exec.c
diff -N sbin/mount_portal/pt_exec.c
--- sbin/mount_portal/pt_exec.c 11 Jun 2003 06:22:14 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
-/* $OpenBSD: pt_exec.c,v 1.4 2003/06/02 20:06:16 millert Exp $ */
-/* $NetBSD: pt_exec.c,v 1.4 1995/04/23 10:33:25 cgd Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: pt_exec.c,v 1.1 1992/05/25 21:43:09 jsp Exp
- * @(#)pt_exec.c 8.1 (Berkeley) 6/5/93
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-int
-portal_exec(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
-{
- return (ENOEXEC);
-}
Index: sbin/mount_portal/pt_file.c
===================================================================
RCS file: sbin/mount_portal/pt_file.c
diff -N sbin/mount_portal/pt_file.c
--- sbin/mount_portal/pt_file.c 11 Jun 2003 06:22:14 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-/* $OpenBSD: pt_file.c,v 1.8 2003/06/02 20:06:16 millert Exp $ */
-/* $NetBSD: pt_file.c,v 1.7 1995/06/06 19:54:30 mycroft Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: pt_file.c,v 1.1 1992/05/25 21:43:09 jsp Exp
- * @(#)pt_file.c 8.3 (Berkeley) 7/3/94
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-int
-portal_file(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
-{
- int fd;
- char pbuf[MAXPATHLEN];
- int error;
-
- pbuf[0] = '/';
- (void)strncpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0), sizeof pbuf-2);
- pbuf[sizeof pbuf-1] = '\0';
-
-#ifdef DEBUG
- (void)printf("path = %s, uid = %u, gid = %u\n", pbuf, pcr->pcr_uid,
-    pcr->pcr_gid);
-#endif
-
- if (setegid(pcr->pcr_gid) < 0 ||
-    setgroups(pcr->pcr_ngroups, pcr->pcr_groups) < 0)
- return (errno);
-
- if (seteuid(pcr->pcr_uid) < 0)
- return (errno);
-
-
- error = 0;
-
- fd = open(pbuf, O_RDWR|O_CREAT, 0666);
- if (fd < 0) {
-        if (errno == EISDIR) {
- errno = 0;
- fd = open(pbuf, O_RDONLY);
- }
- if (fd < 0)
- error = errno;
- }
-
- if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */
- error = errno;
- syslog(LOG_ERR, "setcred: %m");
- if (fd >= 0) {
- (void)close(fd);
- fd = -1;
- }
- }
-
- if (error == 0)
- *fdp = fd;
-
-#ifdef DEBUG
- (void)fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n",
-    *fdp, error);
-#endif
-
- return (error);
-}
Index: sbin/mount_portal/pt_tcp.c
===================================================================
RCS file: sbin/mount_portal/pt_tcp.c
diff -N sbin/mount_portal/pt_tcp.c
--- sbin/mount_portal/pt_tcp.c 9 Dec 2007 20:54:01 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-/* $OpenBSD: pt_tcp.c,v 1.12 2004/08/08 19:04:25 deraadt Exp $ */
-
-/*
- * Copyright (c) 2004 Pedro Martelletto <[hidden email]>
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <unistd.h>
-#include <syslog.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <errno.h>
-
-#include "portald.h"
-
-/*
- * Keys should follow the format: tcp/[4||6]/host/port/["priv"]
- */
-int
-portal_tcp(struct portal_cred *pcr, char *key, char **v, int ks, int *fdp)
-{
- char **tp, *tokens[5];
- int priv, s, tc, n;
- struct addrinfo aih, *ai, *ail;
-
- if (!strlen(key) || key[strlen(key) - 1] == '/')
- return (EINVAL);
-
- tc = 0;
- for (tp = tokens; tp < &tokens[5] &&
-    (*tp = strsep(&key, "/")) != NULL;)
- if (**tp != '\0') {
- tp++;
- tc++;
- }
-
- if (tc < 3)
- return (EINVAL);
-
- memset(&aih, 0x0, sizeof(aih));
- aih.ai_socktype = SOCK_STREAM;
- aih.ai_family = PF_UNSPEC;
-
- priv = 0;
- tp = tokens;
- if (tc > 3) {
- if (!strcmp(tokens[1], "4"))
- aih.ai_family = PF_INET;
- else if (!strcmp(tokens[1], "6"))
- aih.ai_family = PF_INET6;
-
- if (aih.ai_family != PF_UNSPEC) {
- tp++;
- tc--;
- }
-
- if (tc > 4)
- return (EINVAL);
-
- if (tc > 3) {
- if (!strcmp(tp[tc - 1], "priv")) {
- if (pcr->pcr_uid == 0)
- priv = 1;
- else
- return (EPERM);
- } else
- return (EINVAL);
- }
- }
-
- n = getaddrinfo(tp[1], tp[2], &aih, &ail);
- if (n) {
- syslog(LOG_ERR, "getaddrinfo: %s", gai_strerror(n));
- return (EINVAL);
- }
-
- s = -1;
-
- for (ai = ail; ai != NULL; ai = ai->ai_next) {
- if (priv)
- s = rresvport(NULL);
- else
- s = socket(ai->ai_family, ai->ai_socktype,
-        ai->ai_protocol);
- if (s < 0) {
- syslog(LOG_ERR, "socket: %m");
- continue;
- }
-
- n = connect(s, ai->ai_addr, ai->ai_addrlen);
- if (!n)
- break;
-
- syslog(LOG_ERR, "connect: %m");
- close(s);
- s = -1;
- }
-
- freeaddrinfo(ail);
-
- if (s == -1)
- return (errno);
-
- *fdp = s;
- return (0);
-}
Index: sys/conf/files
===================================================================
RCS file: /var/cvs/src/sys/conf/files,v
retrieving revision 1.509
diff -u -p -r1.509 files
--- sys/conf/files 10 Jan 2011 23:23:56 -0000 1.509
+++ sys/conf/files 4 Apr 2011 20:56:27 -0000
@@ -772,8 +772,6 @@ file kern/vfs_vnops.c
 file kern/vfs_getcwd.c
 file miscfs/deadfs/dead_vnops.c
 file miscfs/fifofs/fifo_vnops.c fifo
-file miscfs/portal/portal_vfsops.c portal
-file miscfs/portal/portal_vnops.c portal
 file miscfs/procfs/procfs_cmdline.c procfs
 file miscfs/procfs/procfs_ctl.c procfs
 file miscfs/procfs/procfs_linux.c procfs
Index: sys/kern/Makefile
===================================================================
RCS file: /var/cvs/src/sys/kern/Makefile,v
retrieving revision 1.27
diff -u -p -r1.27 Makefile
--- sys/kern/Makefile 21 Dec 2010 20:14:43 -0000 1.27
+++ sys/kern/Makefile 4 Apr 2011 21:01:00 -0000
@@ -37,7 +37,7 @@ DGEN= compat compat/common compat/freebs
  lib/libkern lib/libkern/arch/${MACHINE} \
  lib/libkern/arch/${MACHINE_ARCH} \
  miscfs miscfs/deadfs miscfs/fifofs \
- miscfs/portal miscfs/procfs miscfs/specfs \
+ miscfs/procfs miscfs/specfs \
  msdosfs \
  net netinet netmpls \
  nfs \
Index: sys/kern/vfs_conf.c
===================================================================
RCS file: /var/cvs/src/sys/kern/vfs_conf.c,v
retrieving revision 1.40
diff -u -p -r1.40 vfs_conf.c
--- sys/kern/vfs_conf.c 21 Dec 2010 20:14:43 -0000 1.40
+++ sys/kern/vfs_conf.c 4 Apr 2011 21:01:12 -0000
@@ -91,10 +91,6 @@ extern const struct vfsops msdosfs_vfsop
 extern const struct vfsops nfs_vfsops;
 #endif
 
-#ifdef PORTAL
-extern const struct vfsops portal_vfsops;
-#endif
-
 #ifdef PROCFS
 extern const struct vfsops procfs_vfsops;
 #endif
@@ -160,11 +156,6 @@ static struct vfsconf vfsconflist[] = {
         /* /proc Filesystem */
 #ifdef PROCFS
         { &procfs_vfsops, MOUNT_PROCFS, 12, 0, 0, NULL },
-#endif
-
-        /* Portal Filesystem */
-#ifdef PORTAL
-        { &portal_vfsops, MOUNT_PORTAL, 8, 0, 0, NULL },
 #endif
 
  /* NTFS Filesystem */
Index: sys/miscfs/portal/portal.h
===================================================================
RCS file: sys/miscfs/portal/portal.h
diff -N sys/miscfs/portal/portal.h
--- sys/miscfs/portal/portal.h 14 Aug 2003 07:46:39 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-/* $OpenBSD: portal.h,v 1.4 2003/06/02 23:28:10 millert Exp $ */
-/* $NetBSD: portal.h,v 1.7 1996/02/09 22:40:40 christos Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: portal.h,v 1.3 1992/05/30 10:05:24 jsp Exp
- * @(#)portal.h 8.4 (Berkeley) 1/21/94
- */
-
-struct portal_args {
- char *pa_config; /* Config file */
- int pa_socket; /* Socket to server */
-};
-
-struct portal_cred {
- int pcr_flag; /* File open mode */
- uid_t pcr_uid; /* From ucred */
- gid_t pcr_gid; /* From ucred */
- short pcr_ngroups; /* From ucred */
- gid_t pcr_groups[NGROUPS]; /* From ucred */
-};
-
-#ifdef _KERNEL
-struct portalmount {
- struct vnode *pm_root; /* Root node */
- struct file *pm_server; /* Held reference to server socket */
-};
-
-struct portalnode {
- int pt_size; /* Length of Arg */
- char *pt_arg; /* Arg to send to server */
- int pt_fileid; /* cookie */
-};
-
-#define VFSTOPORTAL(mp) ((struct portalmount *)((mp)->mnt_data))
-#define VTOPORTAL(vp) ((struct portalnode *)(vp)->v_data)
-
-#define PORTAL_ROOTFILEID 2
-
-extern int (**portal_vnodeop_p)(void *);
-extern const struct vfsops portal_vfsops;
-#endif /* _KERNEL */
Index: sys/miscfs/portal/portal_vfsops.c
===================================================================
RCS file: sys/miscfs/portal/portal_vfsops.c
diff -N sys/miscfs/portal/portal_vfsops.c
--- sys/miscfs/portal/portal_vfsops.c 9 Jul 2009 22:29:56 -0000 1.24
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,261 +0,0 @@
-/* $OpenBSD: portal_vfsops.c,v 1.22 2007/10/29 15:38:00 chl Exp $ */
-/* $NetBSD: portal_vfsops.c,v 1.14 1996/02/09 22:40:41 christos Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: portal_vfsops.c,v 1.5 1992/05/30 10:25:27 jsp Exp
- * @(#)portal_vfsops.c 8.6 (Berkeley) 1/21/94
- */
-
-/*
- * Portal Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/file.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <sys/domain.h>
-#include <sys/un.h>
-#include <sys/dirent.h>
-#include <miscfs/portal/portal.h>
-
-#define portal_init ((int (*)(struct vfsconf *))nullop)
-
-int portal_mount(struct mount *, const char *, void *,
-  struct nameidata *, struct proc *);
-int portal_start(struct mount *, int, struct proc *);
-int portal_unmount(struct mount *, int, struct proc *);
-int portal_root(struct mount *, struct vnode **);
-int portal_statfs(struct mount *, struct statfs *, struct proc *);
-
-
-/*
- * Mount the per-process file descriptors (/dev/fd)
- */
-int
-portal_mount(struct mount *mp, const char *path, void *data, struct nameidata *ndp,
-    struct proc *p)
-{
- struct file *fp;
- struct portal_args args;
- struct portalmount *fmp;
- struct socket *so;
- struct vnode *rvp;
- size_t size;
- int error;
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE)
- return (EOPNOTSUPP);
-
- error = copyin(data, &args, sizeof(struct portal_args));
- if (error)
- return (error);
-
- if ((error = getsock(p->p_fd, args.pa_socket, &fp)) != 0)
- return (error);
- so = (struct socket *) fp->f_data;
- if (so->so_proto->pr_domain->dom_family != AF_UNIX) {
- FRELE(fp);
- return (ESOCKTNOSUPPORT);
- }
-
- error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */
- if (error) {
- FRELE(fp);
- return (error);
- }
- rvp->v_data = malloc(sizeof(struct portalnode), M_TEMP, M_WAITOK);
-
- fmp = (struct portalmount *) malloc(sizeof(struct portalmount),
- M_MISCFSMNT, M_WAITOK);
- rvp->v_type = VDIR;
- rvp->v_flag |= VROOT;
- VTOPORTAL(rvp)->pt_arg = 0;
- VTOPORTAL(rvp)->pt_size = 0;
- VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
- fmp->pm_root = rvp;
- fmp->pm_server = fp;
- fp->f_count++;
- FRELE(fp);
-
- mp->mnt_flag |= MNT_LOCAL;
- mp->mnt_data = fmp;
- vfs_getnewfsid(mp);
-
- mp->mnt_stat.f_namemax = MAXNAMLEN;
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copyinstr(args.pa_config, mp->mnt_stat.f_mntfromname,
-    MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- return (0);
-}
-
-int
-portal_start(struct mount *mp, int flags, struct proc *p)
-{
-
- return (0);
-}
-
-int
-portal_unmount(struct mount *mp, int mntflags, struct proc *p)
-{
- struct vnode *rvp = VFSTOPORTAL(mp)->pm_root;
- int error, flags = 0;
-
- if (mntflags & MNT_FORCE) {
- flags |= FORCECLOSE;
- }
-
- /*
- * Clear out buffer cache.  I don't think we
- * ever get anything cached at this level at the
- * moment, but who knows...
- */
-#ifdef notyet
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp, 1))
- return (EBUSY);
-#endif
- if (rvp->v_usecount > 1 && !(flags & FORCECLOSE))
- return (EBUSY);
- if ((error = vflush(mp, rvp, flags)) != 0)
- return (error);
-
- /*
- * Release reference on underlying root vnode
- */
- vrele(rvp);
- /*
- * And blow it away for future re-use
- */
- vgone(rvp);
- /*
- * Shutdown the socket.  This will cause the select in the
- * daemon to wake up, and then the accept will get ECONNABORTED
- * which it interprets as a request to go and bury itself.
- */
- FREF(VFSTOPORTAL(mp)->pm_server);
- soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
- /*
- * Discard reference to underlying file.  Must call closef because
- * this may be the last reference.
- */
- closef(VFSTOPORTAL(mp)->pm_server, NULL);
- /*
- * Finally, throw away the portalmount structure
- */
- free(mp->mnt_data, M_MISCFSMNT);
- mp->mnt_data = 0;
- return (0);
-}
-
-int
-portal_root(struct mount *mp, struct vnode **vpp)
-{
- struct vnode *vp;
- struct proc *p = curproc;
-
- /*
- * Return locked reference to root.
- */
- vp = VFSTOPORTAL(mp)->pm_root;
- vref(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- *vpp = vp;
- return (0);
-}
-
-int
-portal_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
-{
-
- sbp->f_bsize = DEV_BSIZE;
- sbp->f_iosize = DEV_BSIZE;
- sbp->f_blocks = 2; /* 1K to keep df happy */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
- sbp->f_files = 1; /* Allow for "." */
- sbp->f_ffree = 0; /* See comments above */
- copy_statfs_info(sbp, mp);
-
- return (0);
-}
-
-
-#define portal_sync ((int (*)(struct mount *, int, struct ucred *, \
-  struct proc *))nullop)
-
-#define portal_fhtovp ((int (*)(struct mount *, struct fid *, \
-    struct vnode **))eopnotsupp)
-#define portal_quotactl ((int (*)(struct mount *, int, uid_t, caddr_t, \
-    struct proc *))eopnotsupp)
-#define portal_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
-    size_t, struct proc *))eopnotsupp)
-#define portal_vget ((int (*)(struct mount *, ino_t, struct vnode **)) \
-    eopnotsupp)
-#define portal_vptofh ((int (*)(struct vnode *, struct fid *))eopnotsupp)
-#define portal_checkexp ((int (*)(struct mount *, struct mbuf *, \
- int *, struct ucred **))eopnotsupp)
-
-const struct vfsops portal_vfsops = {
- portal_mount,
- portal_start,
- portal_unmount,
- portal_root,
- portal_quotactl,
- portal_statfs,
- portal_sync,
- portal_vget,
- portal_fhtovp,
- portal_vptofh,
- portal_init,
- portal_sysctl,
- portal_checkexp
-};
Index: sys/miscfs/portal/portal_vnops.c
===================================================================
RCS file: sys/miscfs/portal/portal_vnops.c
diff -N sys/miscfs/portal/portal_vnops.c
--- sys/miscfs/portal/portal_vnops.c 14 Aug 2009 16:32:21 -0000 1.31
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,659 +0,0 @@
-/* $OpenBSD: portal_vnops.c,v 1.30 2009/08/13 15:00:14 jasper Exp $ */
-/* $NetBSD: portal_vnops.c,v 1.17 1996/02/13 13:12:57 mycroft Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: Id: portal_vnops.c,v 1.4 1992/05/30 10:05:24 jsp Exp
- * @(#)portal_vnops.c 8.8 (Berkeley) 1/21/94
- */
-
-/*
- * Portal Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/namei.h>
-#include <sys/mbuf.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/un.h>
-#include <sys/unpcb.h>
-#include <sys/syscallargs.h>
-#include <miscfs/portal/portal.h>
-
-static int portal_fileid = PORTAL_ROOTFILEID+1;
-
-static void portal_closefd(struct proc *, int);
-static int portal_connect(struct socket *, struct socket *);
-
-
-int portal_badop(void *);
-
-int portal_lookup(void *);
-int portal_open(void *);
-int portal_getattr(void *);
-int portal_setattr(void *);
-int portal_link(void *);
-int portal_symlink(void *);
-int portal_readdir(void *);
-int portal_inactive(void *);
-int portal_reclaim(void *);
-int portal_print(void *);
-int portal_pathconf(void *);
-int portal_poll(void *);
-
-int (**portal_vnodeop_p)(void *);
-struct vnodeopv_entry_desc portal_vnodeop_entries[] = {
- { &vop_default_desc, eopnotsupp },
- { &vop_lookup_desc, portal_lookup },
- { &vop_create_desc, eopnotsupp },
- { &vop_mknod_desc, eopnotsupp },
- { &vop_open_desc, portal_open },
- { &vop_close_desc, nullop },
- { &vop_access_desc, nullop },
- { &vop_getattr_desc, portal_getattr },
- { &vop_setattr_desc, portal_setattr },
- { &vop_read_desc, eopnotsupp },
- { &vop_write_desc, eopnotsupp },
- { &vop_ioctl_desc, (int (*)(void *))enoioctl },
- { &vop_poll_desc, portal_poll },
- { &vop_revoke_desc, vop_generic_revoke },
- { &vop_fsync_desc, nullop },
- { &vop_remove_desc, eopnotsupp },
- { &vop_link_desc, portal_link },
- { &vop_rename_desc, eopnotsupp },
- { &vop_mkdir_desc, eopnotsupp },
- { &vop_rmdir_desc, eopnotsupp },
- { &vop_symlink_desc, portal_symlink },
- { &vop_readdir_desc, portal_readdir },
- { &vop_readlink_desc, eopnotsupp },
- { &vop_abortop_desc, vop_generic_abortop },
- { &vop_inactive_desc, portal_inactive },
- { &vop_reclaim_desc, portal_reclaim },
- { &vop_lock_desc, vop_generic_lock },
- { &vop_unlock_desc, vop_generic_unlock },
- { &vop_bmap_desc, portal_badop },
- { &vop_strategy_desc, portal_badop },
- { &vop_print_desc, portal_print },
- { &vop_islocked_desc, vop_generic_islocked },
- { &vop_pathconf_desc, portal_pathconf },
- { &vop_advlock_desc, eopnotsupp },
- { &vop_bwrite_desc, eopnotsupp },
- { NULL, NULL }
-};
-struct vnodeopv_desc portal_vnodeop_opv_desc =
- { &portal_vnodeop_p, portal_vnodeop_entries };
-
-static void
-portal_closefd(struct proc *p, int fd)
-{
- struct sys_close_args /* {
- syscallarg(int) fd;
- } */ ua;
- register_t retval[2];
- int error;
-
- SCARG(&ua, fd) = fd;
- error = sys_close(p, &ua, retval);
- /*
- * We should never get an error, and there isn't anything
- * we could do if we got one, so just print a message.
- */
- if (error)
- printf("portal_closefd: error = %d\n", error);
-}
-
-/*
- * vp is the current namei directory
- * cnp is the name to locate in that directory...
- */
-int
-portal_lookup(void *v)
-{
- struct vop_lookup_args *ap = v;
- struct componentname *cnp = ap->a_cnp;
- struct vnode **vpp = ap->a_vpp;
- struct vnode *dvp = ap->a_dvp;
- char *pname = cnp->cn_nameptr;
- struct proc *p = cnp->cn_proc;
- struct portalnode *pt;
- int error;
- struct vnode *fvp = 0;
- char *path;
- int size;
-
- *vpp = NULLVP;
-
- if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)
- return (EROFS);
-
- if (cnp->cn_namelen == 1 && *pname == '.') {
- *vpp = dvp;
- vref(dvp);
- return (0);
- }
-
- error = getnewvnode(VT_PORTAL, dvp->v_mount, portal_vnodeop_p, &fvp);
- if (error)
- goto bad;
- fvp->v_type = VREG;
- fvp->v_data = malloc(sizeof(struct portalnode), M_TEMP, M_WAITOK);
-
- pt = VTOPORTAL(fvp);
- /*
- * Save all of the remaining pathname and
- * advance the namei next pointer to the end
- * of the string.
- */
- for (size = 0, path = pname; *path; path++)
- size++;
- cnp->cn_consume = size - cnp->cn_namelen;
-
- pt->pt_arg = malloc(size+1, M_TEMP, M_WAITOK);
- pt->pt_size = size+1;
- bcopy(pname, pt->pt_arg, pt->pt_size);
- pt->pt_fileid = portal_fileid++;
-
- *vpp = fvp;
- VOP_LOCK(fvp, LK_EXCLUSIVE, p);
- /*
- * As we are the last component of the path name, fix up
- * the locking on the directory node.
- */
- if ((cnp->cn_flags & LOCKPARENT) == 0) {
- VOP_UNLOCK(dvp, 0, p);
- cnp->cn_flags |= PDIRUNLOCK;
- }
- return (0);
-
-bad:;
- if (fvp)
- vrele(fvp);
- return (error);
-}
-
-static int
-portal_connect(struct socket *so, struct socket *so2)
-{
- /* from unp_connect, bypassing the namei stuff... */
- struct socket *so3;
- struct unpcb *unp2;
- struct unpcb *unp3;
-
- if (so2 == 0)
- return (ECONNREFUSED);
-
- if (so->so_type != so2->so_type)
- return (EPROTOTYPE);
-
- if ((so2->so_options & SO_ACCEPTCONN) == 0)
- return (ECONNREFUSED);
-
- if ((so3 = sonewconn(so2, 0)) == 0)
- return (ECONNREFUSED);
-
- unp2 = sotounpcb(so2);
- unp3 = sotounpcb(so3);
- if (unp2->unp_addr)
- unp3->unp_addr = m_copy(unp2->unp_addr, 0, (int)M_COPYALL);
-
- so2 = so3;
-
-
- return (unp_connect2(so, so2));
-}
-
-int
-portal_open(void *v)
-{
- struct vop_open_args *ap = v;
- struct socket *so = 0;
- struct portalnode *pt;
- struct proc *p = ap->a_p;
- struct vnode *vp = ap->a_vp;
- int s;
- struct uio auio;
- struct iovec aiov[2];
- int res;
- struct mbuf *cm = 0;
- struct cmsghdr *cmsg;
- int newfds;
- int *ip;
- int fd;
- int error;
- int len;
- struct portalmount *fmp;
- struct file *fp;
- struct portal_cred pcred;
-
- /*
- * Nothing to do when opening the root node.
- */
- if (vp->v_flag & VROOT)
- return (0);
-
- /*
- * Can't be opened unless the caller is set up
- * to deal with the side effects.  Check for this
- * by testing whether the p_dupfd has been set.
- */
- if (p->p_dupfd >= 0)
- return (ENODEV);
-
- pt = VTOPORTAL(vp);
- fmp = VFSTOPORTAL(vp->v_mount);
-
- /*
- * Create a new socket.
- */
- error = socreate(AF_UNIX, &so, SOCK_STREAM, 0);
- if (error)
- goto bad;
-
- /*
- * Reserve some buffer space
- */
- res = pt->pt_size + sizeof(pcred) + 512; /* XXX */
- error = soreserve(so, res, res);
- if (error)
- goto bad;
-
- /*
- * Kick off connection
- */
- s = splsoftnet();
- error = portal_connect(so, (struct socket *)fmp->pm_server->f_data);
- splx(s);
- if (error)
- goto bad;
-
- /*
- * Wait for connection to complete
- */
- /*
- * XXX: Since the mount point is holding a reference on the
- * underlying server socket, it is not easy to find out whether
- * the server process is still running.  To handle this problem
- * we loop waiting for the new socket to be connected (something
- * which will only happen if the server is still running) or for
- * the reference count on the server socket to drop to 1, which
- * will happen if the server dies.  Sleep for 5 second intervals
- * and keep polling the reference count.   XXX.
- */
- s = splsoftnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
- if (fmp->pm_server->f_count == 1) {
- error = ECONNREFUSED;
- splx(s);
- goto bad;
- }
- (void) tsleep(&so->so_timeo, PSOCK, "portalcon", 5 * hz);
- }
- splx(s);
-
- if (so->so_error) {
- error = so->so_error;
- goto bad;
- }
-
- /*
- * Set miscellaneous flags
- */
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_timeo = 0;
- so->so_rcv.sb_flags |= SB_NOINTR;
- so->so_snd.sb_flags |= SB_NOINTR;
-
-
- pcred.pcr_flag = ap->a_mode;
- pcred.pcr_uid = ap->a_cred->cr_uid;
- pcred.pcr_gid = ap->a_cred->cr_gid;
- pcred.pcr_ngroups = ap->a_cred->cr_ngroups;
- bcopy(ap->a_cred->cr_groups, pcred.pcr_groups, NGROUPS * sizeof(gid_t));
- aiov[0].iov_base = &pcred;
- aiov[0].iov_len = sizeof(pcred);
- aiov[1].iov_base = pt->pt_arg;
- aiov[1].iov_len = pt->pt_size;
- auio.uio_iov = aiov;
- auio.uio_iovcnt = 2;
- auio.uio_rw = UIO_WRITE;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = p;
- auio.uio_offset = 0;
- auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len;
-
- error = sosend(so, (struct mbuf *) 0, &auio,
- (struct mbuf *) 0, (struct mbuf *) 0, 0);
- if (error)
- goto bad;
-
- len = auio.uio_resid = sizeof(int);
- do {
- struct mbuf *m = 0;
- int flags = MSG_WAITALL;
- fdpunlock(p->p_fd);
- error = soreceive(so, (struct mbuf **) 0, &auio,
- &m, &cm, &flags, 0);
- fdplock(p->p_fd);
- if (error)
- goto bad;
-
- /*
- * Grab an error code from the mbuf.
- */
- if (m) {
- m = m_pullup(m, sizeof(int)); /* Needed? */
- if (m) {
- error = *(mtod(m, int *));
- m_freem(m);
- } else {
- error = EINVAL;
- }
- } else {
- if (cm == 0) {
- error = ECONNRESET; /* XXX */
-#ifdef notdef
- break;
-#endif
- }
- }
- } while (cm == 0 && auio.uio_resid == len && !error);
-
- if (cm == 0)
- goto bad;
-
- if (auio.uio_resid) {
- error = 0;
-#ifdef notdef
- error = EMSGSIZE;
- goto bad;
-#endif
- }
-
- /*
- * XXX: Break apart the control message, and retrieve the
- * received file descriptor.  Note that more than one descriptor
- * may have been received, or that the rights chain may have more
- * than a single mbuf in it.  What to do?
- */
- cmsg = mtod(cm, struct cmsghdr *);
- if (cmsg->cmsg_len < CMSG_LEN(0)) {
- error = EMSGSIZE;
- goto bad;
- }
- newfds = (cmsg->cmsg_len - sizeof(*cmsg)) / sizeof (int);
- if (newfds == 0) {
- error = ECONNREFUSED;
- goto bad;
- }
- /*
- * At this point the rights message consists of a control message
- * header, followed by a data region containing a vector of
- * integer file descriptors.  The fds were allocated by the action
- * of receiving the control message.
- */
- ip = (int *)CMSG_DATA(cmsg);
- fd = *ip++;
- if (newfds > 1) {
- /*
- * Close extra fds.
- */
- int i;
- printf("portal_open: %d extra fds\n", newfds - 1);
- for (i = 1; i < newfds; i++) {
- portal_closefd(p, *ip);
- ip++;
- }
- }
-
- /*
- * Check that the mode the file is being opened for is a subset
- * of the mode of the existing descriptor.
- */
- if ((fp = fd_getfile(p->p_fd, fd)) == NULL) {
- error = EBADF;
- goto bad;
- }
- if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) {
- portal_closefd(p, fd);
- error = EACCES;
- goto bad;
- }
-
- /*
- * Save the dup fd in the proc structure then return the
- * special error code (ENXIO) which causes magic things to
- * happen in vn_open.  The whole concept is, well, hmmm.
- */
- p->p_dupfd = fd;
- error = ENXIO;
-
-bad:;
- /*
- * And discard the control message.
- */
- if (cm) {
- m_freem(cm);
- }
-
- if (so) {
- soshutdown(so, 2);
- soclose(so);
- }
- return (error);
-}
-
-int
-portal_getattr(void *v)
-{
- struct vop_getattr_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct vattr *vap = ap->a_vap;
-
- bzero(vap, sizeof(*vap));
- vattr_null(vap);
- vap->va_uid = 0;
- vap->va_gid = 0;
- vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
- vap->va_size = DEV_BSIZE;
- vap->va_blocksize = DEV_BSIZE;
- getnanotime(&vap->va_atime);
- vap->va_mtime = vap->va_atime;
- vap->va_ctime = vap->va_atime;
- vap->va_gen = 0;
- vap->va_flags = 0;
- vap->va_rdev = 0;
- /* vap->va_qbytes = 0; */
- vap->va_bytes = 0;
- /* vap->va_qsize = 0; */
- if (vp->v_flag & VROOT) {
- vap->va_type = VDIR;
- vap->va_mode = S_IRUSR|S_IWUSR|S_IXUSR|
- S_IRGRP|S_IWGRP|S_IXGRP|
- S_IROTH|S_IWOTH|S_IXOTH;
- vap->va_nlink = 2;
- vap->va_fileid = 2;
- } else {
- vap->va_type = VREG;
- vap->va_mode = S_IRUSR|S_IWUSR|
- S_IRGRP|S_IWGRP|
- S_IROTH|S_IWOTH;
- vap->va_nlink = 1;
- vap->va_fileid = VTOPORTAL(vp)->pt_fileid;
- }
- return (0);
-}
-
-int
-portal_setattr(void *v)
-{
- struct vop_setattr_args *ap = v;
-
- /*
- * Can't mess with the root vnode
- */
- if (ap->a_vp->v_flag & VROOT)
- return (EACCES);
-
- if (ap->a_vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
-
- return (0);
-}
-
-/*
- * Fake readdir, just return empty directory.
- * It is hard to deal with '.' and '..' so don't bother.
- */
-/*ARGSUSED*/
-int
-portal_readdir(void *v)
-{
- return (0);
-}
-
-/*ARGSUSED*/
-int
-portal_inactive(void *v)
-{
- struct vop_inactive_args *ap = v;
-
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-int
-portal_reclaim(void *v)
-{
- struct vop_reclaim_args *ap = v;
- struct portalnode *pt = VTOPORTAL(ap->a_vp);
-
- if (pt->pt_arg) {
- free(pt->pt_arg, M_TEMP);
- pt->pt_arg = 0;
- }
- free(ap->a_vp->v_data, M_TEMP);
- ap->a_vp->v_data = 0;
-
- return (0);
-}
-
-/*
- * Return POSIX pathconf information applicable to special devices.
- */
-int
-portal_pathconf(void *v)
-{
- struct vop_pathconf_args *ap = v;
-
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = LINK_MAX;
- return (0);
- case _PC_MAX_CANON:
- *ap->a_retval = MAX_CANON;
- return (0);
- case _PC_MAX_INPUT:
- *ap->a_retval = MAX_INPUT;
- return (0);
- case _PC_PIPE_BUF:
- *ap->a_retval = PIPE_BUF;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- case _PC_VDISABLE:
- *ap->a_retval = _POSIX_VDISABLE;
- return (0);
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-/*
- * Print out the contents of a Portal vnode.
- */
-/* ARGSUSED */
-int
-portal_print(void *v)
-{
- printf("tag VT_PORTAL, portal vnode\n");
- return (0);
-}
-
-int
-portal_link(void *v)
-{
- struct vop_link_args *ap = v;
-
- VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
- vput(ap->a_dvp);
- return (EROFS);
-}
-
-int
-portal_symlink(void *v)
-{
- struct vop_symlink_args *ap = v;
-  
- VOP_ABORTOP(ap->a_dvp, ap->a_cnp);
- vput(ap->a_dvp);
- return (EROFS);
-}
-
-int
-portal_badop(void *v)
-{
- panic ("portal: bad op");
- return (0);
-}
-
-int
-portal_poll(void *v)
-{
- struct vop_poll_args *ap = v;
-
- return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
-}
Index: sys/sys/mount.h
===================================================================
RCS file: /var/cvs/src/sys/sys/mount.h,v
retrieving revision 1.102
diff -u -p -r1.102 mount.h
--- sys/sys/mount.h 4 Apr 2011 15:22:10 -0000 1.102
+++ sys/sys/mount.h 4 Apr 2011 21:00:15 -0000
@@ -339,7 +339,6 @@ struct ostatfs {
 #define MOUNT_NFS "nfs" /* Network Filesystem */
 #define MOUNT_MFS "mfs" /* Memory Filesystem */
 #define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */
-#define MOUNT_PORTAL "portal" /* Portal Filesystem */
 #define MOUNT_PROCFS "procfs" /* /proc Filesystem */
 #define MOUNT_AFS "afs" /* Andrew Filesystem */
 #define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */
Index: sys/sys/vnode.h
===================================================================
RCS file: /var/cvs/src/sys/sys/vnode.h,v
retrieving revision 1.107
diff -u -p -r1.107 vnode.h
--- sys/sys/vnode.h 21 Dec 2010 20:14:43 -0000 1.107
+++ sys/sys/vnode.h 4 Apr 2011 21:00:03 -0000
@@ -67,14 +67,14 @@ enum vtype { VNON, VREG, VDIR, VBLK, VCH
  */
 enum vtagtype {
  VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS,
- VT_PORTAL, VT_PROCFS, VT_AFS, VT_ISOFS, VT_ADOSFS,
- VT_EXT2FS, VT_VFS, VT_NNPFS, VT_NTFS, VT_UDF, VT_XFS = VT_NNPFS
+ VT_PROCFS, VT_ISOFS, VT_EXT2FS, VT_VFS,
+ VT_NNPFS, VT_NTFS, VT_UDF
 };
 
-#define VTAG_NAMES \
-    "NON", "UFS", "NFS", "MFS", "MSDOSFS", \
-    "PORTAL", "PROCFS", "AFS", "ISOFS", "ADOSFS", \
-    "EXT2FS", "VFS", "NNPFS", "NTFS", "UDF"
+#define VTAG_NAMES \
+    "NON", "UFS", "NFS", "MFS", "MSDOSFS", \
+    "PROCFS", "ISOFS", "EXT2FS", "VFS", \
+    "NNPFS", "NTFS", "UDF"
 
 /*
  * Each underlying filesystem allocates its own private area and hangs