1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

Rename (after a repo-copy) some mount(8) programs:

mount_fdesc -> mount_fdescfs
mount_null -> mount_nullfs
mount_portal -> mount_portalfs
mount_umap -> mount_umapfs
mount_union -> mount_unionfs
This commit is contained in:
Ruslan Ermilov 2001-05-23 14:58:19 +00:00
parent f3bb47cca0
commit 6ad10804f7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77042
49 changed files with 73 additions and 3299 deletions

View File

@ -166,7 +166,7 @@ The underlying file system does not support file flags.
.Xr fflagstostr 3 ,
.Xr strtofflags 3 ,
.Xr init 8 ,
.Xr mount_union 8
.Xr mount_unionfs 8
.Sh HISTORY
The
.Nm chflags

View File

@ -99,7 +99,7 @@ points outside the process's allocated address space.
.El
.Sh SEE ALSO
.Xr unlink 2 ,
.Xr mount_union 8
.Xr mount_unionfs 8
.Sh HISTORY
An
.Fn undelete

View File

@ -46,11 +46,11 @@ SUBDIR= adjkerntz \
mount_msdos \
mount_nfs \
mount_ntfs \
mount_null \
mount_portal \
mount_nullfs \
mount_portalfs \
mount_std \
mount_umap \
mount_union \
mount_umapfs \
mount_unionfs \
mountd \
natd \
newfs \

View File

@ -371,20 +371,20 @@ file system table
.Xr mount_cd9660 8 ,
.Xr mount_devfs 8 ,
.Xr mount_ext2fs 8 ,
.Xr mount_fdesc 8 ,
.Xr mount_fdescfs 8 ,
.Xr mount_hpfs 8 ,
.Xr mount_linprocfs 8 ,
.Xr mount_mfs 8 ,
.Xr mount_msdos 8 ,
.Xr mount_nfs 8 ,
.Xr mount_ntfs 8 ,
.Xr mount_null 8 ,
.Xr mount_nullfs 8 ,
.Xr mount_nwfs 8 ,
.Xr mount_portal 8 ,
.Xr mount_portalfs 8 ,
.Xr mount_procfs 8 ,
.Xr mount_std 8 ,
.Xr mount_umap 8 ,
.Xr mount_union 8 ,
.Xr mount_umapfs 8 ,
.Xr mount_unionfs 8 ,
.Xr umount 8
.Sh BUGS
It is possible for a corrupted file system to cause a crash.

View File

@ -1,12 +0,0 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_null
SRCS= mount_null.c getmntopts.c
MAN= mount_null.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,243 +0,0 @@
.\"
.\" 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
.\" John Heidemann of the UCLA Ficus project.
.\"
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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_null.8 8.6 (Berkeley) 5/1/95
.\" $FreeBSD$
.\"
.Dd May 1, 1995
.Dt MOUNT_NULL 8
.Os BSD 4.4
.Sh NAME
.Nm mount_null
.Nd "mount a loopback filesystem sub-tree; demonstrate the use of a null file system layer"
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
.Ar target
.Ar mount-point
.Sh DESCRIPTION
The
.Nm
command creates a
null layer, duplicating a sub-tree of the file system
name space under another part of the global file system namespace.
This allows existing files and directories to be accessed
using a different pathname.
.Pp
The primary differences between a virtual copy of the filesystem
and a symbolic link are that
.Xr getcwd 3
functions correctly in the virtual copy, and that other filesystems
may be mounted on the virtual copy without affecting the original.
A different device number for the virtual copy is returned by
.Xr stat 2 ,
but in other respects it is indistinguishable from the original.
.Pp
The
.Nm
filesystem differs from a traditional
loopback file system in two respects: it is implemented using
a stackable layers techniques, and it's
.Do null-node Dc Ns s
stack above
all lower-layer vnodes, not just over directory vnodes.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
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 null layer has two purposes.
First, it serves as a demonstration of layering by providing a layer
which does nothing.
(It actually does everything the loopback file system does,
which is slightly more than nothing.)
Second, the null layer can serve as a prototype layer.
Since it provides all necessary layer framework,
new file system layers can be created very easily by starting
with a null layer.
.Pp
The remainder of this man page examines the null layer as a basis
for constructing new layers.
.\"
.\"
.Sh INSTANTIATING NEW NULL LAYERS
New null layers are created with
.Xr mount_null 8 .
.Xr Mount_null 8
takes two arguments, the pathname
of the lower vfs (target-pn) and the pathname where the null
layer will appear in the namespace (mount-point-pn). After
the null layer is put into place, the contents
of target-pn subtree will be aliased under mount-point-pn.
.\"
.\"
.Sh OPERATION OF A NULL LAYER
The null layer is the minimum file system layer,
simply bypassing all possible operations to the lower layer
for processing there. The majority of its activity centers
on the bypass routine, through which nearly all vnode operations
pass.
.Pp
The bypass routine accepts arbitrary vnode operations for
handling by the lower layer. It begins by examining vnode
operation arguments and replacing any null-nodes by their
lower-layer equivalents. It then invokes the operation
on the lower layer. Finally, it replaces the null-nodes
in the arguments and, if a vnode is returned by the operation,
stacks a null-node on top of the returned vnode.
.Pp
Although bypass handles most operations,
.Em vop_getattr ,
.Em vop_inactive ,
.Em vop_reclaim ,
and
.Em vop_print
are not bypassed.
.Em Vop_getattr
must change the fsid being returned.
.Em Vop_inactive
and
.Em vop_reclaim
are not bypassed so that
they can handle freeing null-layer specific data.
.Em Vop_print
is not bypassed to avoid excessive debugging
information.
.\"
.\"
.Sh INSTANTIATING VNODE STACKS
Mounting associates the null layer with a lower layer,
in effect stacking two VFSes. Vnode stacks are instead
created on demand as files are accessed.
.Pp
The initial mount creates a single vnode stack for the
root of the new null layer. All other vnode stacks
are created as a result of vnode operations on
this or other null vnode stacks.
.Pp
New vnode stacks come into existence as a result of
an operation which returns a vnode.
The bypass routine stacks a null-node above the new
vnode before returning it to the caller.
.Pp
For example, imagine mounting a null layer with
.Bd -literal -offset indent
mount_null /usr/include /dev/layer/null
.Ed
Changing directory to
.Pa /dev/layer/null
will assign
the root null-node (which was created when the null layer was mounted).
Now consider opening
.Pa sys .
A vop_lookup would be
done on the root null-node. This operation would bypass through
to the lower layer which would return a vnode representing
the UFS
.Pa sys .
Null_bypass then builds a null-node
aliasing the UFS
.Pa sys
and returns this to the caller.
Later operations on the null-node
.Pa sys
will repeat this
process when constructing other vnode stacks.
.\"
.\"
.Sh CREATING OTHER FILE SYSTEM LAYERS
One of the easiest ways to construct new file system layers is to make
a copy of the null layer, rename all files and variables, and
then begin modifying the copy.
.Xr Sed 1
can be used to easily rename
all variables.
.Pp
The umap layer is an example of a layer descended from the
null layer.
.\"
.\"
.Sh INVOKING OPERATIONS ON LOWER LAYERS
There are two techniques to invoke operations on a lower layer
when the operation cannot be completely bypassed. Each method
is appropriate in different situations. In both cases,
it is the responsibility of the aliasing layer to make
the operation arguments "correct" for the lower layer
by mapping a vnode argument to the lower layer.
.Pp
The first approach is to call the aliasing layer's bypass routine.
This method is most suitable when you wish to invoke the operation
currently being handled on the lower layer.
It has the advantage that
the bypass routine already must do argument mapping.
An example of this is
.Em null_getattrs
in the null layer.
.Pp
A second approach is to directly invoke vnode operations on
the lower layer with the
.Em VOP_OPERATIONNAME
interface.
The advantage of this method is that it is easy to invoke
arbitrary operations on the lower layer. The disadvantage
is that vnode arguments must be manually mapped.
.\"
.\"
.Sh SEE ALSO
.Xr mount 8
.Pp
UCLA Technical Report CSD-910056,
.Em "Stackable Layers: an Architecture for File System Development" .
.Sh BUGS
THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
.Pp
This code also needs an owner in order to be less dangerous - serious
hackers can apply by sending mail to hackers@freebsd.org and announcing
their intent to take it over.
.Sh HISTORY
The
.Nm
utility first appeared in
.Bx 4.4 .

