1994-05-26 06:35:07 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1980, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
1998-08-03 06:44:46 +00:00
|
|
|
static const char copyright[] =
|
1994-05-26 06:35:07 +00:00
|
|
|
"@(#) Copyright (c) 1980, 1989, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
1998-08-03 06:44:46 +00:00
|
|
|
#if 0
|
1997-06-16 11:20:05 +00:00
|
|
|
static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95";
|
1998-08-03 06:44:46 +00:00
|
|
|
#endif
|
|
|
|
static const char rcsid[] =
|
1999-08-28 00:22:10 +00:00
|
|
|
"$FreeBSD$";
|
1994-05-26 06:35:07 +00:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
#include <sys/socket.h>
|
2003-07-20 00:11:27 +00:00
|
|
|
#include <sys/stat.h>
|
1994-05-26 06:35:07 +00:00
|
|
|
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <nfs/rpcv2.h>
|
|
|
|
|
2003-07-18 17:43:13 +00:00
|
|
|
#include <ctype.h>
|
1994-05-26 06:35:07 +00:00
|
|
|
#include <err.h>
|
2003-07-01 17:40:23 +00:00
|
|
|
#include <errno.h>
|
1994-05-26 06:35:07 +00:00
|
|
|
#include <fstab.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1999-11-22 04:23:11 +00:00
|
|
|
#include "mounttab.h"
|
|
|
|
|
2003-07-20 00:11:27 +00:00
|
|
|
typedef enum { FIND, REMOVE, CHECKUNIQUE } dowhat;
|
1999-10-17 16:26:58 +00:00
|
|
|
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
struct addrinfo *nfshost_ai = NULL;
|
1999-10-23 00:54:58 +00:00
|
|
|
int fflag, vflag;
|
1999-10-17 16:26:58 +00:00
|
|
|
char *nfshost;
|
|
|
|
|
2003-07-18 08:01:10 +00:00
|
|
|
struct statfs *checkmntlist(char *);
|
1999-10-17 16:26:58 +00:00
|
|
|
int checkvfsname (const char *, char **);
|
2003-07-20 00:11:27 +00:00
|
|
|
struct statfs *getmntentry(const char *fromname, const char *onname,
|
|
|
|
fsid_t *fsid, dowhat what);
|
1999-10-17 16:26:58 +00:00
|
|
|
char **makevfslist (const char *);
|
|
|
|
size_t mntinfo (struct statfs **);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
int namematch (struct addrinfo *);
|
2003-07-20 00:11:27 +00:00
|
|
|
int parsehexfsid(const char *hex, fsid_t *fsid);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
int sacmp (struct sockaddr *, struct sockaddr *);
|
1999-10-17 16:26:58 +00:00
|
|
|
int umountall (char **);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
int checkname (char *, char **);
|
2003-07-20 00:11:27 +00:00
|
|
|
int umountfs(struct statfs *sfs);
|
1999-10-17 16:26:58 +00:00
|
|
|
void usage (void);
|
|
|
|
int xdr_dir (XDR *, char *);
|
1994-05-26 06:35:07 +00:00
|
|
|
|
|
|
|
int
|
1999-10-17 16:26:58 +00:00
|
|
|
main(int argc, char *argv[])
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
int all, errs, ch, mntsize, error;
|
2003-07-18 01:10:16 +00:00
|
|
|
char **typelist = NULL;
|
|
|
|
struct statfs *mntbuf, *sfs;
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
struct addrinfo hints;
|
1994-05-26 06:35:07 +00:00
|
|
|
|
|
|
|
/* Start disks transferring immediately. */
|
|
|
|
sync();
|
|
|
|
|
1999-10-23 00:54:58 +00:00
|
|
|
all = errs = 0;
|
2003-04-07 12:56:01 +00:00
|
|
|
while ((ch = getopt(argc, argv, "AaF:fh:t:v")) != -1)
|
1994-05-26 06:35:07 +00:00
|
|
|
switch (ch) {
|
1997-06-16 11:20:05 +00:00
|
|
|
case 'A':
|
|
|
|
all = 2;
|
|
|
|
break;
|
1994-05-26 06:35:07 +00:00
|
|
|
case 'a':
|
|
|
|
all = 1;
|
|
|
|
break;
|
2003-04-07 12:56:01 +00:00
|
|
|
case 'F':
|
|
|
|
setfstab(optarg);
|
|
|
|
break;
|
1994-05-26 06:35:07 +00:00
|
|
|
case 'f':
|
|
|
|
fflag = MNT_FORCE;
|
|
|
|
break;
|
1997-06-16 11:20:05 +00:00
|
|
|
case 'h': /* -h implies -A. */
|
|
|
|
all = 2;
|
1994-05-26 06:35:07 +00:00
|
|
|
nfshost = optarg;
|
|
|
|
break;
|
|
|
|
case 't':
|
1997-06-16 11:20:05 +00:00
|
|
|
if (typelist != NULL)
|
1999-10-17 16:26:58 +00:00
|
|
|
err(1, "only one -t option may be specified");
|
1997-06-16 11:20:05 +00:00
|
|
|
typelist = makevfslist(optarg);
|
1994-05-26 06:35:07 +00:00
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
vflag = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
1998-08-03 06:44:46 +00:00
|
|
|
if ((argc == 0 && !all) || (argc != 0 && all))
|
1994-05-26 06:35:07 +00:00
|
|
|
usage();
|
|
|
|
|
|
|
|
/* -h implies "-t nfs" if no -t flag. */
|
|
|
|
if ((nfshost != NULL) && (typelist == NULL))
|
1997-06-16 11:20:05 +00:00
|
|
|
typelist = makevfslist("nfs");
|
1995-05-30 06:12:45 +00:00
|
|
|
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
if (nfshost != NULL) {
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
error = getaddrinfo(nfshost, NULL, &hints, &nfshost_ai);
|
2001-10-13 02:04:54 +00:00
|
|
|
if (error)
|
|
|
|
errx(1, "%s: %s", nfshost, gai_strerror(error));
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
}
|
|
|
|
|
1997-06-16 11:20:05 +00:00
|
|
|
switch (all) {
|
|
|
|
case 2:
|
1999-10-17 16:26:58 +00:00
|
|
|
if ((mntsize = mntinfo(&mntbuf)) <= 0)
|
1997-06-16 11:20:05 +00:00
|
|
|
break;
|
1999-10-17 16:26:58 +00:00
|
|
|
/*
|
|
|
|
* We unmount the nfs-mounts in the reverse order
|
|
|
|
* that they were mounted.
|
|
|
|
*/
|
|
|
|
for (errs = 0, mntsize--; mntsize > 0; mntsize--) {
|
2003-07-18 01:10:16 +00:00
|
|
|
sfs = &mntbuf[mntsize];
|
|
|
|
if (checkvfsname(sfs->f_fstypename, typelist))
|
1997-06-16 11:20:05 +00:00
|
|
|
continue;
|
2003-07-20 00:11:27 +00:00
|
|
|
if (umountfs(sfs) != 0)
|
1997-06-16 11:20:05 +00:00
|
|
|
errs = 1;
|
|
|
|
}
|
1999-10-17 16:26:58 +00:00
|
|
|
free(mntbuf);
|
1997-06-16 11:20:05 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
1994-05-26 06:35:07 +00:00
|
|
|
if (setfsent() == 0)
|
2003-04-07 12:56:01 +00:00
|
|
|
err(1, "%s", getfstab());
|
1997-06-16 11:20:05 +00:00
|
|
|
errs = umountall(typelist);
|
|
|
|
break;
|
|
|
|
case 0:
|
1994-05-26 06:35:07 +00:00
|
|
|
for (errs = 0; *argv != NULL; ++argv)
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
if (checkname(*argv, typelist) != 0)
|
1997-06-16 11:20:05 +00:00
|
|
|
errs = 1;
|
|
|
|
break;
|
|
|
|
}
|
1994-05-26 06:35:07 +00:00
|
|
|
exit(errs);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-10-17 16:26:58 +00:00
|
|
|
umountall(char **typelist)
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
- Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *.
- Convert several consumers of getvfsbyname() to use struct xvfsconf.
- Correct the getvfsbyname.3 manpage.
- Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the
kernel, and rewrite getvfsbyname() to use this instead of the weird
existing API.
- Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist
sysctl.
- Convert a vfsload() call in nfsiod.c to kldload() and remove the useless
vfsisloadable() and endvfsent() calls.
- Add a warning printf() in vfs_sysctl() to tell people they are using
an old userland.
After these changes, it's possible to modify struct vfsconf without
breaking the binary compatibility. Please note that these changes don't
break this compatibility either.
When bp will have updated mount_smbfs(8) with the patch I sent him, there
will be no more consumers of the {set,get,end}vfsent(), vfsisloadable()
and vfsload() API, and I will promptly delete it.
2002-08-10 20:19:04 +00:00
|
|
|
struct xvfsconf vfc;
|
1994-05-26 06:35:07 +00:00
|
|
|
struct fstab *fs;
|
1998-08-03 06:44:46 +00:00
|
|
|
int rval;
|
1994-05-26 06:35:07 +00:00
|
|
|
char *cp;
|
1999-10-18 03:52:20 +00:00
|
|
|
static int firstcall = 1;
|
1994-05-26 06:35:07 +00:00
|
|
|
|
1999-10-29 09:33:50 +00:00
|
|
|
if ((fs = getfsent()) != NULL)
|
1999-10-18 03:52:20 +00:00
|
|
|
firstcall = 0;
|
1999-10-29 09:33:50 +00:00
|
|
|
else if (firstcall)
|
|
|
|
errx(1, "fstab reading failure");
|
|
|
|
else
|
|
|
|
return (0);
|
1999-10-17 16:26:58 +00:00
|
|
|
do {
|
1994-05-26 06:35:07 +00:00
|
|
|
/* Ignore the root. */
|
|
|
|
if (strcmp(fs->fs_file, "/") == 0)
|
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* !!!
|
|
|
|
* Historic practice: ignore unknown FSTAB_* fields.
|
|
|
|
*/
|
|
|
|
if (strcmp(fs->fs_type, FSTAB_RW) &&
|
|
|
|
strcmp(fs->fs_type, FSTAB_RO) &&
|
|
|
|
strcmp(fs->fs_type, FSTAB_RQ))
|
|
|
|
continue;
|
2002-08-21 18:11:48 +00:00
|
|
|
/* Ignore unknown file system types. */
|
2000-09-06 17:44:07 +00:00
|
|
|
if (getvfsbyname(fs->fs_vfstype, &vfc) == -1)
|
1994-05-26 06:35:07 +00:00
|
|
|
continue;
|
1997-06-16 11:20:05 +00:00
|
|
|
if (checkvfsname(fs->fs_vfstype, typelist))
|
1994-05-26 06:35:07 +00:00
|
|
|
continue;
|
|
|
|
|
1995-05-30 06:12:45 +00:00
|
|
|
/*
|
2002-08-21 18:11:48 +00:00
|
|
|
* We want to unmount the file systems in the reverse order
|
1994-05-26 06:35:07 +00:00
|
|
|
* that they were mounted. So, we save off the file name
|
|
|
|
* in some allocated memory, and then call recursively.
|
|
|
|
*/
|
|
|
|
if ((cp = malloc((size_t)strlen(fs->fs_file) + 1)) == NULL)
|
1999-10-17 16:26:58 +00:00
|
|
|
err(1, "malloc failed");
|
1994-05-26 06:35:07 +00:00
|
|
|
(void)strcpy(cp, fs->fs_file);
|
1997-06-16 11:20:05 +00:00
|
|
|
rval = umountall(typelist);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
rval = checkname(cp, typelist) || rval;
|
1999-10-18 03:52:20 +00:00
|
|
|
free(cp);
|
|
|
|
return (rval);
|
1999-10-17 16:26:58 +00:00
|
|
|
} while ((fs = getfsent()) != NULL);
|
1994-05-26 06:35:07 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
/*
|
2003-07-20 00:11:27 +00:00
|
|
|
* Do magic checks on mountpoint/device/fsid, and then call unmount(2).
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
*/
|
1994-05-26 06:35:07 +00:00
|
|
|
int
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
checkname(char *name, char **typelist)
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
2003-07-20 00:11:27 +00:00
|
|
|
char buf[MAXPATHLEN];
|
|
|
|
struct statfs sfsbuf;
|
|
|
|
struct stat sb;
|
2003-07-18 01:10:16 +00:00
|
|
|
struct statfs *sfs;
|
2003-07-20 00:11:27 +00:00
|
|
|
char *delimp;
|
|
|
|
dev_t dev;
|
|
|
|
int len;
|
1999-10-17 16:26:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 1. Check if the name exists in the mounttable.
|
|
|
|
*/
|
2003-07-18 08:01:10 +00:00
|
|
|
sfs = checkmntlist(name);
|
1999-10-17 16:26:58 +00:00
|
|
|
/*
|
|
|
|
* 2. Remove trailing slashes if there are any. After that
|
|
|
|
* we look up the name in the mounttable again.
|
|
|
|
*/
|
2003-07-01 17:40:23 +00:00
|
|
|
if (sfs == NULL) {
|
2003-07-20 00:11:27 +00:00
|
|
|
len = strlen(name);
|
2003-10-29 17:44:36 +00:00
|
|
|
while (len > 1 && name[len - 1] == '/')
|
2003-07-20 00:11:27 +00:00
|
|
|
name[--len] = '\0';
|
2003-07-18 08:01:10 +00:00
|
|
|
sfs = checkmntlist(name);
|
2003-07-20 00:11:27 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* 3. Check if the deprecated NFS syntax with an '@' has been used
|
|
|
|
* and translate it to the ':' syntax. Look up the name in the
|
|
|
|
* mount table again.
|
|
|
|
*/
|
|
|
|
if (sfs == NULL && (delimp = strrchr(name, '@')) != NULL) {
|
|
|
|
snprintf(buf, sizeof(buf), "%s:%.*s", delimp + 1, delimp - name,
|
|
|
|
name);
|
|
|
|
len = strlen(buf);
|
2003-10-29 17:44:36 +00:00
|
|
|
while (len > 1 && buf[len - 1] == '/')
|
2003-07-20 00:11:27 +00:00
|
|
|
buf[--len] = '\0';
|
|
|
|
sfs = checkmntlist(buf);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* 4. Resort to a statfs(2) call. This is the last check so that
|
|
|
|
* hung NFS filesystems for example can be unmounted without
|
|
|
|
* potentially blocking forever in statfs() as long as the
|
|
|
|
* filesystem is specified unambiguously. This covers all the
|
|
|
|
* hard cases such as symlinks and mismatches between the
|
|
|
|
* mount list and reality.
|
|
|
|
* We also do this if an ambiguous mount point was specified.
|
|
|
|
*/
|
|
|
|
if (sfs == NULL || (getmntentry(NULL, name, NULL, FIND) != NULL &&
|
|
|
|
getmntentry(NULL, name, NULL, CHECKUNIQUE) == NULL)) {
|
|
|
|
if (statfs(name, &sfsbuf) != 0) {
|
|
|
|
warn("%s: statfs", name);
|
|
|
|
} else if (stat(name, &sb) != 0) {
|
|
|
|
warn("%s: stat", name);
|
|
|
|
} else if (S_ISDIR(sb.st_mode)) {
|
|
|
|
/* Check that `name' is the root directory. */
|
|
|
|
dev = sb.st_dev;
|
|
|
|
snprintf(buf, sizeof(buf), "%s/..", name);
|
|
|
|
if (stat(buf, &sb) != 0) {
|
|
|
|
warn("%s: stat", buf);
|
|
|
|
} else if (sb.st_dev == dev) {
|
|
|
|
warnx("%s: not a file system root directory",
|
|
|
|
name);
|
|
|
|
return (1);
|
|
|
|
} else
|
|
|
|
sfs = &sfsbuf;
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
2003-07-20 00:11:27 +00:00
|
|
|
}
|
|
|
|
if (sfs == NULL) {
|
|
|
|
warnx("%s: unknown file system", name);
|
|
|
|
return (1);
|
|
|
|
}
|
2003-07-18 08:01:10 +00:00
|
|
|
if (checkvfsname(sfs->f_fstypename, typelist))
|
1997-06-16 11:20:05 +00:00
|
|
|
return (1);
|
2003-07-20 00:11:27 +00:00
|
|
|
return (umountfs(sfs));
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NFS stuff and unmount(2) call
|
|
|
|
*/
|
|
|
|
int
|
2003-07-20 00:11:27 +00:00
|
|
|
umountfs(struct statfs *sfs)
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
{
|
2003-07-01 17:40:23 +00:00
|
|
|
char fsidbuf[64];
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
enum clnt_stat clnt_stat;
|
|
|
|
struct timeval try;
|
|
|
|
struct addrinfo *ai, hints;
|
|
|
|
int do_rpc;
|
|
|
|
CLIENT *clp;
|
|
|
|
char *nfsdirname, *orignfsdirname;
|
|
|
|
char *hostp, *delimp;
|
|
|
|
|
|
|
|
ai = NULL;
|
2001-07-22 00:45:29 +00:00
|
|
|
do_rpc = 0;
|
|
|
|
hostp = NULL;
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
nfsdirname = delimp = orignfsdirname = NULL;
|
|
|
|
memset(&hints, 0, sizeof hints);
|
|
|
|
|
2003-07-20 00:11:27 +00:00
|
|
|
if (strcmp(sfs->f_fstypename, "nfs") == 0) {
|
|
|
|
if ((nfsdirname = strdup(sfs->f_mntfromname)) == NULL)
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
err(1, "strdup");
|
|
|
|
orignfsdirname = nfsdirname;
|
|
|
|
if ((delimp = strrchr(nfsdirname, ':')) != NULL) {
|
|
|
|
*delimp = '\0';
|
|
|
|
hostp = nfsdirname;
|
|
|
|
getaddrinfo(hostp, NULL, &hints, &ai);
|
|
|
|
if (ai == NULL) {
|
|
|
|
warnx("can't get net id for host");
|
|
|
|
}
|
|
|
|
nfsdirname = delimp + 1;
|
|
|
|
}
|
2001-07-22 00:45:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we have to start the rpc-call later.
|
|
|
|
* If there are still identical nfs-names mounted,
|
|
|
|
* we skip the rpc-call. Obviously this has to
|
|
|
|
* happen before unmount(2), but it should happen
|
|
|
|
* after the previous namecheck.
|
|
|
|
* A non-NULL return means that this is the last
|
|
|
|
* mount from mntfromname that is still mounted.
|
|
|
|
*/
|
2003-07-20 00:11:27 +00:00
|
|
|
if (getmntentry(sfs->f_mntfromname, NULL, NULL,
|
|
|
|
CHECKUNIQUE) != NULL)
|
2001-07-22 00:45:29 +00:00
|
|
|
do_rpc = 1;
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!namematch(ai))
|
1997-06-16 11:20:05 +00:00
|
|
|
return (1);
|
2003-07-20 00:11:27 +00:00
|
|
|
/* First try to unmount using the file system ID. */
|
|
|
|
snprintf(fsidbuf, sizeof(fsidbuf), "FSID:%d:%d", sfs->f_fsid.val[0],
|
|
|
|
sfs->f_fsid.val[1]);
|
|
|
|
if (unmount(fsidbuf, fflag | MNT_BYFSID) != 0) {
|
2003-11-16 16:48:18 +00:00
|
|
|
/* XXX, non-root users get a zero fsid, so don't warn. */
|
|
|
|
if (errno != ENOENT || sfs->f_fsid.val[0] != 0 ||
|
|
|
|
sfs->f_fsid.val[1] != 0)
|
|
|
|
warn("unmount of %s failed", sfs->f_mntonname);
|
2003-07-20 00:11:27 +00:00
|
|
|
if (errno != ENOENT)
|
|
|
|
return (1);
|
|
|
|
/* Compatability for old kernels. */
|
|
|
|
warnx("retrying using path instead of file system ID");
|
|
|
|
if (unmount(sfs->f_mntonname, fflag) != 0) {
|
|
|
|
warn("unmount of %s failed", sfs->f_mntonname);
|
|
|
|
return (1);
|
2003-07-01 17:40:23 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-20 00:11:27 +00:00
|
|
|
/* Mark this this file system as unmounted. */
|
|
|
|
getmntentry(NULL, NULL, &sfs->f_fsid, REMOVE);
|
1999-10-17 16:26:58 +00:00
|
|
|
if (vflag)
|
2003-07-20 00:11:27 +00:00
|
|
|
(void)printf("%s: unmount from %s\n", sfs->f_mntfromname,
|
|
|
|
sfs->f_mntonname);
|
1999-10-17 16:26:58 +00:00
|
|
|
/*
|
|
|
|
* Report to mountd-server which nfsname
|
|
|
|
* has been unmounted.
|
|
|
|
*/
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
if (ai != NULL && !(fflag & MNT_FORCE) && do_rpc) {
|
|
|
|
clp = clnt_create(hostp, RPCPROG_MNT, RPCMNT_VER1, "udp");
|
|
|
|
if (clp == NULL) {
|
2001-07-22 00:45:29 +00:00
|
|
|
warnx("%s: %s", hostp,
|
|
|
|
clnt_spcreateerror("RPCPROG_MNT"));
|
1994-05-26 06:35:07 +00:00
|
|
|
return (1);
|
|
|
|
}
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
clp->cl_auth = authsys_create_default();
|
1994-05-26 06:35:07 +00:00
|
|
|
try.tv_sec = 20;
|
|
|
|
try.tv_usec = 0;
|
2003-04-07 11:44:48 +00:00
|
|
|
clnt_stat = clnt_call(clp, RPCMNT_UMOUNT, (xdrproc_t)xdr_dir,
|
|
|
|
nfsdirname, (xdrproc_t)xdr_void, (caddr_t)0, try);
|
1994-05-26 06:35:07 +00:00
|
|
|
if (clnt_stat != RPC_SUCCESS) {
|
2001-07-22 00:45:29 +00:00
|
|
|
warnx("%s: %s", hostp,
|
|
|
|
clnt_sperror(clp, "RPCMNT_UMOUNT"));
|
1994-05-26 06:35:07 +00:00
|
|
|
return (1);
|
|
|
|
}
|
1999-11-22 04:23:11 +00:00
|
|
|
/*
|
|
|
|
* Remove the unmounted entry from /var/db/mounttab.
|
|
|
|
*/
|
2001-07-22 12:17:51 +00:00
|
|
|
if (read_mtab()) {
|
|
|
|
clean_mtab(hostp, nfsdirname, vflag);
|
|
|
|
if(!write_mtab(vflag))
|
2001-07-22 00:45:29 +00:00
|
|
|
warnx("cannot remove mounttab entry %s:%s",
|
1999-11-22 04:23:11 +00:00
|
|
|
hostp, nfsdirname);
|
|
|
|
free_mtab();
|
|
|
|
}
|
1999-10-17 16:26:58 +00:00
|
|
|
free(orignfsdirname);
|
1994-05-26 06:35:07 +00:00
|
|
|
auth_destroy(clp->cl_auth);
|
|
|
|
clnt_destroy(clp);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-07-01 17:40:23 +00:00
|
|
|
struct statfs *
|
2003-07-20 00:11:27 +00:00
|
|
|
getmntentry(const char *fromname, const char *onname, fsid_t *fsid, dowhat what)
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
1997-06-16 11:20:05 +00:00
|
|
|
static struct statfs *mntbuf;
|
1999-10-17 16:26:58 +00:00
|
|
|
static size_t mntsize = 0;
|
|
|
|
static char *mntcheck = NULL;
|
2003-07-20 00:11:27 +00:00
|
|
|
struct statfs *sfs, *foundsfs;
|
1999-10-17 16:26:58 +00:00
|
|
|
int i, count;
|
|
|
|
|
|
|
|
if (mntsize <= 0) {
|
|
|
|
if ((mntsize = mntinfo(&mntbuf)) <= 0)
|
|
|
|
return (NULL);
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
1999-10-17 16:26:58 +00:00
|
|
|
if (mntcheck == NULL) {
|
2003-07-20 00:11:27 +00:00
|
|
|
if ((mntcheck = calloc(mntsize + 1, sizeof(int))) == NULL)
|
1999-10-17 16:26:58 +00:00
|
|
|
err(1, "calloc");
|
|
|
|
}
|
|
|
|
/*
|
2002-08-21 18:11:48 +00:00
|
|
|
* We want to get the file systems in the reverse order
|
2003-07-20 00:11:27 +00:00
|
|
|
* that they were mounted. Unmounted file systems are marked
|
|
|
|
* in a table called 'mntcheck'.
|
1999-10-17 16:26:58 +00:00
|
|
|
*/
|
2003-07-20 00:11:27 +00:00
|
|
|
count = 0;
|
|
|
|
foundsfs = NULL;
|
|
|
|
for (i = mntsize - 1; i >= 0; i--) {
|
|
|
|
if (mntcheck[i])
|
|
|
|
continue;
|
|
|
|
sfs = &mntbuf[i];
|
|
|
|
if (fromname != NULL && strcmp(sfs->f_mntfromname,
|
|
|
|
fromname) != 0)
|
|
|
|
continue;
|
|
|
|
if (onname != NULL && strcmp(sfs->f_mntonname, onname) != 0)
|
|
|
|
continue;
|
|
|
|
if (fsid != NULL && bcmp(&sfs->f_fsid, fsid,
|
|
|
|
sizeof(*fsid)) != 0)
|
|
|
|
continue;
|
2003-07-01 17:40:23 +00:00
|
|
|
|
2003-07-20 00:11:27 +00:00
|
|
|
switch (what) {
|
|
|
|
case CHECKUNIQUE:
|
|
|
|
foundsfs = sfs;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
case REMOVE:
|
|
|
|
mntcheck[i] = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-10-17 16:26:58 +00:00
|
|
|
}
|
2003-07-20 00:11:27 +00:00
|
|
|
return (sfs);
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
2003-07-20 00:11:27 +00:00
|
|
|
|
|
|
|
if (what == CHECKUNIQUE && count == 1)
|
|
|
|
return (foundsfs);
|
|
|
|
return (NULL);
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
sacmp(struct sockaddr *sa1, struct sockaddr *sa2)
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
void *p1, *p2;
|
|
|
|
int len;
|
1994-05-26 06:35:07 +00:00
|
|
|
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
if (sa1->sa_family != sa2->sa_family)
|
1994-05-26 06:35:07 +00:00
|
|
|
return (1);
|
|
|
|
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
switch (sa1->sa_family) {
|
|
|
|
case AF_INET:
|
|
|
|
p1 = &((struct sockaddr_in *)sa1)->sin_addr;
|
|
|
|
p2 = &((struct sockaddr_in *)sa2)->sin_addr;
|
|
|
|
len = 4;
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
p1 = &((struct sockaddr_in6 *)sa1)->sin6_addr;
|
|
|
|
p2 = &((struct sockaddr_in6 *)sa2)->sin6_addr;
|
|
|
|
len = 16;
|
|
|
|
if (((struct sockaddr_in6 *)sa1)->sin6_scope_id !=
|
|
|
|
((struct sockaddr_in6 *)sa2)->sin6_scope_id)
|
1994-05-26 06:35:07 +00:00
|
|
|
return (1);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (1);
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
|
|
|
|
return memcmp(p1, p2, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
namematch(struct addrinfo *ai)
|
|
|
|
{
|
|
|
|
struct addrinfo *aip;
|
|
|
|
|
|
|
|
if (nfshost == NULL || nfshost_ai == NULL)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
while (ai != NULL) {
|
|
|
|
aip = nfshost_ai;
|
|
|
|
while (aip != NULL) {
|
|
|
|
if (sacmp(ai->ai_addr, aip->ai_addr) == 0)
|
1994-05-26 06:35:07 +00:00
|
|
|
return (1);
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
aip = aip->ai_next;
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
ai = ai->ai_next;
|
1994-05-26 06:35:07 +00:00
|
|
|
}
|
Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.
Bring in required TLI library routines to support this.
Since we don't support TLI we've essentially copied what NetBSD
has done, adding a thin layer to emulate direct the TLI calls
into BSD socket calls.
This is mostly from Sun's tirpc release that was made in 1994,
however some fixes were backported from the 1999 release (supposedly
only made available after this porting effort was underway).
The submitter has agreed to continue on and bring us up to the
1999 release.
Several key features are introduced with this update:
Client calls are thread safe. (1999 code has server side thread
safe)
Updated, a more modern interface.
Many userland updates were done to bring the code up to par with
the recent RPC API.
There is an update to the pthreads library, a function
pthread_main_np() was added to emulate a function of Sun's threads
library.
While we're at it, bring in NetBSD's lockd, it's been far too
long of a wait.
New rpcbind(8) replaces portmap(8) (supporting communication over
an authenticated Unix-domain socket, and by default only allowing
set and unset requests over that channel). It's much more secure
than the old portmapper.
Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
to support TI-RPC and to support IPV6.
Umount(8) is also fixed to unmount pathnames longer than 80 chars,
which are currently truncated by the Kernel statfs structure.
Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00
|
|
|
|
1994-05-26 06:35:07 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-07-01 17:40:23 +00:00
|
|
|
struct statfs *
|
2003-07-18 08:01:10 +00:00
|
|
|
checkmntlist(char *name)
|
1999-10-17 16:26:58 +00:00
|
|
|
{
|
2003-07-01 17:40:23 +00:00
|
|
|
struct statfs *sfs;
|
2003-07-20 00:11:27 +00:00
|
|
|
fsid_t fsid;
|
1999-10-17 16:26:58 +00:00
|
|
|
|
2003-07-20 00:11:27 +00:00
|
|
|
sfs = NULL;
|
|
|
|
if (parsehexfsid(name, &fsid) == 0)
|
|
|
|
sfs = getmntentry(NULL, NULL, &fsid, FIND);
|
2003-07-18 17:43:13 +00:00
|
|
|
if (sfs == NULL)
|
2003-07-20 00:11:27 +00:00
|
|
|
sfs = getmntentry(NULL, name, NULL, FIND);
|
2003-07-01 17:40:23 +00:00
|
|
|
if (sfs == NULL)
|
2003-07-20 00:11:27 +00:00
|
|
|
sfs = getmntentry(name, NULL, NULL, FIND);
|
2003-07-01 17:40:23 +00:00
|
|
|
return (sfs);
|
1999-10-17 16:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
mntinfo(struct statfs **mntbuf)
|
|
|
|
{
|
|
|
|
static struct statfs *origbuf;
|
|
|
|
size_t bufsize;
|
|
|
|
int mntsize;
|
|
|
|
|
1999-11-22 04:23:11 +00:00
|
|
|
mntsize = getfsstat(NULL, 0, MNT_NOWAIT);
|
1999-10-17 16:26:58 +00:00
|
|
|
if (mntsize <= 0)
|
|
|
|
return (0);
|
|
|
|
bufsize = (mntsize + 1) * sizeof(struct statfs);
|
|
|
|
if ((origbuf = malloc(bufsize)) == NULL)
|
|
|
|
err(1, "malloc");
|
|
|
|
mntsize = getfsstat(origbuf, (long)bufsize, MNT_NOWAIT);
|
|
|
|
*mntbuf = origbuf;
|
|
|
|
return (mntsize);
|
|
|
|
}
|
|
|
|
|
2003-07-20 00:11:27 +00:00
|
|
|
/*
|
|
|
|
* Convert a hexidecimal filesystem ID to an fsid_t.
|
|
|
|
* Returns 0 on success.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
parsehexfsid(const char *hex, fsid_t *fsid)
|
1999-10-17 16:26:58 +00:00
|
|
|
{
|
2003-07-20 00:11:27 +00:00
|
|
|
char hexbuf[3];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (strlen(hex) != sizeof(*fsid) * 2)
|
|
|
|
return (-1);
|
|
|
|
hexbuf[2] = '\0';
|
2003-10-29 17:44:36 +00:00
|
|
|
for (i = 0; i < (int)sizeof(*fsid); i++) {
|
2003-07-20 00:11:27 +00:00
|
|
|
hexbuf[0] = hex[i * 2];
|
|
|
|
hexbuf[1] = hex[i * 2 + 1];
|
|
|
|
if (!isxdigit(hexbuf[0]) || !isxdigit(hexbuf[1]))
|
|
|
|
return (-1);
|
|
|
|
((u_char *)fsid)[i] = strtol(hexbuf, NULL, 16);
|
1999-10-17 16:26:58 +00:00
|
|
|
}
|
2003-07-20 00:11:27 +00:00
|
|
|
return (0);
|
1999-10-17 16:26:58 +00:00
|
|
|
}
|
|
|
|
|
1994-05-26 06:35:07 +00:00
|
|
|
/*
|
|
|
|
* xdr routines for mount rpc's
|
|
|
|
*/
|
|
|
|
int
|
1999-10-17 16:26:58 +00:00
|
|
|
xdr_dir(XDR *xdrsp, char *dirp)
|
1994-05-26 06:35:07 +00:00
|
|
|
{
|
1999-10-17 16:26:58 +00:00
|
|
|
|
1994-05-26 06:35:07 +00:00
|
|
|
return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usage()
|
|
|
|
{
|
1999-10-17 16:26:58 +00:00
|
|
|
|
1997-06-19 14:44:24 +00:00
|
|
|
(void)fprintf(stderr, "%s\n%s\n",
|
|
|
|
"usage: umount [-fv] special | node",
|
2003-04-07 12:56:01 +00:00
|
|
|
" umount -a | -A [ -F fstab] [-fv] [-h host] [-t type]");
|
1994-05-26 06:35:07 +00:00
|
|
|
exit(1);
|
|
|
|
}
|