summaryrefslogtreecommitdiff
path: root/sbin/mount_portal
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/mount_portal')
-rw-r--r--sbin/mount_portal/Makefile19
-rw-r--r--sbin/mount_portal/activate.c205
-rw-r--r--sbin/mount_portal/conf.c317
-rw-r--r--sbin/mount_portal/mount_portal.8144
-rw-r--r--sbin/mount_portal/mount_portal.c286
-rw-r--r--sbin/mount_portal/pathnames.h42
-rw-r--r--sbin/mount_portal/portal.conf9
-rw-r--r--sbin/mount_portal/portald.h76
-rw-r--r--sbin/mount_portal/pt_conf.c49
-rw-r--r--sbin/mount_portal/pt_exec.c54
-rw-r--r--sbin/mount_portal/pt_file.c106
-rw-r--r--sbin/mount_portal/pt_tcp.c123
12 files changed, 0 insertions, 1430 deletions
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);
-}