View File

@ -1,148 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*/
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <fs/nullfs/null.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
struct mntopt mopts[] = {
MOPT_STDOPTS,
{ NULL }
};
int subdir __P((const char *, const char *));
static void usage __P((void)) __dead2;
int
main(argc, argv)
int argc;
char *argv[];
{
struct null_args args;
int ch, mntflags;
char source[MAXPATHLEN];
char target[MAXPATHLEN];
struct vfsconf vfc;
int error;
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
switch(ch) {
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
/* resolve target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
argv[0], target, argv[1]);
args.target = target;
error = getvfsbyname("nullfs", &vfc);
if (error && vfsisloadable("nullfs")) {
if(vfsload("nullfs"))
err(EX_OSERR, "vfsload(nullfs)");
endvfsent();
error = getvfsbyname("nullfs", &vfc);
}
if (error)
errx(EX_OSERR, "null/loopback filesystem is not available");
if (mount(vfc.vfc_name, source, mntflags, &args))
err(1, NULL);
exit(0);
}
int
subdir(p, dir)
const char *p;
const char *dir;
{
int l;
l = strlen(dir);
if (l <= 1)
return (1);
if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
return (1);
return (0);
}
static void
usage()
{
(void)fprintf(stderr,
"usage: mount_null [-o options] target_fs mount_point\n");
exit(1);
}

View File

@ -1,9 +1,9 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_null
SRCS= mount_null.c getmntopts.c
MAN= mount_null.8
PROG= mount_nullfs
SRCS= mount_nullfs.c getmntopts.c
MAN= mount_nullfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}

View File

@ -38,10 +38,10 @@
.\" $FreeBSD$
.\"
.Dd May 1, 1995
.Dt MOUNT_NULL 8
.Os BSD 4.4
.Dt MOUNT_NULLFS 8
.Os
.Sh NAME
.Nm mount_null
.Nm mount_nullfs
.Nd "mount a loopback filesystem sub-tree; demonstrate the use of a null file system layer"
.Sh SYNOPSIS
.Nm
@ -102,8 +102,8 @@ for constructing new layers.
.\"
.Sh INSTANTIATING NEW NULL LAYERS
New null layers are created with
.Xr mount_null 8 .
.Xr Mount_null 8
.Nm .
.Nm Mount_nullfs
takes two arguments, the pathname
of the lower vfs (target-pn) and the pathname where the null
layer will appear in the namespace (mount-point-pn). After
@ -162,7 +162,7 @@ vnode before returning it to the caller.
.Pp
For example, imagine mounting a null layer with
.Bd -literal -offset indent
mount_null /usr/include /dev/layer/null
mount_nullfs /usr/include /dev/layer/null
.Ed
Changing directory to
.Pa /dev/layer/null

View File

@ -143,6 +143,6 @@ static void
usage()
{
(void)fprintf(stderr,
"usage: mount_null [-o options] target_fs mount_point\n");
"usage: mount_nullfs [-o options] target_fs mount_point\n");
exit(1);
}

View File

@ -1,13 +0,0 @@
# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
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 pt_tcplisten.c
MAN= mount_portal.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,214 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)activate.c 8.3 (Berkeley) 4/28/95
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.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(pcr, key, v, so, fdp)
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(so, pcr, key, klen)
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;
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(so, fd, error)
int so;
int fd;
int error;
{
int n;
struct iovec iov;
struct msghdr msg;
struct {
struct cmsghdr cmsg;
int fd;
} ctl;
/*
* 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
*/
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) {
ctl.fd = fd;
ctl.cmsg.cmsg_len = sizeof(ctl);
ctl.cmsg.cmsg_level = SOL_SOCKET;
ctl.cmsg.cmsg_type = SCM_RIGHTS;
msg.msg_control = (caddr_t) &ctl;
msg.msg_controllen = ctl.cmsg.cmsg_len;
}
/*
* Send to kernel...
*/
if ((n = sendmsg(so, &msg, 0)) < 0)
syslog(LOG_ERR, "send: %s", strerror(errno));
#ifdef DEBUG
fprintf(stderr, "sent %d bytes\n", n);
#endif
sleep(1); /*XXX*/
#ifdef notdef
if (shutdown(so, 2) < 0)
syslog(LOG_ERR, "shutdown: %s", strerror(errno));
#endif
/*
* Throw away the open file descriptor
*/
(void) close(fd);
}
void activate(q, so)
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: %s", strerror(error));
goto drop;
}
#ifdef DEBUG
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);
}

View File

@ -1,340 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)conf.c 8.2 (Berkeley) 3/27/94
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.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_rx; /* RE to match against pathname () */
int p_rxvalid; /* non-zero if valid regular expression */
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 */
static path *curp; /* XXX for regerror */
/*
* Add an element to a 2-way list,
* just after (pred)
*/
static void ins_que(elem, pred)
qelem *elem, *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(elem)
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(siz)
unsigned siz;
{
void *p = malloc(siz);
if (p)
return (p);
syslog(LOG_ALERT, "malloc: failed to get %d 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(p0, q0)
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(cline, lno)
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);
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);
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++)
printf("%sv[%d] = %s\n", c?"\t":"", c, p->p_argv[c]);
#endif
p->p_key = p->p_argv[0];
if (strpbrk(p->p_key, RE_CHARS)) {
int val;
curp = p; /* XXX */
val = regcomp(&p->p_rx, p->p_key, REG_EXTENDED | REG_NOSUB);
if (val) {
char errbuf[_POSIX2_LINE_MAX];
regerror(val, &p->p_rx, errbuf, sizeof errbuf);
syslog(LOG_ERR, "%s:%d: regcomp %s: %s",
conf_file, curp->p_lno, curp->p_key, errbuf);
regfree(&p->p_rx);
p->p_rxvalid = 0;
} else {
p->p_rxvalid = 1;
}
curp = 0; /* XXX */
} else {
p->p_rxvalid = 0;
}
p->p_lno = lno;
return (p);
}
/*
* Free a path structure
*/
static void pfree(p)
path *p;
{
free(p->p_args);
if (p->p_rxvalid) {
regfree(&p->p_rx);
}
free((char *) p->p_argv);
free((char *) p);
}
/*
* Discard all currently held path structures on q0.
* and add all the ones on xq.
*/
static void preplace(q0, xq)
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(q0, fp)
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(q, conf)
qelem *q;
char *conf;
{
FILE *fp = fopen(conf, "r");
if (fp) {
conf_file = conf; /* XXX */
readfp(q, fp);
conf_file = 0; /* XXX */
(void) fclose(fp);
} else {
syslog(LOG_ERR, "open config file \"%s\": %s", conf, strerror(errno));
}
}
char **conf_match(q0, key)
qelem *q0;
char *key;
{
qelem *q;
for (q = q0->q_forw; q != q0; q = q->q_forw) {
path *p = (path *) q;
if (p->p_rxvalid) {
if (!regexec(&p->p_rx, key, 0, 0, 0)) {
return p->p_argv + 1;
}
} else {
if (strncmp(p->p_key, key, strlen(p->p_key)) == 0)
return (p->p_argv+1);
}
}
return (0);
}

View File

