diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2011-04-05 18:51:27 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2011-04-05 18:51:27 +0000 |
commit | d06c6e3ed24cd10e8c6d6e2716844bdfdf4988d0 (patch) | |
tree | 6b5cb852c945d2ff31b480ac2809cd2b116a1f51 | |
parent | ff7b8619a9913d659ebfcd6f5e5968081d98d873 (diff) |
Remove portalfs.
While it is a terribly cool idea, it's just awful and since noone has stepped
up to the plate to keep it up with the current vop state, retire it to the
attic.
ok krw@, deraadt@, guenther@, miod@.
comments from jmc@
-rw-r--r-- | etc/changelist | 3 | ||||
-rw-r--r-- | sbin/Makefile | 4 | ||||
-rw-r--r-- | sbin/mount/mount.8 | 5 | ||||
-rw-r--r-- | sbin/mount_portal/Makefile | 19 | ||||
-rw-r--r-- | sbin/mount_portal/activate.c | 205 | ||||
-rw-r--r-- | sbin/mount_portal/conf.c | 317 | ||||
-rw-r--r-- | sbin/mount_portal/mount_portal.8 | 144 | ||||
-rw-r--r-- | sbin/mount_portal/mount_portal.c | 286 | ||||
-rw-r--r-- | sbin/mount_portal/pathnames.h | 42 | ||||
-rw-r--r-- | sbin/mount_portal/portal.conf | 9 | ||||
-rw-r--r-- | sbin/mount_portal/portald.h | 76 | ||||
-rw-r--r-- | sbin/mount_portal/pt_conf.c | 49 | ||||
-rw-r--r-- | sbin/mount_portal/pt_exec.c | 54 | ||||
-rw-r--r-- | sbin/mount_portal/pt_file.c | 106 | ||||
-rw-r--r-- | sbin/mount_portal/pt_tcp.c | 123 | ||||
-rw-r--r-- | share/man/man4/options.4 | 12 | ||||
-rw-r--r-- | sys/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/conf/files | 4 | ||||
-rw-r--r-- | sys/kern/Makefile | 4 | ||||
-rw-r--r-- | sys/kern/vfs_conf.c | 11 | ||||
-rw-r--r-- | sys/miscfs/portal/portal.h | 71 | ||||
-rw-r--r-- | sys/miscfs/portal/portal_vfsops.c | 261 | ||||
-rw-r--r-- | sys/miscfs/portal/portal_vnops.c | 659 | ||||
-rw-r--r-- | sys/sys/mount.h | 3 | ||||
-rw-r--r-- | usr.sbin/procmap/procmap.c | 5 |
25 files changed, 14 insertions, 2462 deletions
diff --git a/etc/changelist b/etc/changelist index 1a8f9b70a8e..0aab92b70c0 100644 --- a/etc/changelist +++ b/etc/changelist @@ -1,4 +1,4 @@ -# $OpenBSD: changelist,v 1.71 2011/01/19 18:34:58 david Exp $ +# $OpenBSD: changelist,v 1.72 2011/04/05 18:51:25 thib Exp $ # # List of files which the security script backs up and checks # for modifications. @@ -101,7 +101,6 @@ /etc/pf.conf /etc/pf.os /etc/pkg.conf -/etc/portal.conf /etc/printcap /etc/profile /etc/protocols diff --git a/sbin/Makefile b/sbin/Makefile index c73a4f0468b..b7a0f2e3717 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.93 2010/11/01 05:25:49 deraadt Exp $ +# $OpenBSD: Makefile,v 1.94 2011/04/05 18:51:25 thib Exp $ SUBDIR= atactl badsect bioctl ccdconfig clri dhclient \ disklabel dmesg dump dumpfs fdisk fsck fsck_ext2fs fsck_ffs \ 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 \ diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8 index 1fe627b87b0..1d7a58b36a3 100644 --- a/sbin/mount/mount.8 +++ b/sbin/mount/mount.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mount.8,v 1.67 2010/09/28 17:42:52 jmc Exp $ +.\" $OpenBSD: mount.8,v 1.68 2011/04/05 18:51:25 thib Exp $ .\" $NetBSD: mount.8,v 1.11 1995/07/12 06:23:21 cgd Exp $ .\" .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)mount.8 8.7 (Berkeley) 3/27/94 .\" -.Dd $Mdocdate: September 28 2010 $ +.Dd $Mdocdate: April 5 2011 $ .Dt MOUNT 8 .Os .Sh NAME @@ -390,7 +390,6 @@ with option .Xr mount_nfs 8 , .Xr mount_nnpfs 8 , .Xr mount_ntfs 8 , -.Xr mount_portal 8 , .Xr mount_procfs 8 , .Xr mount_udf 8 , .Xr mount_vnd 8 , diff --git a/sbin/mount_portal/Makefile b/sbin/mount_portal/Makefile deleted file mode 100644 index 88fab6bc034..00000000000 --- a/sbin/mount_portal/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $OpenBSD: Makefile,v 1.8 2001/07/04 06:32:18 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 diff --git a/sbin/mount_portal/activate.c b/sbin/mount_portal/activate.c deleted file mode 100644 index 8937cc785e4..00000000000 --- a/sbin/mount_portal/activate.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $OpenBSD: activate.c,v 1.9 2008/03/24 16:11:08 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); -} diff --git a/sbin/mount_portal/conf.c b/sbin/mount_portal/conf.c deleted file mode 100644 index 51e2fcbfefc..00000000000 --- a/sbin/mount_portal/conf.c +++ /dev/null @@ -1,317 +0,0 @@ -/* $OpenBSD: conf.c,v 1.9 2004/06/06 00:12:03 tedu 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); -} diff --git a/sbin/mount_portal/mount_portal.8 b/sbin/mount_portal/mount_portal.8 deleted file mode 100644 index 271b0b3fc08..00000000000 --- a/sbin/mount_portal/mount_portal.8 +++ /dev/null @@ -1,144 +0,0 @@ -.\" $OpenBSD: mount_portal.8,v 1.19 2007/05/31 19:19:45 jmc 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. diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c deleted file mode 100644 index 727470bcfc5..00000000000 --- a/sbin/mount_portal/mount_portal.c +++ /dev/null @@ -1,286 +0,0 @@ -/* $OpenBSD: mount_portal.c,v 1.29 2009/10/27 23:59:33 deraadt 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); -} diff --git a/sbin/mount_portal/pathnames.h b/sbin/mount_portal/pathnames.h deleted file mode 100644 index 5dd127ac650..00000000000 --- a/sbin/mount_portal/pathnames.h +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: pathnames.h,v 1.5 2003/06/02 20:06:16 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 */ diff --git a/sbin/mount_portal/portal.conf b/sbin/mount_portal/portal.conf deleted file mode 100644 index 4ab04d14d73..00000000000 --- a/sbin/mount_portal/portal.conf +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: portal.conf,v 1.3 1996/12/08 22:22:38 tholo 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 diff --git a/sbin/mount_portal/portald.h b/sbin/mount_portal/portald.h deleted file mode 100644 index 64fef30caab..00000000000 --- a/sbin/mount_portal/portald.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: portald.h,v 1.6 2003/06/02 20:06:16 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); diff --git a/sbin/mount_portal/pt_conf.c b/sbin/mount_portal/pt_conf.c deleted file mode 100644 index be43907b7ae..00000000000 --- a/sbin/mount_portal/pt_conf.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: pt_conf.c,v 1.4 2003/06/02 20:06: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 } -}; diff --git a/sbin/mount_portal/pt_exec.c b/sbin/mount_portal/pt_exec.c deleted file mode 100644 index 3e19db8cf10..00000000000 --- a/sbin/mount_portal/pt_exec.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: pt_exec.c,v 1.5 2003/06/11 06:22:14 deraadt 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); -} diff --git a/sbin/mount_portal/pt_file.c b/sbin/mount_portal/pt_file.c deleted file mode 100644 index 0d32d056ef6..00000000000 --- a/sbin/mount_portal/pt_file.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: pt_file.c,v 1.9 2003/06/11 06:22:14 deraadt 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); -} diff --git a/sbin/mount_portal/pt_tcp.c b/sbin/mount_portal/pt_tcp.c deleted file mode 100644 index 2f66073cb14..00000000000 --- a/sbin/mount_portal/pt_tcp.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $OpenBSD: pt_tcp.c,v 1.13 2007/12/09 20:54:01 jmc Exp $ */ - -/* - * Copyright (c) 2004 Pedro Martelletto <pedro@ambientworks.net> - * 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); -} diff --git a/share/man/man4/options.4 b/share/man/man4/options.4 index 1069b06d199..781c3a25551 100644 --- a/share/man/man4/options.4 +++ b/share/man/man4/options.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: options.4,v 1.209 2011/04/05 12:50:15 guenther Exp $ +.\" $OpenBSD: options.4,v 1.210 2011/04/05 18:51:25 thib Exp $ .\" $NetBSD: options.4,v 1.21 1997/06/25 03:13:00 thorpej Exp $ .\" .\" Copyright (c) 1998 Theo de Raadt @@ -294,16 +294,6 @@ Experimental and read only. See .Xr mount_ntfs 8 for details. -.It Cd option PORTAL -Includes the (experimental) portal filesystem. -This permits interesting tricks like opening TCP sockets by opening files in -the file system. -The portal file system is conventionally mounted on -.Pa /p -and is partially implemented by a special daemon. -See -.Xr mount_portal 8 -for details. .It Cd option PROCFS Includes code for a special file system (conventionally mounted on .Pa /proc ) diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC index 0b8f27081ad..7a67d937224 100644 --- a/sys/conf/GENERIC +++ b/sys/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.173 2011/04/04 12:44:10 deraadt Exp $ +# $OpenBSD: GENERIC,v 1.174 2011/04/05 18:51:25 thib Exp $ # # Machine-independent option; used by all architectures for their # GENERIC kernel @@ -17,7 +17,7 @@ option KMEMSTATS # collect malloc(9) statistics option PTRACE # ptrace(2) system call #option KVA_GUARDPAGES # slow virtual address recycling (+ guarding) -option POOL_DEBUG # pool corruption detection +#option POOL_DEBUG # pool corruption detection #option VFSDEBUG # VFS locking checks option CRYPTO # Cryptographic framework diff --git a/sys/conf/files b/sys/conf/files index a1b986f9d52..23a786e8fe9 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.510 2011/04/05 12:50:15 guenther Exp $ +# $OpenBSD: files,v 1.511 2011/04/05 18:51:25 thib Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -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 diff --git a/sys/kern/Makefile b/sys/kern/Makefile index 33364686c5c..184b2121524 100644 --- a/sys/kern/Makefile +++ b/sys/kern/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2011/04/05 12:50:15 guenther Exp $ +# $OpenBSD: Makefile,v 1.29 2011/04/05 18:51:25 thib Exp $ # Makefile for kernel tags files, init_sysent, etc. @@ -37,7 +37,7 @@ DGEN= compat compat/common \ 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 \ diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index a71bf4ac355..c685e6f0082 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_conf.c,v 1.40 2010/12/21 20:14:43 thib Exp $ */ +/* $OpenBSD: vfs_conf.c,v 1.41 2011/04/05 18:51:25 thib Exp $ */ /* $NetBSD: vfs_conf.c,v 1.21.4.1 1995/11/01 00:06:26 jtc Exp $ */ /* @@ -91,10 +91,6 @@ extern const struct vfsops msdosfs_vfsops; 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 @@ -162,11 +158,6 @@ static struct vfsconf vfsconflist[] = { { &procfs_vfsops, MOUNT_PROCFS, 12, 0, 0, NULL }, #endif - /* Portal Filesystem */ -#ifdef PORTAL - { &portal_vfsops, MOUNT_PORTAL, 8, 0, 0, NULL }, -#endif - /* NTFS Filesystem */ #ifdef NTFS { &ntfs_vfsops, MOUNT_NTFS, 6, 0, MNT_LOCAL, NULL }, diff --git a/sys/miscfs/portal/portal.h b/sys/miscfs/portal/portal.h deleted file mode 100644 index dd7db01cfa4..00000000000 --- a/sys/miscfs/portal/portal.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: portal.h,v 1.5 2003/08/14 07:46:39 mickey 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 */ diff --git a/sys/miscfs/portal/portal_vfsops.c b/sys/miscfs/portal/portal_vfsops.c deleted file mode 100644 index ee959434394..00000000000 --- a/sys/miscfs/portal/portal_vfsops.c +++ /dev/null @@ -1,261 +0,0 @@ -/* $OpenBSD: portal_vfsops.c,v 1.24 2009/07/09 22:29:56 thib 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 -}; diff --git a/sys/miscfs/portal/portal_vnops.c b/sys/miscfs/portal/portal_vnops.c deleted file mode 100644 index d95f65cf01c..00000000000 --- a/sys/miscfs/portal/portal_vnops.c +++ /dev/null @@ -1,659 +0,0 @@ -/* $OpenBSD: portal_vnops.c,v 1.31 2009/08/14 16:32:21 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)); -} diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 16007f6e13e..bd05ec88c72 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.102 2011/04/04 15:22:10 thib Exp $ */ +/* $OpenBSD: mount.h,v 1.103 2011/04/05 18:51:26 thib Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -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 */ diff --git a/usr.sbin/procmap/procmap.c b/usr.sbin/procmap/procmap.c index fd280ad74ea..406219a5a33 100644 --- a/usr.sbin/procmap/procmap.c +++ b/usr.sbin/procmap/procmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procmap.c,v 1.34 2009/08/12 20:13:12 miod Exp $ */ +/* $OpenBSD: procmap.c,v 1.35 2011/04/05 18:51:26 thib Exp $ */ /* $NetBSD: pmap.c,v 1.1 2002/09/01 20:32:44 atatat Exp $ */ /* @@ -641,10 +641,7 @@ dump_vm_map_entry(kvm_t *kd, struct kbit *vmspace, case VT_NFS: case VT_MFS: case VT_MSDOSFS: - case VT_PORTAL: case VT_PROCFS: - case VT_AFS: - case VT_ADOSFS: default: break; } |