@ -1,152 +0,0 @@
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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
.\" $FreeBSD$
.\"
.Dd March 27, 1994
.Dt MOUNT_PORTAL 8
.Os BSD 4.4
.Sh NAME
.Nm mount_portal
.Nd mount the portal daemon
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
.Ar /etc/portal.conf
.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 .
.\" .PA /dev .
This command is normally executed by
.Xr mount 8
at boot time.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
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 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
The following sub-namespaces are currently implemented:
.Pa tcplisten ,
.Pa tcp
and
.Pa fs .
The
.Pa tcplisten
namespace takes a slash separated hostname and port and creates a TCP/IP
socket bound to the given hostname-port pair.
The hostname may be
specified as "ANY" to allow any other host to connect to the socket.
A
port number of 0 will dynamically allocate a port, this can be
discovered by calling
.Xr getsockname 2
with the returned file descriptor.
Privileged ports can only be bound to
by the super-user.
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 (``#'') 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
tcplisten/ tcplisten tcplisten/
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 unmount 2 ,
.Xr fstab 5 ,
.Xr mount 8
.Sh CAVEATS
This filesystem may not be NFS-exported.
.Sh HISTORY
The
.Nm
utility first appeared in
.Bx 4.4 .

View File

@ -1,295 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/syslog.h>
#include <sys/mount.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
#include "pathnames.h"
#include "portald.h"
struct mntopt mopts[] = {
MOPT_STDOPTS,
{ NULL }
};
static void usage __P((void)) __dead2;
static sig_atomic_t readcf; /* Set when SIGHUP received */
static void sighup(sig)
int sig;
{
readcf ++;
}
static void sigchld(sig)
int sig;
{
pid_t pid;
while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0)
;
/* wrtp - waitpid _doesn't_ return 0 when no children! */
#ifdef notdef
if (pid < 0 && errno != ECHILD)
syslog(LOG_WARNING, "waitpid: %s", strerror(errno));
#endif
}
int
main(argc, argv)
int argc;
char *argv[];
{
struct portal_args args;
struct sockaddr_un un;
char *conf;
char mountpt[MAXPATHLEN];
int mntflags = 0;
char tag[32];
struct vfsconf vfc;
mode_t um;
qelem q;
int rc;
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, 0);
break;
default:
error = 1;
break;
}
}
if (optind != (argc - 2))
error = 1;
if (error)
usage();
/*
* Get config file and mount point
*/
conf = argv[optind];
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[optind+1], mountpt);
/*
* Construct the listening socket
*/
un.sun_family = AF_UNIX;
if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) {
errx(EX_SOFTWARE, "portal socket name too long");
}
strcpy(un.sun_path, _PATH_TMPPORTAL);
mktemp(un.sun_path);
un.sun_len = strlen(un.sun_path);
so = socket(AF_UNIX, SOCK_STREAM, 0);
if (so < 0) {
err(EX_OSERR, "socket");
}
um = umask(077);
(void) unlink(un.sun_path);
if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0)
err(1, NULL);
(void) unlink(un.sun_path);
(void) umask(um);
(void) listen(so, 5);
args.pa_socket = so;
sprintf(tag, "portal:%d", getpid());
args.pa_config = tag;
error = getvfsbyname("portal", &vfc);
if (error && vfsisloadable("portal")) {
if (vfsload("portal"))
err(EX_OSERR, "vfsload(portal)");
endvfsent();
error = getvfsbyname("portal", &vfc);
}
if (error)
errx(EX_OSERR, "portal filesystem is not available");
rc = mount(vfc.vfc_name, mountpt, mntflags, &args);
if (rc < 0)
err(1, NULL);
/*
* Everything is ready to go - now is a good time to fork
*/
#ifndef DEBUG
daemon(0, 0);
#endif
/*
* Start logging (and change name)
*/
openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON);
q.q_forw = q.q_back = &q;
readcf = 1;
signal(SIGCHLD, sigchld);
signal(SIGHUP, sighup);
/*
* Just loop waiting for new connections and activating them
*/
for (;;) {
struct sockaddr_un un2;
int len2 = sizeof(un2);
int so2;
pid_t pid;
fd_set fdset;
int rc;
/*
* Check whether we need to re-read the configuration file
*/
if (readcf) {
#ifdef DEBUG
printf ("re-reading configuration file\n");
#endif
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
*/
FD_ZERO(&fdset);
FD_SET(so, &fdset);
rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0);
if (rc < 0) {
if (errno == EINTR)
continue;
syslog(LOG_ERR, "select: %s", strerror(errno));
exit(EX_OSERR);
}
if (rc == 0)
break;
so2 = accept(so, (struct sockaddr *) &un2, &len2);
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: %s", strerror(errno));
exit(EX_OSERR);
}
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: %s", strerror(errno));
break;
case 0:
(void) close(so);
activate(&q, so2);
exit(0);
default:
(void) close(so2);
break;
}
}
syslog(LOG_INFO, "%s unmounted", mountpt);
exit(0);
}
static void
usage()
{
(void)fprintf(stderr,
"usage: mount_portal [-o options] config mount-point\n");
exit(EX_USAGE);
}

View File

@ -1,44 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/5/93
*
* $FreeBSD$
*/
#include <paths.h>
#define _PATH_TMPPORTAL "/tmp/portalXXXXXXXXXX" /* Scratch socket name */

View File

@ -1,7 +0,0 @@
# @(#)portal.conf 8.1 (Berkeley) 6/5/93
# $FreeBSD$
tcplisten/ tcplisten tcplisten/
tcp/ tcp tcp/
fs/ file fs/
pipe/ pipe
foo/ exec ./bar bar baz

View File

@ -1,84 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)portald.h 8.1 (Berkeley) 6/5/93
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
#include <fs/portalfs/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) __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
};
extern provider providers[];
/*
* Portal providers
*/
extern int portal_exec __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_file __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_tcp __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_tcplisten __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
/*
* Global functions
*/
extern void activate __P((qelem *q, int so));
extern char **conf_match __P((qelem *q, char *key));
extern void conf_read __P((qelem *q, char *conf));

View File

@ -1,55 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pt_conf.c 8.1 (Berkeley) 6/5/93
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/param.h>
#include "portald.h"
provider providers[] = {
{ "exec", portal_exec },
{ "file", portal_file },
{ "tcp", portal_tcp },
{ "tcplisten", portal_tcplisten },
{ 0, 0 }
};

View File

@ -1,60 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pt_exec.c 8.1 (Berkeley) 6/5/93
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
#include "portald.h"
int portal_exec(pcr, key, v, so, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int so;
int *fdp;
{
return (ENOEXEC);
}

View File

@ -1,109 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pt_file.c 8.3 (Berkeley) 7/3/94
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syslog.h>
#include "portald.h"
int portal_file(pcr, key, v, so, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int so;
int *fdp;
{
int fd;
char pbuf[MAXPATHLEN];
int error;
gid_t gidset[NGROUPS];
int i;
pbuf[0] = '/';
strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0));
#ifdef DEBUG
printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_groups[0]);
printf ("fflag = %x, oflag = %x\n", pcr->pcr_flag, (pcr->pcr_flag)-1);
#endif
for (i = 0; i < pcr->pcr_ngroups; i++)
gidset[i] = pcr->pcr_groups[i];
if (setgroups(pcr->pcr_ngroups, gidset) < 0)
return (errno);
if (seteuid(pcr->pcr_uid) < 0)
return (errno);
/* dmb convert kernel flags to oflags, see <fcntl.h> */
fd = open(pbuf, (pcr->pcr_flag)-1, 0777);
if (fd < 0)
error = errno;
else
error = 0;
if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */
error = errno;
syslog(LOG_ERR, "setcred: %s", strerror(error));
if (fd >= 0) {
(void) close(fd);
fd = -1;
}
}
if (error == 0)
*fdp = fd;
#ifdef DEBUG
fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, error);
#endif
return (error);
}

View File

@ -1,167 +0,0 @@
/*
* Copyright (c) 1992, 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pt_tcp.c 8.5 (Berkeley) 4/28/95
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <errno.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "portald.h"
/*
* Key will be tcp/host/port[/"priv"]
* Create a TCP socket connected to the
* requested host and port.
* Some trailing suffix values have special meanings.
* An unrecognized suffix is an error.
*/
int portal_tcp(pcr, key, v, kso, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int kso;
int *fdp;
{
char host[MAXHOSTNAMELEN];
char port[MAXHOSTNAMELEN];
char *p = key + (v[1] ? strlen(v[1]) : 0);
char *q;
struct hostent *hp;
struct servent *sp;
struct in_addr **ipp;
struct in_addr *ip[2];
struct in_addr ina;
u_short s_port;
int priv = 0;
struct sockaddr_in sain;
q = strchr(p, '/');
if (q == 0 || q - p >= sizeof(host))
return (EINVAL);
*q = '\0';
strcpy(host, p);
p = q + 1;
q = strchr(p, '/');
if (q)
*q = '\0';
if (strlen(p) >= sizeof(port))
return (EINVAL);
strcpy(port, p);
if (q) {
p = q + 1;
if (strcmp(p, "priv") == 0) {
if (pcr->pcr_uid == 0)
priv = 1;
else
return (EPERM);
} else {
return (EINVAL);
}
}
hp = gethostbyname(host);
if (hp != 0) {
ipp = (struct in_addr **) hp->h_addr_list;
} else {
ina.s_addr = inet_addr(host);
if (ina.s_addr == INADDR_NONE)
return (EINVAL);
ip[0] = &ina;
ip[1] = 0;
ipp = ip;
}
#ifdef DEBUG
printf ("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
#endif
sp = getservbyname(port, "tcp");
if (sp != NULL) {
s_port = (u_short)sp->s_port;
} else {
s_port = strtoul(port, &p, 0);
if (s_port == 0 || *p != '\0')
return (EINVAL);
s_port = htons(s_port);
}
#ifdef DEBUG
printf ("port number for %s is %d\n", port, (int)ntohs(s_port));
#endif
memset(&sain, 0, sizeof(sain));
sain.sin_len = sizeof(sain);
sain.sin_family = AF_INET;
sain.sin_port = s_port;
while (ipp[0]) {
int so;
if (priv)
so = rresvport((int *) 0);
else
so = socket(AF_INET, SOCK_STREAM, 0);
if (so < 0) {
syslog(LOG_ERR, "socket: %m");
return (errno);
}
sain.sin_addr = *ipp[0];
if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
*fdp = so;
return (0);
}
(void) close(so);
ipp++;
}
return (errno);
}

View File

@ -1,206 +0,0 @@
/*
* 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.
*
* Modified by Duncan Barclay.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94
*
* pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "portald.h"
/*
* Key will be tcplisten/host/port
*
* Create a TCP socket bound to the requested host and port.
* If the host is "ANY" the receving address will be set to INADDR_ANY.
* If the port is 0 the caller must find out the returned port number
* using a call to getsockname.
*
* XXX! The owner of the socket will be root rather then the user. This
* may cause remote auth (identd) to return unexpected results.
*
*/
int portal_tcplisten(pcr, key, v, kso, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int kso;
int *fdp;
{
char host[MAXHOSTNAMELEN];
char port[MAXHOSTNAMELEN];
char *p = key + (v[1] ? strlen(v[1]) : 0);
char *q;
struct hostent *hp;
struct servent *sp;
struct in_addr **ipp;
struct in_addr *ip[2];
struct in_addr ina;
u_short s_port;
int any = 0;
struct sockaddr_in sain;
q = strchr(p, '/');
if (q == 0 || q - p >= sizeof(host))
return (EINVAL);
*q = '\0';
snprintf(host, sizeof(host), "%s", p);
p = q + 1;
q = strchr(p, '/');
if (q)
*q = '\0';
if (strlen(p) >= sizeof(port))
return (EINVAL);
snprintf(port, sizeof(port), "%s", p);
if (strcmp(host, "ANY") == 0) {
any = 1;
} else {
hp = gethostbyname(host);
if (hp != 0) {
ipp = (struct in_addr **) hp->h_addr_list;
} else {
ina.s_addr = inet_addr(host);
if (ina.s_addr == INADDR_NONE)
return (EINVAL);
ip[0] = &ina;
ip[1] = 0;
ipp = ip;
}
}
#ifdef DEBUG
if (any)
printf("INADDR_ANY to be used for hostname\n");
else
printf("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
#endif
sp = getservbyname(port, "tcp");
if (sp != NULL) {
s_port = (u_short) sp->s_port;
} else {
s_port = strtoul(port, &p, 0);
if (*p != '\0')
return (EINVAL);
s_port = htons(s_port);
}
if ((ntohs(s_port) != 0) &&
(ntohs(s_port) <= IPPORT_RESERVED) &&
(pcr->pcr_uid != 0))
return (EPERM);
#ifdef DEBUG
printf("port number for %s is %d\n", port, ntohs(s_port));
#endif
memset(&sain, 0, sizeof(sain));
sain.sin_len = sizeof(sain);
sain.sin_family = AF_INET;
sain.sin_port = s_port;
if (any) {
int so;
int sock;
so = socket(AF_INET, SOCK_STREAM, 0);
if (so < 0) {
syslog(LOG_ERR, "socket: %m");
return (errno);
}
sain.sin_addr.s_addr = INADDR_ANY;
if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
listen(so, 1);
if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
syslog(LOG_ERR, "accept: %m");
(void) close(so);
return (errno);
}
*fdp = sock;
(void) close(so);
return (0);
}
syslog(LOG_ERR, "bind: %m");
(void) close(so);
return (errno);
}
while (ipp[0]) {
int so;
int sock;
so = socket(AF_INET, SOCK_STREAM, 0);
if (so < 0) {
syslog(LOG_ERR, "socket: %m");
return (errno);
}
sain.sin_addr = *ipp[0];
if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
listen(so, 1);
if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
syslog(LOG_ERR, "accept: %m");
(void) close(so);
return (errno);
}
*fdp = sock;
(void) close(so);
return (0);
}
(void) close(so);
ipp++;
}
syslog(LOG_ERR, "bind: %m");
return (errno);
}

View File

@ -1,10 +1,10 @@
# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_portal
SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
PROG= mount_portalfs
SRCS= mount_portalfs.c activate.c conf.c getmntopts.c pt_conf.c \
pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c
MAN= mount_portal.8
MAN= mount_portalfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}

View File

@ -38,10 +38,10 @@
.\" $FreeBSD$
.\"
.Dd March 27, 1994
.Dt MOUNT_PORTAL 8
.Os BSD 4.4
.Dt MOUNT_PORTALFS 8
.Os
.Sh NAME
.Nm mount_portal
.Nm mount_portalfs
.Nd mount the portal daemon
.Sh SYNOPSIS
.Nm

View File

@ -290,6 +290,6 @@ static void
usage()
{
(void)fprintf(stderr,
"usage: mount_portal [-o options] config mount-point\n");
"usage: mount_portalfs [-o options] config mount-point\n");
exit(EX_USAGE);
}

View File

@ -5,7 +5,7 @@ PROG= mount_std
SRCS= mount_std.c getmntopts.c
MAN= mount_std.8
MLINKS= mount_std.8 mount_devfs.8 \
mount_std.8 mount_fdesc.8 \
mount_std.8 mount_fdescfs.8 \
mount_std.8 mount_linprocfs.8 \
mount_std.8 mount_procfs.8
@ -14,7 +14,7 @@ CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}
LINKS= ${BINDIR}/mount_std ${BINDIR}/mount_devfs \
${BINDIR}/mount_std ${BINDIR}/mount_fdesc \
${BINDIR}/mount_std ${BINDIR}/mount_fdescfs \
${BINDIR}/mount_std ${BINDIR}/mount_linprocfs \
${BINDIR}/mount_std ${BINDIR}/mount_procfs

View File

@ -38,14 +38,16 @@
.\"
.Dd May 13, 1996
.Dt MOUNT_STD 8
.Os FreeBSD
.Os
.Sh NAME
.Nm mount_std ,
.Nm mount_devfs ,
.Nm mount_fdesc ,
.Nm mount_fdescfs ,
.Nm mount_linprocfs ,
.Nm mount_procfs
.Nd mount ``standard'' filesystems
.Nd mount
.Dq standard
filesystems
.Sh SYNOPSIS
.Nm mount_ Ns Ar fsname
.Op Fl o Ar options
@ -59,7 +61,7 @@ the filesystem. The
.Nm
command currently supports the following filesystems:
.Nm devfs ,
.Nm fdesc ,
.Nm fdescfs ,
.Nm linprocfs
and
.Nm procfs .
@ -70,7 +72,7 @@ accepts only the standard
.Fl o
options
.Dq ro
.Pq ``rdonly'' ,
.Pq Dq rdonly ,
.Dq rw ,
.Dq nodev ,
.Dq noexec ,
@ -119,7 +121,7 @@ command.
Refer to the following manual pages for detailed information
on these file system:
.Xr devfs 5 ,
.Xr fdesc 5 ,
.Xr fdescfs 5 ,
.Xr linprocfs 5
and
.Xr procfs 5 .
@ -142,7 +144,7 @@ loadable module for it was found.
.Xr unmount 2 ,
.Xr getvfsbyname 3 ,
.Xr devfs 5 ,
.Xr fdesc 5 ,
.Xr fdescfs 5 ,
.Xr fstab 5 ,
.Xr linprocfs 5 ,
.Xr procfs 5 ,
@ -157,7 +159,7 @@ utility first appeared in
Loadable filesystem modules first appeared in
.Fx 2.0 .
The
.Dq fdesc
.Dq fdescfs
and
.Dq procfs
filesystem types first appeared in

View File

@ -1,12 +0,0 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_umap
SRCS= mount_umap.c getmntopts.c
MAN= mount_umap.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,138 +0,0 @@
.\" Copyright (c) 1992, 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 and from John Heidemann of the UCLA Ficus project.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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_umap.8 8.4 (Berkeley) 5/1/95
.\" $FreeBSD$
.\"
.Dd May 1, 1995
.Dt MOUNT_UMAP 8
.Os BSD 4.4
.Sh NAME
.Nm mount_umap
.Nd sample file system layer
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
.Fl u Ar uid-mapfile
.Fl g Ar gid-mapfile
.Ar target
.Ar mount-point
.Sh DESCRIPTION
The
.Nm
command is used to mount a sub-tree of an existing file system
that uses a different set of uids and gids than the local system.
Such a file system could be mounted from a remote site via NFS or
it could be a file system on removable media brought from some
foreign location that uses a different password file.
.Pp
The
.Nm
command uses a set of files provided by the user to make correspondences
between uids and gids in the sub-tree's original environment and
some other set of ids in the local environment. For instance, user
smith might have uid 1000 in the original environment, while having
uid 2000 in the local environment. The
.Nm
command allows the subtree from smith's original environment to be
mapped in such a way that all files with owning uid 1000 look like
they are actually owned by uid 2000.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
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.
.It Ar target
Should be the current location of the sub-tree in the
local system's name space.
.It Ar mount-point
Should be a directory
where the mapped subtree is to be placed.
.It Fl u Ar uid-mapfile
.It Fl g Ar gid-mapfile
Describe the mappings to be made between identifiers.
Briefly, the format of these files is a count of the number of
mappings on the first line, with each subsequent line containing
a single mapping. Each of these mappings consists of an id in
the local environment and the corresponding id from the original environment,
separated by white space.
.Ar Uid-mapfile
should contain all uid
mappings, and
.Ar gid-mapfile
should contain all gid mappings.
Any uids not mapped in
.Ar uid-mapfile
will be treated as user NOBODY,
and any gids not mapped in
.Ar gid-mapfile
will be treated as group
NULLGROUP. At most 64 uids can be mapped for a given subtree, and
at most 16 groups can be mapped by a given subtree.
.El
.Pp
The mapfiles can be located anywhere in the file hierarchy, but they
must be owned by root, and they must be writable only by root.
.Nm Mount_umap
will refuse to map the sub-tree if the ownership or permissions on
these files are improper. It will also balk if the count of mappings
in the first line of the map files is not correct.
.Pp
The layer created by the
.Nm
command is meant to serve as a simple example of file system layering.
It is not meant for production use. The implementation is not very
sophisticated.
.Sh SEE ALSO
.Xr mount 8 ,
.Xr mount_null 8
.Sh BUGS
THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
.Pp
This code also needs an owner in order to be less dangerous - serious
hackers can apply by sending mail to hackers@freebsd.org and announcing
their intent to take it over.
.Sh HISTORY
The
.Nm
utility first appeared in
.Bx 4.4 .

View File

@ -1,250 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*/
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mount_umap.c 8.5 (Berkeley) 4/26/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <fs/umapfs/umap.h>
#include <err.h>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
#define ROOTUSER 0
/*
* This define controls whether any user but the superuser can own and
* write mapfiles. If other users can, system security can be gravely
* compromised. If this is not a concern, undefine SECURITY.
*/
#define MAPSECURITY 1
/*
* This routine provides the user interface to mounting a umap layer.
* It takes 4 mandatory parameters. The mandatory arguments are the place
* where the next lower level is mounted, the place where the umap layer is to
* be mounted, the name of the user mapfile, and the name of the group
* mapfile. The routine checks the ownerships and permissions on the
* mapfiles, then opens and reads them. Then it calls mount(), which
* will, in turn, call the umap version of mount.
*/
static struct mntopt mopts[] = {
MOPT_STDOPTS,
{ NULL }
};
static void usage __P((void)) __dead2;
int
main(argc, argv)
int argc;
char *argv[];
{
static char not[] = "; not mounted";
struct stat statbuf;
struct umap_args args;
FILE *fp, *gfp;
u_long gmapdata[GMAPFILEENTRIES][2], mapdata[MAPFILEENTRIES][2];
int ch, count, gnentries, mntflags, nentries;
char *gmapfile, *mapfile, buf[20];
char source[MAXPATHLEN], target[MAXPATHLEN];
struct vfsconf vfc;
int error;
mntflags = 0;
mapfile = gmapfile = NULL;
while ((ch = getopt(argc, argv, "g:o:u:")) != -1)
switch (ch) {
case 'g':
gmapfile = optarg;
break;
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
case 'u':
mapfile = optarg;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 2 || mapfile == NULL || gmapfile == NULL)
usage();
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], source);
(void)checkpath(argv[1], target);
/* Read in uid mapping data. */
if ((fp = fopen(mapfile, "r")) == NULL)
err(EX_NOINPUT, "%s%s", mapfile, not);
#ifdef MAPSECURITY
/*
* Check that group and other don't have write permissions on
* this mapfile, and that the mapfile belongs to root.
*/
if (fstat(fileno(fp), &statbuf))
err(EX_OSERR, "%s%s", mapfile, not);
if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) {
strmode(statbuf.st_mode, buf);
err(EX_NOPERM, "%s: improper write permissions (%s)%s",
mapfile, buf, not);
}
if (statbuf.st_uid != ROOTUSER)
errx(EX_NOPERM, "%s does not belong to root%s", mapfile, not);
#endif /* MAPSECURITY */
if ((fscanf(fp, "%d\n", &nentries)) != 1)
errx(EX_DATAERR, "%s: nentries not found%s", mapfile, not);
if (nentries > MAPFILEENTRIES)
errx(EX_DATAERR,
"maximum number of entries is %d%s", MAPFILEENTRIES, not);
#if 0
(void)printf("reading %d entries\n", nentries);
#endif
for (count = 0; count < nentries; ++count) {
if ((fscanf(fp, "%lu %lu\n",
&(mapdata[count][0]), &(mapdata[count][1]))) != 2) {
if (ferror(fp))
err(EX_OSERR, "%s%s", mapfile, not);
if (feof(fp))
errx(EX_DATAERR, "%s: unexpected end-of-file%s",
mapfile, not);
errx(EX_DATAERR, "%s: illegal format (line %d)%s",
mapfile, count + 2, not);
}
#if 0
/* Fix a security hole. */
if (mapdata[count][1] == 0)
errx(1, "mapping id 0 not permitted (line %d)%s",
count + 2, not);
#endif
}
/* Read in gid mapping data. */
if ((gfp = fopen(gmapfile, "r")) == NULL)
err(EX_NOINPUT, "%s%s", gmapfile, not);
#ifdef MAPSECURITY
/*
* Check that group and other don't have write permissions on
* this group mapfile, and that the file belongs to root.
*/
if (fstat(fileno(gfp), &statbuf))
err(EX_OSERR, "%s%s", gmapfile, not);
if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) {
strmode(statbuf.st_mode, buf);
err(EX_NOPERM, "%s: improper write permissions (%s)%s",
gmapfile, buf, not);
}
if (statbuf.st_uid != ROOTUSER)
errx(EX_NOPERM, "%s does not belong to root%s", gmapfile, not);
#endif /* MAPSECURITY */
if ((fscanf(gfp, "%d\n", &gnentries)) != 1)
errx(EX_DATAERR, "%s: nentries not found%s", gmapfile, not);
if (gnentries > MAPFILEENTRIES)
errx(EX_DATAERR,
"maximum number of entries is %d%s", GMAPFILEENTRIES, not);
#if 0
(void)printf("reading %d group entries\n", gnentries);
#endif
for (count = 0; count < gnentries; ++count)
if ((fscanf(gfp, "%lu %lu\n",
&(gmapdata[count][0]), &(gmapdata[count][1]))) != 2) {
if (ferror(gfp))
err(EX_OSERR, "%s%s", gmapfile, not);
if (feof(gfp))
errx(EX_DATAERR, "%s: unexpected end-of-file%s",
gmapfile, not);
errx(EX_DATAERR, "%s: illegal format (line %d)%s",
gmapfile, count + 2, not);
}
/* Setup mount call args. */
args.target = source;
args.nentries = nentries;
args.mapdata = mapdata;
args.gnentries = gnentries;
args.gmapdata = gmapdata;
error = getvfsbyname("umap", &vfc);
if (error && vfsisloadable("umap")) {
if(vfsload("umap"))
err(1, "vfsload(umap)");
endvfsent();
error = getvfsbyname("umap", &vfc);
}
if (error)
errx(1, "umap filesystem is not available");
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
err(1, NULL);
exit(0);
}
void
usage()
{
(void)fprintf(stderr,
"usage: mount_umap [-o options] -u usermap -g groupmap target_fs mount_point\n");
exit(EX_USAGE);
}

View File

@ -1,2 +0,0 @@
1
1200 1200

View File

@ -1,3 +0,0 @@
2
5217 5217
3 3

View File

@ -1,175 +0,0 @@
\appendix
\section{The umap Layer} \label{sect:umap}
\subsection{Introduction}
Normally, the file system is expected to span a single administrative domain.
An administrative domain, for these purposes, is a machine or set of
machines that share common password file information, usually through
the yellow pages mechanism. File hierarchies that span more
than one domain leads to certain problems, since the same numerical
UID in one domain may correspond to a different user in another domain.
If the system administrator is very careful to ensure that both domains
contain identical user ID information, the umap layer can be used to
run between those domains without changes
The umap layer is a file system layer that sits on top of the normal
file layer. The umap layer maps Unix-style UIDs from
one domain into the UIDs in the other domain. By setting up the mappings
properly, the same user with different UIDs in two domains can be seen
as the same user, from the system point of view, or, conversely, two
different users with the same UID in the two domains can be distinguished.
First, we define some terms. ``User'' refers to the human (or daemon) that
has privileges to login, run programs, and access files. ``UID''refers to
the numerical identifier that uniquely identifies the user within a
single domain. ``Login name'' refers to the character string the user
types to log into the system. ``GID'' refers to the numerical group
identifier used by Unix systems to identify groups of users. ``Group
name'' is the character string name attached to a particular GID in the
local {\sf /etc/groups} file or the yellow pages groups file.
In order for the umap layer to work properly, all users
in either domain must have password file entries in both domains.
They do not, however, have to have the same numerical UID, nor even the
same character string login name (the latter is highly recommended,
if possible, however). Any user not having a UID in one domain will be
treated as the special user NOBODY by the other domain, probably with
undesirable consequences. Any user not owning any files in the shared
sub-trees need not be given a UID in the other domain.
Groups work similarly. The umap layer can translate group ID's between
domains in the same manner as UID's. Again, any group that wishes to
participate must have a group ID in both domains,
though it need not be the same GID in both. If a group in one domain is not
known in the other domain, that group will be treated as being NULLGROUP.
The umap layer has no provisions for enrolling UID's from other domains
as group members, but, since each user from each domain must have some
UID in every domain, the UID in the local domain can be used to enroll
the user in the local groups.
NOBODY and NULLGROUP are special reserved UID's and GID's, respectively.
NOBODY is user 32767. NULLGROUP is group 65534. If the system administrator
wants to have an appropriate text string appear when these UID's are
encountered by programs like {\sf ls -l}, he should add these values to
the password and {\sf /etc/groups} file, or to the appropriate yellow pages.
If these IDs are already in use in that domain, different values can be
used for NOBODY and NULLGROUP, but that will require a recompilation of
the umap layer code and, as a result, the entire kernel. These
values are defined in the {\sf umap\_info.h} file, kept with the rest of the
umap source code.
When the umap layer is in use, one of the participating domains is declared
to be the master. All UID and GID information stored for participating files
will be stored in vnodes using its mappings, no matter what site the copies of
the files are stored at. The master domain therefore need not run a copy
of the umap layer, as it already has all of the correct mappings. All
other domains must run a umap layer on top of any other layers they use.
\subsection{Setting Up a umap Layer}
The system administrator of a system needing to use the umap layer
must take several actions.
First, he must create files containing the necessary UID
and GID mappings. There is a separate file for user and group IDs. The
format of the files is the same. The first line contains the total number
of entries in the file. Each subsequent line contains one mapping. A
mapping line consists of two numerical UIDs, separated by white space.
The first is the UID of a user on the local machine. The second is the
UID for the same user on the master machine. The maximum number of users
that can be mapped for a single shared sub-tree is 64. The maximum number of
groups that can be mapped for a single sub-tree is 16. These constants
are set in the {\sf umap\_info.h} file, and can be changed, but changing them
requires recompilation. Separate mapping files can be used for each shared
subtree, or the same mapping files can be shared by several sub-trees.
Below is a sample UID mapping file. There are four entries. UID 5 is mapped
to 5, 521 to 521, and 7000 to 7000. UID 2002 is mapped to 604. On this
machine, the UID's for users 5, 521, and 7000 are the same as on the master,
but UID 2002 is for a user whose UID on the master machine is 604. All
files in the sub-tree belonging to that user have UID 604 in their inodes,
even on this machine, but the umap layer will ensure that anyone running
under UID 2002 will have all files in this sub-tree owned by 604 treated as if
they were owned by 2002. An {\sf ls -l} on a file owned by 604 in this sub-tree
will show the login name associated with UID 2002 as the owner.
\noindent4\newline
5 5\newline
521 521\newline
2002 604\newline
7000 7000\newline
The user and group mapping files should be owned by the root user, and
should be writable only by that user. If they are not owned by root, or
are writable by some other user, the umap mounting command will abort.
Normally, the sub-tree is grafted directly into the place in
the file hierarchy where the it should appear to users. Using the umap
layer requires that the sub-tree be grafted somewhere else, and
the umap layer be mounted in the desired position in the file hierarchy.
Depending on the situation, the underlying sub-tree can be wherever is
convenient.
\subsection{Troubleshooting umap Layer Problems}
The umap layer code was not built with special convenience or
robustness in mind, as it is expected to be superseded with a better
user ID mapping strategy in the near future. As a result, it is not
very forgiving of errors in being set up. Here are some possible
problems, and what to do about them.
\begin{itemize}
\item{Problem: A file belongs to NOBODY, or group NULLGROUP.
Fixes: The mapping files don't know about this file's real user or group.
Either they are not in the mapping files, or the counts on the number of
entries in the mapping files are too low, so entries at the end (including
these) are being ignored. Add the entries or fix the counts, and either
unmount and remount the sub-tree, or reboot.}
\item{Problem: A normal operation does not work.
Fixes: Possibly, some mapping has not been set properly. Check to
see which files are used by the operation and who they appear to be
owned by. If they are owned by NOBODY or some other suspicious user,
there may be a problem in the mapping files. Be sure to check groups,
too. As above, if the counts of mappings in the mapping files are lower
than the actual numbers of pairs, pairs at the end of the file will be
ignored. If any changes are made in the mapping files, you will need to
either unmount and remount or reboot before they will take effect.
Another possible problem can arise because not all Unix utilities
rely exclusively on numeric UID for identification. For instance,
SCCS saves the login name in files. If a user's login name on two machines
isn't the same, SCCS may veto an operation even though Unix file permissions,
as checked by the umap layer, may say it's OK. There's not much to be
done in such cases, unless the login name can be changed or one fiddles
improperly with SCCS information. There may be other, undiscovered cases
where similar problems arise, some of which may be even harder to handle.}
\item{Problem: Someone has access permissions he should not have.
Fixes: This is probably caused by a mistake in the mapping files. Check
both user and group mapping files. If any changes are made in the mapping
files, you will need to unmount and remount the sub-tree or reboot before they
will take effect.}
\item{Problem: {\sf ls -l} (or a similar program) shows the wrong user for a file.
Fixes: Probably a mistake in the mapping files. In particular, if
two local UIDs are mapped to a single master UID, stat calls will assign
ownership to the first local UID occurring in the file, which may or may
not be what was intended. (Generally speaking, mapping two local UIDs to
a single master UID is a bad idea, but the software will not prevent it.
Similarly, mapping a single local UID to two master UIDs is a bad idea,
but will not be prevented. In this case, only the first mapping of the
local UID will be done. The second, and all subsequent ones, will be
ignored.) If any changes are made in the mapping files, you will need to
unmount and remount the sub-tree or reboot before they will take effect.}
\end{itemize}
\end{document}

View File

@ -1,9 +1,9 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_umap
SRCS= mount_umap.c getmntopts.c
MAN= mount_umap.8
PROG= mount_umapfs
SRCS= mount_umapfs.c getmntopts.c
MAN= mount_umapfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}

View File

@ -37,10 +37,10 @@
.\" $FreeBSD$
.\"
.Dd May 1, 1995
.Dt MOUNT_UMAP 8
.Os BSD 4.4
.Dt MOUNT_UMAPFS 8
.Os
.Sh NAME
.Nm mount_umap
.Nm mount_umapfs
.Nd sample file system layer
.Sh SYNOPSIS
.Nm
@ -110,7 +110,7 @@ at most 16 groups can be mapped by a given subtree.
.Pp
The mapfiles can be located anywhere in the file hierarchy, but they
must be owned by root, and they must be writable only by root.
.Nm Mount_umap
.Nm Mount_umapfs
will refuse to map the sub-tree if the ownership or permissions on
these files are improper. It will also balk if the count of mappings
in the first line of the map files is not correct.
@ -122,7 +122,7 @@ It is not meant for production use. The implementation is not very
sophisticated.
.Sh SEE ALSO
.Xr mount 8 ,
.Xr mount_null 8
.Xr mount_nullfs 8
.Sh BUGS
THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR

View File

@ -245,6 +245,6 @@ void
usage()
{
(void)fprintf(stderr,
"usage: mount_umap [-o options] -u usermap -g groupmap target_fs mount_point\n");
"usage: mount_umapfs [-o options] -u usermap -g groupmap target_fs mount_point\n");
exit(EX_USAGE);
}

View File

@ -1,12 +0,0 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_union
SRCS= mount_union.c getmntopts.c
MAN= mount_union.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
.include <bsd.prog.mk>

View File

@ -1,214 +0,0 @@
.\" Copyright (c) 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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_union.8 8.6 (Berkeley) 3/27/94
.\" $FreeBSD$
.\"
.Dd March 27, 1994
.Dt MOUNT_UNION 8
.Os BSD 4.4
.Sh NAME
.Nm mount_union
.Nd mount union filesystems
.Sh SYNOPSIS
.Nm
.Op Fl br
.Op Fl o Ar options
.Ar directory
.Ar uniondir
.Sh DESCRIPTION
The
.Nm
command
attaches
.Ar directory
above
.Ar uniondir
in such a way that the contents of both directory trees remain visible.
By default,
.Ar directory
becomes the
.Em upper
layer and
.Ar uniondir
becomes the
.Em lower
layer.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl b
Invert the default position, so that
.Ar directory
becomes the lower layer and
.Ar uniondir
becomes the upper layer.
However,
.Ar uniondir
remains the mount point.
.It Fl o
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.
.It Fl r
Hide the lower layer completely in the same way as mounting with
.Xr mount_null 8 .
.El
.Pp
To enforce filesystem security, the user mounting the filesystem
must be superuser or else have write permission on the mounted-on
directory.
.Pp
Filenames are looked up in the upper layer and then in the
lower layer.
If a directory is found in the lower layer, and there is no entry
in the upper layer, then a
.Em shadow
directory will be created in the upper layer.
It will be owned by the user who originally did the union mount,
with mode
.Dq rwxrwxrwx
(0777) modified by the umask in effect at that time.
.Pp
If a file exists in the upper layer then there is no way to access
a file with the same name in the lower layer.
If necessary, a combination of loopback and union mounts can be made
which will still allow the lower files to be accessed by a different
pathname.
.Pp
Except in the case of a directory,
access to an object is granted via the normal filesystem access checks.
For directories, the current user must have access to both the upper
and lower directories (should they both exist).
.Pp
Requests to create or modify objects in
.Ar uniondir
are passed to the upper layer with the exception of a few special cases.
An attempt to open for writing a file which exists in the lower layer
causes a copy of the
.Em entire
file to be made to the upper layer, and then for the upper layer copy
to be opened.
Similarly, an attempt to truncate a lower layer file to zero length
causes an empty file to be created in the upper layer.
Any other operation which would ultimately require modification to
the lower layer fails with
.Er EROFS .
.Pp
The union filesystem manipulates the namespace, rather than
individual filesystems.
The union operation applies recursively down the directory tree
now rooted at
.Ar uniondir .
Thus any filesystems which are mounted under
.Ar uniondir
will take part in the union operation.
This differs from the
.Em union
option to
.Xr mount 8
which only applies the union operation to the mount point itself,
and then only for lookups.
.Sh EXAMPLES
The commands
.Bd -literal -offset indent
mount -t cd9660 -o ro /dev/cd0a /usr/src
mount -t union /var/obj /usr/src
.Ed
.Pp
mount the CD-ROM drive
.Pa /dev/cd0a
on
.Pa /usr/src
and then attaches
.Pa /var/obj
on top.
For most purposes the effect of this is to make the
source tree appear writable
even though it is stored on a CD-ROM.
.Pp
The command
.Bd -literal -offset indent
mount -t union -o -b /sys $HOME/sys
.Ed
.Pp
attaches the system source tree below the
.Pa sys
directory in the user's home directory.
This allows individual users to make private changes
to the source, and build new kernels, without those
changes becoming visible to other users.
Note that the files in the lower layer remain
accessible via
.Pa /sys .
.Sh SEE ALSO
.Xr intro 2 ,
.Xr mount 2 ,
.Xr unmount 2 ,
.Xr fstab 5 ,
.Xr mount 8 ,
.Xr mount_null 8
.Sh BUGS
THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
.Pp
This code also needs an owner in order to be less dangerous - serious
hackers can apply by sending mail to
.Aq hackers@FreeBSD.org
and announcing
their intent to take it over.
.Pp
Without whiteout support from the filesystem backing the upper layer,
there is no way that delete and rename operations on lower layer
objects can be done.
.Er EROFS
is returned for this kind of operations along with any others
which would make modifications to the lower layer, such as
.Xr chmod 1 .
.Pp
Running
.Xr find 1
over a union tree has the side-effect of creating
a tree of shadow directories in the upper layer.
.Sh HISTORY
The
.Nm
command first appeared in
.Bx 4.4 .
It first worked in
.Fx Ns -(fill this in) .

View File

@ -1,160 +0,0 @@
/*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*/
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mount_union.c 8.5 (Berkeley) 3/27/94";
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <fs/unionfs/union.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include "mntopts.h"
static struct mntopt mopts[] = {
MOPT_STDOPTS,
{ NULL }
};
static int subdir __P((const char *, const char *));
static void usage __P((void)) __dead2;
int
main(argc, argv)
int argc;
char *argv[];
{
struct union_args args;
int ch, mntflags;
char source[MAXPATHLEN];
char target[MAXPATHLEN];
struct vfsconf vfc;
int error;
mntflags = 0;
args.mntflags = UNMNT_ABOVE;
while ((ch = getopt(argc, argv, "bo:r")) != -1)
switch (ch) {
case 'b':
args.mntflags &= ~UNMNT_OPMASK;
args.mntflags |= UNMNT_BELOW;
break;
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
case 'r':
args.mntflags &= ~UNMNT_OPMASK;
args.mntflags |= UNMNT_REPLACE;
break;
case '?':
default:
usage();
/* NOTREACHED */
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
argv[0], target, argv[1], source);
args.target = target;
error = getvfsbyname("union", &vfc);
if (error && vfsisloadable("union")) {
if (vfsload("union"))
err(EX_OSERR, "vfsload(union)");
endvfsent(); /* flush cache */
error = getvfsbyname("union", &vfc);
}
if (error)
errx(EX_OSERR, "union filesystem is not available");
if (mount(vfc.vfc_name, source, mntflags, &args))
err(EX_OSERR, "%s", target);
exit(0);
}
int
subdir(p, dir)
const char *p;
const char *dir;
{
int l;
l = strlen(dir);
if (l <= 1)
return (1);
if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
return (1);
return (0);
}
void
usage()
{
(void)fprintf(stderr,
"usage: mount_union [-br] [-o options] target_fs mount_point\n");
exit(EX_USAGE);
}

View File

@ -1,9 +1,9 @@
# @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_union
SRCS= mount_union.c getmntopts.c
MAN= mount_union.8
PROG= mount_unionfs
SRCS= mount_unionfs.c getmntopts.c
MAN= mount_unionfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}

View File

@ -36,10 +36,10 @@
.\" $FreeBSD$
.\"
.Dd March 27, 1994
.Dt MOUNT_UNION 8
.Os BSD 4.4
.Dt MOUNT_UNIONFS 8
.Os
.Sh NAME
.Nm mount_union
.Nm mount_unionfs
.Nd mount union filesystems
.Sh SYNOPSIS
.Nm
@ -86,7 +86,7 @@ See the
man page for possible options and their meanings.
.It Fl r
Hide the lower layer completely in the same way as mounting with
.Xr mount_null 8 .
.Xr mount_nullfs 8 .
.El
.Pp
To enforce filesystem security, the user mounting the filesystem
@ -147,7 +147,7 @@ and then only for lookups.
The commands
.Bd -literal -offset indent
mount -t cd9660 -o ro /dev/cd0a /usr/src
mount -t union /var/obj /usr/src
mount -t unionfs /var/obj /usr/src
.Ed
.Pp
mount the CD-ROM drive
@ -163,7 +163,7 @@ even though it is stored on a CD-ROM.
.Pp
The command
.Bd -literal -offset indent
mount -t union -o -b /sys $HOME/sys
mount -t unionfs -o -b /sys $HOME/sys
.Ed
.Pp
attaches the system source tree below the

View File

@ -155,6 +155,6 @@ void
usage()
{
(void)fprintf(stderr,
"usage: mount_union [-br] [-o options] target_fs mount_point\n");
"usage: mount_unionfs [-br] [-o options] target_fs mount_point\n");
exit(EX_USAGE);
}

View File

@ -3,7 +3,7 @@
#MISSING: dump.5 plot.5
MAN= a.out.5 acct.5 core.5 devfs.5 dir.5 disktab.5 ethers.5 \
elf.5 fbtab.5 fdesc.5 forward.5 fs.5 fstab.5 group.5 \
elf.5 fbtab.5 fdescfs.5 forward.5 fs.5 fstab.5 group.5 \
hesiod.conf.5 \
hosts.5 hosts.equiv.5 hosts.lpd.5 intro.5 link.5 \
linprocfs.5 make.conf.5 mailer.conf.5 motd.5 networks.5 \

View File

@ -1,113 +0,0 @@
.\" Copyright (c) 1996
.\" Mike Pritchard <mpp@FreeBSD.org>. All rights reserved.
.\"
.\" Copyright (c) 1992, 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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.
.\"
.\" $FreeBSD$
.\"
.Dd December 14, 1996
.Dt FDESC 5
.Os BSD 4.4
.Sh NAME
.Nm fdesc
.Nd file-descriptor file system
.Sh SYNOPSIS
fdesc /dev/fd fdesc rw 0 0
.Sh DESCRIPTION
The file-descriptor file system, or
.Nm ,
provides access to the per-process file descriptor
namespace in the global filesystem namespace.
The conventional mount point is
.Pa /dev/fd .
.Pp
The file system's contents
appear as a list of numbered files
which correspond to the open files of the process reading the
directory.
The files
.Pa /dev/fd/0
through
.Pa /dev/fd/#
refer to file descriptors which can be accessed through the file
system.
If the file descriptor is open and the mode the file is being opened
with is a subset of the mode of the existing descriptor, the call:
.Bd -literal -offset indent
fd = open("/dev/fd/0", mode);
.Ed
.Pp
and the call:
.Bd -literal -offset indent
fd = fcntl(0, F_DUPFD, 0);
.Ed
.Pp
are equivalent.
.Pp
Flags to the
.Xr open 2
call other than
.Dv O_RDONLY ,
.Dv O_WRONLY
and
.Dv O_RDWR
are ignored.
.Sh FILES
.Bl -tag -width /dev/stderr -compact
.It Pa /dev/fd/#
.El
.Sh SEE ALSO
.Xr mount_devfs 8 ,
.Xr mount_fdesc 8
.Sh HISTORY
The
.Nm
filesystem first appeared in
.Bx 4.4 .
The
.Nm
manual page first appeared in
.Fx 2.2 .
.Sh AUTHORS
.An -nosplit
The
.Nm
manual page was written by
.An Mike Pritchard Aq mpp@FreeBSD.org ,
and was based on the
.Xr mount_fdesc 8
manual page written by
.An Jan-Simon Pendry .

View File

@ -39,13 +39,13 @@
.\" $FreeBSD$
.\"
.Dd December 14, 1996
.Dt FDESC 5
.Os BSD 4.4
.Dt FDESCFS 5
.Os
.Sh NAME
.Nm fdesc
.Nm fdescfs
.Nd file-descriptor file system
.Sh SYNOPSIS
fdesc /dev/fd fdesc rw 0 0
fdescfs /dev/fd fdescfs rw 0 0
.Sh DESCRIPTION
The file-descriptor file system, or
.Nm ,
@ -91,7 +91,7 @@ are ignored.
.El
.Sh SEE ALSO
.Xr mount_devfs 8 ,
.Xr mount_fdesc 8
.Xr mount_fdescfs 8
.Sh HISTORY
The
.Nm
@ -108,6 +108,6 @@ The
manual page was written by
.An Mike Pritchard Aq mpp@FreeBSD.org ,
and was based on the
.Xr mount_fdesc 8
.Xr mount_fdescfs 8
manual page written by
.An Jan-Simon Pendry .

View File

@ -1,10 +1,10 @@
# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
# $FreeBSD$
PROG= mount_portal
SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
PROG= mount_portalfs
SRCS= mount_portalfs.c activate.c conf.c getmntopts.c pt_conf.c \
pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c
MAN= mount_portal.8
MAN= mount_portalfs.8
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}

View File

@ -38,10 +38,10 @@
.\" $FreeBSD$
.\"
.Dd March 27, 1994
.Dt MOUNT_PORTAL 8
.Os BSD 4.4
.Dt MOUNT_PORTALFS 8
.Os
.Sh NAME
.Nm mount_portal
.Nm mount_portalfs
.Nd mount the portal daemon
.Sh SYNOPSIS
.Nm

View File

@ -290,6 +290,6 @@ static void
usage()
{
(void)fprintf(stderr,
"usage: mount_portal [-o options] config mount-point\n");
"usage: mount_portalfs [-o options] config mount-point\n");
exit(EX_USAGE);
}