summaryrefslogtreecommitdiffstats
path: root/contrib/amd
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2003-09-02 15:42:57 +0000
committermbr <mbr@FreeBSD.org>2003-09-02 15:42:57 +0000
commitfa2df21e0559a4a9af7f4504ac75a0ff043eaeb9 (patch)
tree361063e0f962fb2fd69f626b26e596899c16d3cd /contrib/amd
parentccc3812476e334ade5336aa157187088e2026fd3 (diff)
downloadFreeBSD-src-fa2df21e0559a4a9af7f4504ac75a0ff043eaeb9.zip
FreeBSD-src-fa2df21e0559a4a9af7f4504ac75a0ff043eaeb9.tar.gz
Resolve conflicts.
Diffstat (limited to 'contrib/amd')
-rw-r--r--contrib/amd/amd/amd.86
-rw-r--r--contrib/amd/amd/amd.c4
-rw-r--r--contrib/amd/amd/amq_subr.c4
-rw-r--r--contrib/amd/amd/get_args.c16
-rw-r--r--contrib/amd/amd/ops_autofs.c1279
-rw-r--r--contrib/amd/amd/srvr_nfs.c49
-rw-r--r--contrib/amd/amq/amq.83
-rw-r--r--contrib/amd/amq/amq.c8
-rw-r--r--contrib/amd/amq/pawd.14
-rw-r--r--contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h4
-rw-r--r--contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h12
-rw-r--r--contrib/amd/doc/stamp-vti3
-rw-r--r--contrib/amd/fixmount/fixmount.84
-rw-r--r--contrib/amd/fixmount/fixmount.c4
-rw-r--r--contrib/amd/fsinfo/fsinfo.811
-rw-r--r--contrib/amd/fsinfo/fsinfo.c7
-rw-r--r--contrib/amd/hlfsd/hlfsd.86
-rw-r--r--contrib/amd/hlfsd/hlfsd.c43
-rw-r--r--contrib/amd/hlfsd/hlfsd.h8
-rw-r--r--contrib/amd/hlfsd/homedir.c121
-rw-r--r--contrib/amd/include/am_defs.h26
-rw-r--r--contrib/amd/libamu/mount_fs.c143
-rw-r--r--contrib/amd/mk-amd-map/mk-amd-map.84
-rw-r--r--contrib/amd/mk-amd-map/mk-amd-map.c21
-rw-r--r--contrib/amd/scripts/amd.conf.5260
-rw-r--r--contrib/amd/wire-test/wire-test.84
-rw-r--r--contrib/amd/wire-test/wire-test.c4
27 files changed, 437 insertions, 1621 deletions
diff --git a/contrib/amd/amd/amd.8 b/contrib/amd/amd/amd.8
index da10482..f98bae7 100644
--- a/contrib/amd/amd/amd.8
+++ b/contrib/amd/amd/amd.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1989 Jan-Simon Pendry
.\" Copyright (c) 1989 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: amd.8,v 1.3 1999/09/30 21:01:29 ezk Exp $
+.\" $Id: amd.8,v 1.4.2.4 2003/03/16 01:46:59 ezk Exp $
.\" $FreeBSD$
.\"
.Dd April 19, 1994
@@ -183,7 +183,7 @@ Specify the NFS timeout
in tenths of a second, between
.Tn NFS/RPC
retries (for UDP only). The default
-is 0.8 seconds. The second value alters the restransmit counter, which
+is 0.8 seconds. The second value alters the retransmit counter, which
defaults to 11 retransmissions. Both of these values are used by the kernel
to communicate with amd. Useful defaults are supplied if either or both
values are missing.
diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c
index 1ad6d0a..1cc97b7 100644
--- a/contrib/amd/amd/amd.c
+++ b/contrib/amd/amd/amd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: amd.c,v 1.8.2.3 2001/01/10 03:22:59 ezk Exp $
+ * $Id: amd.c,v 1.8.2.5 2002/12/27 22:44:29 ezk Exp $
* $FreeBSD$
*
*/
diff --git a/contrib/amd/amd/amq_subr.c b/contrib/amd/amd/amq_subr.c
index e8b8c78..6ce7bfa 100644
--- a/contrib/amd/amd/amq_subr.c
+++ b/contrib/amd/amd/amq_subr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: amq_subr.c,v 1.6.2.2 2001/01/12 22:43:42 ro Exp $
+ * $Id: amq_subr.c,v 1.6.2.4 2002/12/27 22:44:33 ezk Exp $
* $FreeBSD$
*
*/
diff --git a/contrib/amd/amd/get_args.c b/contrib/amd/amd/get_args.c
index 0f52218..cc9847d 100644
--- a/contrib/amd/amd/get_args.c
+++ b/contrib/amd/amd/get_args.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: get_args.c,v 1.7.2.1 2001/01/10 03:23:05 ezk Exp $
+ * $Id: get_args.c,v 1.7.2.5 2002/12/27 22:44:34 ezk Exp $
* $FreeBSD$
*
*/
@@ -86,7 +86,7 @@ get_version_string(void)
vers = xmalloc(2048 + wire_buf_len);
sprintf(vers, "%s\n%s\n%s\n%s\n",
- "Copyright (c) 1997-2001 Erez Zadok",
+ "Copyright (c) 1997-2003 Erez Zadok",
"Copyright (c) 1990 Jan-Simon Pendry",
"Copyright (c) 1990 Imperial College of Science, Technology & Medicine",
"Copyright (c) 1990 The Regents of the University of California.");
@@ -128,12 +128,20 @@ get_args(int argc, char *argv[])
{
int opt_ch;
FILE *fp = stdin;
+ char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:H";
+ char *getopt_args;
+
+#ifdef HAVE_GNU_GETOPT
+ getopt_args = getopt_arguments;
+#else /* ! HAVE_GNU_GETOPT */
+ getopt_args = &getopt_arguments[1];
+#endif /* HAVE_GNU_GETOPT */
/* if no arguments were passed, try to use /etc/amd.conf file */
if (argc <= 1)
use_conf_file = 1;
- while ((opt_ch = getopt(argc, argv, "nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:H")) != -1)
+ while ((opt_ch = getopt(argc, argv, getopt_args)) != -1)
switch (opt_ch) {
case 'a':
diff --git a/contrib/amd/amd/ops_autofs.c b/contrib/amd/amd/ops_autofs.c
deleted file mode 100644
index bd0bb12..0000000
--- a/contrib/amd/amd/ops_autofs.c
+++ /dev/null
@@ -1,1279 +0,0 @@
-/*
- * Copyright (c) 1997-2001 Erez Zadok
- * Copyright (c) 1990 Jan-Simon Pendry
- * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry at Imperial College, London.
- *
- * 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 acknowledgment:
- * 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.
- *
- * %W% (Berkeley) %G%
- *
- * $Id: ops_autofs.c,v 1.7.2.4 2001/04/24 06:17:40 ib42 Exp $
- *
- */
-
-/*
- * Automounter filesystem
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-#include <am_defs.h>
-#include <amd.h>
-
-/*
- * KLUDGE: wrap whole file in HAVE_FS_AUTOFS, because
- * not all systems with an automounter file system are supported
- * by am-utils yet...
- */
-
-#ifdef HAVE_FS_AUTOFS
-
-/*
- * MACROS:
- */
-#ifndef AUTOFS_NULL
-# define AUTOFS_NULL ((u_long)0)
-#endif /* not AUTOFS_NULL */
-
-/*
- * VARIABLES:
- */
-
-/* forward declarations */
-static int mount_autofs(char *dir, char *opts);
-static int autofs_mount_1_svc(struct mntrequest *mr, struct mntres *result, struct authunix_parms *cred);
-static int autofs_unmount_1_svc(struct umntrequest *ur, struct umntres *result, struct authunix_parms *cred);
-
-/* external declarations */
-extern bool_t xdr_mntrequest(XDR *, mntrequest *);
-extern bool_t xdr_mntres(XDR *, mntres *);
-extern bool_t xdr_umntrequest(XDR *, umntrequest *);
-extern bool_t xdr_umntres(XDR *, umntres *);
-
-/*
- * STRUCTURES:
- */
-
-/* Sun's kernel-based automounter-supporting file system */
-am_ops autofs_ops =
-{
- "autofs",
- amfs_auto_match,
- 0, /* amfs_auto_init */
- autofs_mount,
- 0,
- autofs_umount,
- 0,
- amfs_auto_lookuppn,
- amfs_auto_readdir, /* browsable version of readdir() */
- 0, /* autofs_readlink */
- autofs_mounted,
- 0, /* autofs_umounted */
- find_amfs_auto_srvr,
- FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY
-};
-
-
-/****************************************************************************
- *** FUNCTIONS ***
- ****************************************************************************/
-
-/*
- * Mount the top-level using autofs
- */
-int
-autofs_mount(am_node *mp)
-{
- mntfs *mf = mp->am_mnt;
- struct stat stb;
- char opts[256], preopts[256];
- int error;
- char *mnttype;
-
- /*
- * Mounting the automounter.
- * Make sure the mount directory exists, construct
- * the mount options and call the mount_autofs routine.
- */
-
- if (stat(mp->am_path, &stb) < 0) {
- return errno;
- } else if ((stb.st_mode & S_IFMT) != S_IFDIR) {
- plog(XLOG_WARNING, "%s is not a directory", mp->am_path);
- return ENOTDIR;
- }
- if (mf->mf_ops == &autofs_ops)
- mnttype = "indirect";
- else if (mf->mf_ops == &amfs_direct_ops)
- mnttype = "direct";
-#ifdef HAVE_AMU_FS_UNION
- else if (mf->mf_ops == &amfs_union_ops)
- mnttype = "union";
-#endif /* HAVE_AMU_FS_UNION */
- else
- mnttype = "auto";
-
- /*
- * Construct some mount options:
- *
- * Tack on magic map=<mapname> option in mtab to emulate
- * SunOS automounter behavior.
- */
- preopts[0] = '\0';
-#ifdef MNTTAB_OPT_INTR
- strcat(preopts, MNTTAB_OPT_INTR);
- strcat(preopts, ",");
-#endif /* MNTTAB_OPT_INTR */
-#ifdef MNTTAB_OPT_IGNORE
- strcat(preopts, MNTTAB_OPT_IGNORE);
- strcat(preopts, ",");
-#endif /* MNTTAB_OPT_IGNORE */
- sprintf(opts, "%s%s,%s=%d,%s=%d,%s=%d,%s,map=%s",
- preopts,
- MNTTAB_OPT_RW,
- MNTTAB_OPT_PORT, nfs_port,
- MNTTAB_OPT_TIMEO, gopt.amfs_auto_timeo,
- MNTTAB_OPT_RETRANS, gopt.amfs_auto_retrans,
- mnttype, mf->mf_info);
-
- /* now do the mount */
- error = mount_autofs(mf->mf_mount, opts);
- if (error) {
- errno = error;
- plog(XLOG_FATAL, "mount_autofs: %m");
- return error;
- }
- return 0;
-}
-
-
-void
-autofs_mounted(mntfs *mf)
-{
- amfs_auto_mkcacheref(mf);
-}
-
-
-/*
- * Unmount a top-level automount node
- */
-int
-autofs_umount(am_node *mp)
-{
- int error;
- struct stat stb;
-
- /*
- * The lstat is needed if this mount is type=direct. When that happens,
- * the kernel cache gets confused between the underlying type (dir) and
- * the mounted type (link) and so needs to be re-synced before the
- * unmount. This is all because the unmount system call follows links and
- * so can't actually unmount a link (stupid!). It was noted that doing an
- * ls -ld of the mount point to see why things were not working actually
- * fixed the problem - so simulate an ls -ld here.
- */
- if (lstat(mp->am_path, &stb) < 0) {
-#ifdef DEBUG
- dlog("lstat(%s): %m", mp->am_path);
-#endif /* DEBUG */
- }
- error = UMOUNT_FS(mp->am_path, mnttab_file_name);
- if (error == EBUSY && mp->am_flags & AMF_AUTOFS) {
- plog(XLOG_WARNING, "autofs_unmount of %s busy (autofs). exit", mp->am_path);
- error = 0; /* fake unmount was ok */
- }
- return error;
-}
-
-
-/*
- * Mount an automounter directory.
- * The automounter is connected into the system
- * as a user-level NFS server. mount_autofs constructs
- * the necessary NFS parameters to be given to the
- * kernel so that it will talk back to us.
- */
-static int
-mount_autofs(char *dir, char *opts)
-{
- char fs_hostname[MAXHOSTNAMELEN + MAXPATHLEN + 1];
- char *map_opt, buf[MAXHOSTNAMELEN];
- int retry, error, flags;
- struct utsname utsname;
- mntent_t mnt;
- autofs_args_t autofs_args;
- MTYPE_TYPE type = MOUNT_TYPE_AUTOFS;
-
- memset((voidp) &autofs_args, 0, sizeof(autofs_args)); /* Paranoid */
-
- memset((voidp) &mnt, 0, sizeof(mnt));
- mnt.mnt_dir = dir;
- mnt.mnt_fsname = pid_fsname;
- mnt.mnt_opts = opts;
- mnt.mnt_type = type;
-
- retry = hasmntval(&mnt, "retry");
- if (retry <= 0)
- retry = 2; /* XXX */
-
- /*
- * SET MOUNT ARGS
- */
- if (uname(&utsname) < 0) {
- strcpy(buf, "localhost.autofs");
- } else {
- strcpy(buf, utsname.nodename);
- strcat(buf, ".autofs");
- }
-#ifdef HAVE_FIELD_AUTOFS_ARGS_T_ADDR
- autofs_args.addr.buf = buf;
- autofs_args.addr.len = strlen(autofs_args.addr.buf);
- autofs_args.addr.maxlen = autofs_args.addr.len;
-#endif /* HAVE_FIELD_AUTOFS_ARGS_T_ADDR */
-
- autofs_args.path = dir;
- autofs_args.opts = opts;
-
- map_opt = hasmntopt(&mnt, "map");
- if (map_opt) {
- map_opt += sizeof("map="); /* skip the "map=" */
- if (map_opt == NULL) {
- plog(XLOG_WARNING, "map= has a null map name. reset to amd.unknown");
- map_opt = "amd.unknown";
- }
- }
- autofs_args.map = map_opt;
-
- /* XXX: these I set arbitrarily... */
- autofs_args.mount_to = 300;
- autofs_args.rpc_to = 60;
- autofs_args.direct = 0;
-
- /*
- * Make a ``hostname'' string for the kernel
- */
- sprintf(fs_hostname, "pid%ld@%s:%s",
- (long) (foreground ? am_mypid : getppid()),
- am_get_hostname(), dir);
-
- /*
- * Most kernels have a name length restriction.
- */
- if (strlen(fs_hostname) >= MAXHOSTNAMELEN)
- strcpy(fs_hostname + MAXHOSTNAMELEN - 3, "..");
-
- /*
- * Finally we can compute the mount flags set above.
- */
- flags = compute_mount_flags(&mnt);
-
- /*
- * This is it! Here we try to mount amd on its mount points.
- */
- error = mount_fs(&mnt, flags, (caddr_t) &autofs_args, retry, type, 0, NULL, mnttab_file_name);
- return error;
-}
-
-
-/****************************************************************************/
-/* autofs program dispatcher */
-void
-autofs_program_1(struct svc_req *rqstp, SVCXPRT *transp)
-{
- int ret;
- union {
- mntrequest autofs_mount_1_arg;
- umntrequest autofs_umount_1_arg;
- } argument;
- union {
- mntres mount_res;
- umntres umount_res;
- } result;
-
- bool_t (*xdr_argument)(), (*xdr_result)();
- int (*local)();
-
- switch (rqstp->rq_proc) {
-
- case AUTOFS_NULL:
- svc_sendreply(transp,
- (XDRPROC_T_TYPE) xdr_void,
- (SVC_IN_ARG_TYPE) NULL);
- return;
-
- case AUTOFS_MOUNT:
- xdr_argument = xdr_mntrequest;
- xdr_result = xdr_mntres;
- local = (int (*)()) autofs_mount_1_svc;
- break;
-
- case AUTOFS_UNMOUNT:
- xdr_argument = xdr_umntrequest;
- xdr_result = xdr_umntres;
- local = (int (*)()) autofs_unmount_1_svc;
- break;
-
- default:
- svcerr_noproc(transp);
- return;
- }
-
- memset((char *) &argument, 0, sizeof(argument));
- if (!svc_getargs(transp,
- (XDRPROC_T_TYPE) xdr_argument,
- (SVC_IN_ARG_TYPE) &argument)) {
- plog(XLOG_ERROR,
- "AUTOFS xdr decode failed for %d %d %d",
- (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc);
- svcerr_decode(transp);
- return;
- }
-
- ret = (*local) (&argument, &result, rqstp);
- if (!svc_sendreply(transp,
- (XDRPROC_T_TYPE) xdr_result,
- (SVC_IN_ARG_TYPE) &result)) {
- svcerr_systemerr(transp);
- }
-
- if (!svc_freeargs(transp,
- (XDRPROC_T_TYPE) xdr_argument,
- (SVC_IN_ARG_TYPE) &argument)) {
- plog(XLOG_FATAL, "unable to free rpc arguments in autofs_program_1");
- going_down(1);
- }
-}
-
-
-static int
-autofs_mount_1_svc(struct mntrequest *mr, struct mntres *result, struct authunix_parms *cred)
-{
- int err = 0;
- am_node *anp, *anp2;
-
- plog(XLOG_INFO, "XXX: autofs_mount_1_svc: %s:%s:%s:%s",
- mr->map, mr->name, mr->opts, mr->path);
-
- /* look for map (eg. "/home") */
- anp = find_ap(mr->path);
- if (!anp) {
- plog(XLOG_ERROR, "map %s not found", mr->path);
- err = ENOENT;
- goto out;
- }
- /* turn on autofs in map flags */
- if (!(anp->am_flags & AMF_AUTOFS)) {
- plog(XLOG_INFO, "turning on AMF_AUTOFS for node %s", mr->path);
- anp->am_flags |= AMF_AUTOFS;
- }
-
- /*
- * Look for (and create if needed) the new node.
- *
- * If an error occurred, return it. If a -1 was returned, that indicates
- * that a mount is in progress, so sleep a while (while the backgrounded
- * mount is happening), and then signal the autofs to retry the mount.
- *
- * There's something I don't understand. I was thinking that this code
- * here is the one which will succeed eventually and will send an RPC
- * reply to the kernel, but apparently that happens somewhere else, not
- * here. It works though, just that I don't know how. Arg. -Erez.
- * */
- err = 0;
- anp2 = autofs_lookuppn(anp, mr->name, &err, VLOOK_CREATE);
- if (!anp2) {
- if (err == -1) { /* then tell autofs to retry */
- sleep(1);
- err = EAGAIN;
- }
- goto out;
- }
-
-out:
- result->status = err;
- return err;
-}
-
-
-static int
-autofs_unmount_1_svc(struct umntrequest *ur, struct umntres *result, struct authunix_parms *cred)
-{
- int err = 0;
-
-#ifdef HAVE_FIELD_UMNTREQUEST_RDEVID
- plog(XLOG_INFO, "XXX: autofs_unmount_1_svc: %d:%lu:%lu:0x%lx",
- ur->isdirect, (unsigned long) ur->devid, (unsigned long) ur->rdevid,
- (unsigned long) ur->next);
-#else /* HAVE_FIELD_UMNTREQUEST_RDEVID */
- plog(XLOG_INFO, "XXX: autofs_unmount_1_svc: %d:%lu:0x%lx",
- ur->isdirect, (unsigned long) ur->devid,
- (unsigned long) ur->next);
-#endif /* HAVE_FIELD_UMNTREQUEST_RDEVID */
-
- err = EINVAL; /* XXX: not implemented yet */
- goto out;
-
-out:
- result->status = err;
- return err;
-}
-
-
-/*
- * Pick a file system to try mounting and
- * do that in the background if necessary
- *
- For each location:
- if it is new -defaults then
- extract and process
- continue;
- fi
- if it is a cut then
- if a location has been tried then
- break;
- fi
- continue;
- fi
- parse mount location
- discard previous mount location if required
- find matching mounted filesystem
- if not applicable then
- this_error = No such file or directory
- continue
- fi
- if the filesystem failed to be mounted then
- this_error = error from filesystem
- elif the filesystem is mounting or unmounting then
- this_error = -1
- elif the fileserver is down then
- this_error = -1
- elif the filesystem is already mounted
- this_error = 0
- break
- fi
- if no error on this mount then
- this_error = initialize mount point
- fi
- if no error on this mount and mount is delayed then
- this_error = -1
- fi
- if this_error < 0 then
- retry = true
- fi
- if no error on this mount then
- make mount point if required
- fi
- if no error on this mount then
- if mount in background then
- run mount in background
- return -1
- else
- this_error = mount in foreground
- fi
- fi
- if an error occurred on this mount then
- update stats
- save error in mount point
- fi
- endfor
- */
-static int
-autofs_bgmount(struct continuation *cp, int mpe)
-{
- mntfs *mf = cp->mp->am_mnt; /* Current mntfs */
- mntfs *mf_retry = 0; /* First mntfs which needed retrying */
- int this_error = -1; /* Per-mount error */
- int hard_error = -1;
- int mp_error = mpe;
-
- /*
- * Try to mount each location.
- * At the end:
- * hard_error == 0 indicates something was mounted.
- * hard_error > 0 indicates everything failed with a hard error
- * hard_error < 0 indicates nothing could be mounted now
- */
- for (; this_error && *cp->ivec; cp->ivec++) {
- am_ops *p;
- am_node *mp = cp->mp;
- char *link_dir;
- int dont_retry;
-
- if (hard_error < 0)
- hard_error = this_error;
-
- this_error = -1;
-
- if (**cp->ivec == '-') {
- /*
- * Pick up new defaults
- */
- if (cp->auto_opts && *cp->auto_opts)
- cp->def_opts = str3cat(cp->def_opts, cp->auto_opts, ";", *cp->ivec + 1);
- else
- cp->def_opts = strealloc(cp->def_opts, *cp->ivec + 1);
-#ifdef DEBUG
- dlog("Setting def_opts to \"%s\"", cp->def_opts);
-#endif /* DEBUG */
- continue;
- }
- /*
- * If a mount has been attempted, and we find
- * a cut then don't try any more locations.
- */
- if (STREQ(*cp->ivec, "/") || STREQ(*cp->ivec, "||")) {
- if (cp->tried) {
-#ifdef DEBUG
- dlog("Cut: not trying any more locations for %s",
- mp->am_path);
-#endif /* DEBUG */
- break;
- }
- continue;
- }
-
- /* match the operators */
- p = ops_match(&cp->fs_opts, *cp->ivec, cp->def_opts, mp->am_path, cp->key, mp->am_parent->am_mnt->mf_info);
-
- /*
- * Find a mounted filesystem for this node.
- */
- mp->am_mnt = mf = realloc_mntfs(mf, p, &cp->fs_opts,
- cp->fs_opts.opt_fs,
- cp->fs_opts.fs_mtab,
- cp->auto_opts,
- cp->fs_opts.opt_opts,
- cp->fs_opts.opt_remopts);
-
- p = mf->mf_ops;
-#ifdef DEBUG
- dlog("Got a hit with %s", p->fs_type);
-#endif /* DEBUG */
-
- /*
- * Note whether this is a real mount attempt
- */
- if (p == &amfs_error_ops) {
- plog(XLOG_MAP, "Map entry %s for %s did not match", *cp->ivec, mp->am_path);
- if (this_error <= 0)
- this_error = ENOENT;
- continue;
- } else {
- if (cp->fs_opts.fs_mtab) {
- plog(XLOG_MAP, "Trying mount of %s on \"%s\" fstype %s",
- cp->fs_opts.fs_mtab, mp->am_path, p->fs_type);
- }
- cp->tried = TRUE;
- }
-
- this_error = 0;
- dont_retry = FALSE;
-
- if (mp->am_link) {
- XFREE(mp->am_link);
- mp->am_link = 0;
- }
- link_dir = mf->mf_fo->opt_sublink;
-
- if (link_dir && *link_dir) {
- if (*link_dir == '/') {
- mp->am_link = strdup(link_dir);
- } else {
- /*
- * try getting fs option from continuation, not mountpoint!
- * Don't try logging the string from mf, since it may be bad!
- */
- if (cp->fs_opts.opt_fs != mf->mf_fo->opt_fs)
- plog(XLOG_ERROR, "use %s instead of 0x%lx",
- cp->fs_opts.opt_fs, (unsigned long) mf->mf_fo->opt_fs);
-
- mp->am_link = str3cat((char *) 0,
- cp->fs_opts.opt_fs, "/", link_dir);
-
- normalize_slash(mp->am_link);
- }
- }
-
- if (mf->mf_error > 0) {
- this_error = mf->mf_error;
- } else if (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)) {
- /*
- * Still mounting - retry later
- */
-#ifdef DEBUG
- dlog("Duplicate pending mount fstype %s", p->fs_type);
-#endif /* DEBUG */
- this_error = -1;
- } else if (FSRV_ISDOWN(mf->mf_server)) {
- /*
- * Would just mount from the same place
- * as a hung mount - so give up
- */
-#ifdef DEBUG
- dlog("%s is already hung - giving up", mf->mf_mount);
-#endif /* DEBUG */
- mp_error = EWOULDBLOCK;
- dont_retry = TRUE;
- this_error = -1;
- } else if (mf->mf_flags & MFF_MOUNTED) {
-#ifdef DEBUG
- dlog("duplicate mount of \"%s\" ...", mf->mf_info);
-#endif /* DEBUG */
-
- /*
- * Just call mounted()
- */
- am_mounted(mp);
-
- this_error = 0;
- break;
- }
-
- /*
- * Will usually need to play around with the mount nodes
- * file attribute structure. This must be done here.
- * Try and get things initialized, even if the fileserver
- * is not known to be up. In the common case this will
- * progress things faster.
- */
- if (!this_error) {
- /*
- * Fill in attribute fields.
- */
- if (mf->mf_ops->fs_flags & FS_DIRECTORY)
- mk_fattr(mp, NFDIR);
- else
- mk_fattr(mp, NFLNK);
-
- if (p->fs_init)
- this_error = (*p->fs_init) (mf);
- }
-
- /*
- * Make sure the fileserver is UP before doing any more work
- */
- if (!FSRV_ISUP(mf->mf_server)) {
-#ifdef DEBUG
- dlog("waiting for server %s to become available", mf->mf_server->fs_host);
-#endif /* DEBUG */
- this_error = -1;
- }
-
- if (!this_error && mf->mf_fo->opt_delay) {
- /*
- * If there is a delay timer on the mount
- * then don't try to mount if the timer
- * has not expired.
- */
- int i = atoi(mf->mf_fo->opt_delay);
- if (i > 0 && clocktime() < (cp->start + i)) {
-#ifdef DEBUG
- dlog("Mount of %s delayed by %lds", mf->mf_mount, i - clocktime() + cp->start);
-#endif /* DEBUG */
- this_error = -1;
- }
- }
-
- if (this_error < 0 && !dont_retry) {
- if (!mf_retry)
- mf_retry = dup_mntfs(mf);
- cp->retry = TRUE;
- }
-
- if (!this_error) {
- if (p->fs_flags & FS_MBACKGROUND) {
- mf->mf_flags |= MFF_MOUNTING; /* XXX */
-#ifdef DEBUG
- dlog("backgrounding mount of \"%s\"", mf->mf_mount);
-#endif /* DEBUG */
- if (cp->callout) {
- untimeout(cp->callout);
- cp->callout = 0;
- }
- run_task(try_mount, (voidp) mp, amfs_auto_cont, (voidp) cp);
- mf->mf_flags |= MFF_MKMNT; /* XXX */
- if (mf_retry)
- free_mntfs(mf_retry);
- return -1;
- } else {
-#ifdef DEBUG
- dlog("foreground mount of \"%s\" ...", mf->mf_info);
-#endif /* DEBUG */
- this_error = try_mount((voidp) mp);
- if (this_error < 0) {
- if (!mf_retry)
- mf_retry = dup_mntfs(mf);
- cp->retry = TRUE;
- }
- }
- }
-
- if (this_error >= 0) {
- if (this_error > 0) {
- amd_stats.d_merr++;
- if (mf != mf_retry) {
- mf->mf_error = this_error;
- mf->mf_flags |= MFF_ERROR;
- }
- }
-
- /*
- * Wakeup anything waiting for this mount
- */
- wakeup((voidp) mf);
- }
- }
-
- if (this_error && cp->retry) {
- free_mntfs(mf);
- mf = cp->mp->am_mnt = mf_retry;
- /*
- * Not retrying again (so far)
- */
- cp->retry = FALSE;
- cp->tried = FALSE;
- /*
- * Start at the beginning.
- * Rewind the location vector and
- * reset the default options.
- */
- cp->ivec = cp->xivec;
- cp->def_opts = strealloc(cp->def_opts, cp->auto_opts);
- /*
- * Arrange that autofs_bgmount is called
- * after anything else happens.
- */
-#ifdef DEBUG
- dlog("Arranging to retry mount of %s", cp->mp->am_path);
-#endif /* DEBUG */
- sched_task(amfs_auto_retry, (voidp) cp, (voidp) mf);
- if (cp->callout)
- untimeout(cp->callout);
- cp->callout = timeout(RETRY_INTERVAL, wakeup, (voidp) mf);
-
- cp->mp->am_ttl = clocktime() + RETRY_INTERVAL;
-
- /*
- * Not done yet - so don't return anything
- */
- return -1;
- }
-
- if (hard_error < 0 || this_error == 0)
- hard_error = this_error;
-
- /*
- * Discard handle on duff filesystem.
- * This should never happen since it
- * should be caught by the case above.
- */
- if (mf_retry) {
- if (hard_error)
- plog(XLOG_ERROR, "discarding a retry mntfs for %s", mf_retry->mf_mount);
- free_mntfs(mf_retry);
- }
-
- /*
- * If we get here, then either the mount succeeded or
- * there is no more mount information available.
- */
- if (hard_error < 0 && mp_error)
- hard_error = cp->mp->am_error = mp_error;
- if (hard_error > 0) {
- /*
- * Set a small(ish) timeout on an error node if
- * the error was not a time out.
- */
- switch (hard_error) {
- case ETIMEDOUT:
- case EWOULDBLOCK:
- cp->mp->am_timeo = 17;
- break;
- default:
- cp->mp->am_timeo = 5;
- break;
- }
- new_ttl(cp->mp);
- }
-
- /*
- * Make sure that the error value in the mntfs has a
- * reasonable value.
- */
- if (mf->mf_error < 0) {
- mf->mf_error = hard_error;
- if (hard_error)
- mf->mf_flags |= MFF_ERROR;
- }
-
- /*
- * In any case we don't need the continuation any more
- */
- free_continuation(cp);
-
- return hard_error;
-}
-
-
-/*
- * Automount interface to RPC lookup routine
- * Find the corresponding entry and return
- * the file handle for it.
- */
-am_node *
-autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op)
-{
- am_node *ap, *new_mp, *ap_hung;
- char *info; /* Mount info - where to get the file system */
- char **ivec, **xivec; /* Split version of info */
- char *auto_opts; /* Automount options */
- int error = 0; /* Error so far */
- char path_name[MAXPATHLEN]; /* General path name buffer */
- char apath[MAXPATHLEN]; /* autofs path (added space) */
- char *pfname; /* Path for database lookup */
- struct continuation *cp; /* Continuation structure if need to mount */
- int in_progress = 0; /* # of (un)mount in progress */
- char *dflts;
- mntfs *mf;
-
-#ifdef DEBUG
- dlog("in autofs_lookuppn");
-#endif /* DEBUG */
-
- /*
- * If the server is shutting down
- * then don't return information
- * about the mount point.
- */
- if (amd_state == Finishing) {
-#ifdef DEBUG
- if ((mf = mp->am_mnt) == 0 || mf->mf_ops == &amfs_direct_ops) {
- dlog("%s mount ignored - going down", fname);
- } else {
- dlog("%s/%s mount ignored - going down", mp->am_path, fname);
- }
-#endif /* DEBUG */
- ereturn(ENOENT);
- }
-
- /*
- * Handle special case of "." and ".."
- */
- if (fname[0] == '.') {
- if (fname[1] == '\0')
- return mp; /* "." is the current node */
- if (fname[1] == '.' && fname[2] == '\0') {
- if (mp->am_parent) {
-#ifdef DEBUG
- dlog(".. in %s gives %s", mp->am_path, mp->am_parent->am_path);
-#endif /* DEBUG */
- return mp->am_parent; /* ".." is the parent node */
- }
- ereturn(ESTALE);
- }
- }
-
- /*
- * Check for valid key name.
- * If it is invalid then pretend it doesn't exist.
- */
- if (!valid_key(fname)) {
- plog(XLOG_WARNING, "Key \"%s\" contains a disallowed character", fname);
- ereturn(ENOENT);
- }
-
- /*
- * Expand key name.
- * fname is now a private copy.
- */
- fname = expand_key(fname);
-
- for (ap_hung = 0, ap = mp->am_child; ap; ap = ap->am_osib) {
- /*
- * Otherwise search children of this node
- */
- if (FSTREQ(ap->am_name, fname)) {
- mf = ap->am_mnt;
- if (ap->am_error) {
- error = ap->am_error;
- continue;
- }
- /*
- * If the error code is undefined then it must be
- * in progress.
- */
- if (mf->mf_error < 0)
- goto in_progrss;
-
- /*
- * Check for a hung node
- */
- if (FSRV_ISDOWN(mf->mf_server)) {
-#ifdef DEBUG
- dlog("server hung");
-#endif /* DEBUG */
- error = ap->am_error;
- ap_hung = ap;
- continue;
- }
- /*
- * If there was a previous error with this node
- * then return that error code.
- */
- if (mf->mf_flags & MFF_ERROR) {
- error = mf->mf_error;
- continue;
- }
- if (!(mf->mf_flags & MFF_MOUNTED) || (mf->mf_flags & MFF_UNMOUNTING)) {
- in_progrss:
- /*
- * If the fs is not mounted or it is unmounting then there
- * is a background (un)mount in progress. In this case
- * we just drop the RPC request (return nil) and
- * wait for a retry, by which time the (un)mount may
- * have completed.
- */
-#ifdef DEBUG
- dlog("ignoring mount of %s in %s -- flags (%x) in progress",
- fname, mf->mf_mount, mf->mf_flags);
-#endif /* DEBUG */
- in_progress++;
- continue;
- }
-
- /*
- * Otherwise we have a hit: return the current mount point.
- */
-#ifdef DEBUG
- dlog("matched %s in %s", fname, ap->am_path);
-#endif /* DEBUG */
- XFREE(fname);
- return ap;
- }
- }
-
- if (in_progress) {
-#ifdef DEBUG
- dlog("Waiting while %d mount(s) in progress", in_progress);
-#endif /* DEBUG */
- XFREE(fname);
- ereturn(-1);
- }
-
- /*
- * If an error occurred then return it.
- */
- if (error) {
-#ifdef DEBUG
- errno = error; /* XXX */
- dlog("Returning error: %m");
-#endif /* DEBUG */
- XFREE(fname);
- ereturn(error);
- }
-
- /*
- * If doing a delete then don't create again!
- */
- switch (op) {
- case VLOOK_DELETE:
- ereturn(ENOENT);
-
- case VLOOK_CREATE:
- break;
-
- default:
- plog(XLOG_FATAL, "Unknown op to autofs_lookuppn: 0x%x", op);
- ereturn(EINVAL);
- }
-
- /*
- * If the server is going down then just return,
- * don't try to mount any more file systems
- */
- if ((int) amd_state >= (int) Finishing) {
-#ifdef DEBUG
- dlog("not found - server going down anyway");
-#endif /* DEBUG */
- XFREE(fname);
- ereturn(ENOENT);
- }
-
- /*
- * If we get there then this is a reference to an,
- * as yet, unknown name so we need to search the mount
- * map for it.
- */
- if (mp->am_pref) {
- sprintf(path_name, "%s%s", mp->am_pref, fname);
- pfname = path_name;
- } else {
- pfname = fname;
- }
-
- mf = mp->am_mnt;
-
-#ifdef DEBUG
- dlog("will search map info in %s to find %s", mf->mf_info, pfname);
-#endif /* DEBUG */
- /*
- * Consult the oracle for some mount information.
- * info is malloc'ed and belongs to this routine.
- * It ends up being free'd in free_continuation().
- *
- * Note that this may return -1 indicating that information
- * is not yet available.
- */
- error = mapc_search((mnt_map *) mf->mf_private, pfname, &info);
- if (error) {
- if (error > 0)
- plog(XLOG_MAP, "No map entry for %s", pfname);
- else
- plog(XLOG_MAP, "Waiting on map entry for %s", pfname);
- XFREE(fname);
- ereturn(error);
- }
-#ifdef DEBUG
- dlog("mount info is %s", info);
-#endif /* DEBUG */
-
- /*
- * Split info into an argument vector.
- * The vector is malloc'ed and belongs to
- * this routine. It is free'd in free_continuation()
- */
- xivec = ivec = strsplit(info, ' ', '\"');
-
- /*
- * Default error code...
- */
- if (ap_hung)
- error = EWOULDBLOCK;
- else
- error = ENOENT;
-
- /*
- * Allocate a new map
- */
- new_mp = exported_ap_alloc();
- if (new_mp == 0) {
- XFREE(xivec);
- XFREE(info);
- XFREE(fname);
- ereturn(ENOSPC);
- }
- if (mf->mf_auto)
- auto_opts = mf->mf_auto;
- else
- auto_opts = "";
-
- auto_opts = strdup(auto_opts);
-
-#ifdef DEBUG
- dlog("searching for /defaults entry");
-#endif /* DEBUG */
- if (mapc_search((mnt_map *) mf->mf_private, "/defaults", &dflts) == 0) {
- char *dfl;
- char **rvec;
-#ifdef DEBUG
- dlog("/defaults gave %s", dflts);
-#endif /* DEBUG */
- if (*dflts == '-')
- dfl = dflts + 1;
- else
- dfl = dflts;
-
- /*
- * Chop the defaults up
- */
- rvec = strsplit(dfl, ' ', '\"');
-
- if (gopt.flags & CFM_SELECTORS_IN_DEFAULTS) {
- /*
- * Pick whichever first entry matched the list of selectors.
- * Strip the selectors from the string, and assign to dfl the
- * rest of the string.
- */
- if (rvec) {
- am_opts ap;
- am_ops *pt;
- char **sp = rvec;
- while (*sp) { /* loop until you find something, if any */
- memset((char *) &ap, 0, sizeof(am_opts));
- pt = ops_match(&ap, *sp, "", mp->am_path, "/defaults",
- mp->am_parent->am_mnt->mf_info);
- free_opts(&ap); /* don't leak */
- if (pt == &amfs_error_ops) {
- plog(XLOG_MAP, "did not match defaults for \"%s\"", *sp);
- } else {
- dfl = strip_selectors(*sp, "/defaults");
- plog(XLOG_MAP, "matched default selectors \"%s\"", dfl);
- break;
- }
- ++sp;
- }
- }
- } else { /* not selectors_in_defaults */
- /*
- * Extract first value
- */
- dfl = rvec[0];
- }
-
- /*
- * If there were any values at all...
- */
- if (dfl) {
- /*
- * Log error if there were other values
- */
- if (!(gopt.flags & CFM_SELECTORS_IN_DEFAULTS) && rvec[1]) {
-# ifdef DEBUG
- dlog("/defaults chopped into %s", dfl);
-# endif /* DEBUG */
- plog(XLOG_USER, "More than a single value for /defaults in %s", mf->mf_info);
- }
-
- /*
- * Prepend to existing defaults if they exist,
- * otherwise just use these defaults.
- */
- if (*auto_opts && *dfl) {
- char *nopts = (char *) xmalloc(strlen(auto_opts) + strlen(dfl) + 2);
- sprintf(nopts, "%s;%s", dfl, auto_opts);
- XFREE(auto_opts);
- auto_opts = nopts;
- } else if (*dfl) {
- auto_opts = strealloc(auto_opts, dfl);
- }
- }
- XFREE(dflts);
- /*
- * Don't need info vector any more
- */
- XFREE(rvec);
- }
-
- /*
- * Fill it in
- */
- init_map(new_mp, fname);
-
- /*
- * Turn on autofs flag if needed.
- */
- if (mp->am_flags & AMF_AUTOFS) {
- new_mp->am_flags |= AMF_AUTOFS;
- }
-
- /*
- * Put it in the table
- */
- insert_am(new_mp, mp);
-
- /*
- * Fill in some other fields,
- * path and mount point.
- *
- * bugfix: do not prepend old am_path if direct map
- * <wls@astro.umd.edu> William Sebok
- */
-
- strcpy(apath, fname);
- strcat(apath, " ");
- new_mp->am_path = str3cat(new_mp->am_path,
- mf->mf_ops == &amfs_direct_ops ? "" : mp->am_path,
- *fname == '/' ? "" : "/",
- apath);
-
-#ifdef DEBUG
- dlog("setting path to \"%s\"", new_mp->am_path);
-#endif /* DEBUG */
-
- /*
- * Take private copy of pfname
- */
- pfname = strdup(pfname);
-
- /*
- * Construct a continuation
- */
- cp = ALLOC(struct continuation);
- cp->callout = 0;
- cp->mp = new_mp;
- cp->xivec = xivec;
- cp->ivec = ivec;
- cp->info = info;
- cp->key = pfname;
- cp->auto_opts = auto_opts;
- cp->retry = FALSE;
- cp->tried = FALSE;
- cp->start = clocktime();
- cp->def_opts = strdup(auto_opts);
- memset((voidp) &cp->fs_opts, 0, sizeof(cp->fs_opts));
-
- /*
- * Try and mount the file system. If this succeeds immediately (possible
- * for a ufs file system) then return the attributes, otherwise just
- * return an error.
- */
- error = autofs_bgmount(cp, error);
- reschedule_timeout_mp();
- if (!error) {
- XFREE(fname);
- return new_mp;
- }
-
- /*
- * Code for quick reply. If nfs_program_2_transp is set, then
- * its the transp that's been passed down from nfs_program_2().
- * If new_mp->am_transp is not already set, set it by copying in
- * nfs_program_2_transp. Once am_transp is set, quick_reply() can
- * use it to send a reply to the client that requested this mount.
- */
- if (nfs_program_2_transp && !new_mp->am_transp) {
- new_mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT));
- *(new_mp->am_transp) = *nfs_program_2_transp;
- }
- if (error && (new_mp->am_mnt->mf_ops == &amfs_error_ops))
- new_mp->am_error = error;
-
- assign_error_mntfs(new_mp);
-
- XFREE(fname);
-
- ereturn(error);
-}
-#endif /* HAVE_FS_AUTOFS */
diff --git a/contrib/amd/amd/srvr_nfs.c b/contrib/amd/amd/srvr_nfs.c
index b5687ac..d745519 100644
--- a/contrib/amd/amd/srvr_nfs.c
+++ b/contrib/amd/amd/srvr_nfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: srvr_nfs.c,v 1.7.2.5 2001/04/14 21:08:23 ezk Exp $
+ * $Id: srvr_nfs.c,v 1.7.2.10 2002/12/29 01:55:43 ib42 Exp $
* $FreeBSD$
*
*/
@@ -412,21 +412,23 @@ nfs_timed_out(voidp v)
* Another ping has failed
*/
np->np_ping++;
+ if (np->np_ping > 1)
+ srvrlog(fs, "not responding");
/*
* Not known to be up any longer
*/
- if (FSRV_ISUP(fs)) {
+ if (FSRV_ISUP(fs))
fs->fs_flags &= ~FSF_VALID;
- if (np->np_ping > 1)
- srvrlog(fs, "not responding");
- }
/*
* If ttl has expired then guess that it is dead
*/
if (np->np_ttl < clocktime()) {
int oflags = fs->fs_flags;
+#ifdef DEBUG
+ dlog("ttl has expired");
+#endif /* DEBUG */
if ((fs->fs_flags & FSF_DOWN) == 0) {
/*
* Server was up, but is now down.
@@ -452,6 +454,10 @@ nfs_timed_out(voidp v)
}
if (oflags != fs->fs_flags && (fs->fs_flags & FSF_WANT))
wakeup_srvr(fs);
+ /*
+ * Reset failed ping count
+ */
+ np->np_ping = 0;
} else {
#ifdef DEBUG
if (np->np_ping > 1)
@@ -460,6 +466,12 @@ nfs_timed_out(voidp v)
}
/*
+ * New RPC xid, so any late responses to the previous ping
+ * get ignored...
+ */
+ np->np_xid = NPXID_ALLOC(struct );
+
+ /*
* Run keepalive again
*/
nfs_keepalive(fs);
@@ -595,21 +607,22 @@ nfs_srvr_port(fserver *fs, u_short *port, voidp wchan)
static void
start_nfs_pings(fserver *fs, int pingval)
{
- if (!(fs->fs_flags & FSF_PINGING)) {
- fs->fs_flags |= FSF_PINGING;
- if (fs->fs_cid)
- untimeout(fs->fs_cid);
- if (pingval < 0) {
- srvrlog(fs, "wired up");
- fs->fs_flags |= FSF_VALID;
- fs->fs_flags &= ~FSF_DOWN;
- } else {
- nfs_keepalive(fs);
- }
- } else {
+ if (fs->fs_flags & FSF_PINGING) {
#ifdef DEBUG
dlog("Already running pings to %s", fs->fs_host);
#endif /* DEBUG */
+ return;
+ }
+
+ if (fs->fs_cid)
+ untimeout(fs->fs_cid);
+ if (pingval < 0) {
+ srvrlog(fs, "wired up");
+ fs->fs_flags |= FSF_VALID;
+ fs->fs_flags &= ~FSF_DOWN;
+ } else {
+ fs->fs_flags |= FSF_PINGING;
+ nfs_keepalive(fs);
}
}
diff --git a/contrib/amd/amq/amq.8 b/contrib/amd/amq/amq.8
index 7d928bb..e1dc13e 100644
--- a/contrib/amd/amq/amq.8
+++ b/contrib/amd/amq/amq.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -39,6 +39,7 @@
.\" %W% (Berkeley) %G%
.\"
.\" $Id: amq.8,v 1.2 1999/01/10 21:53:58 ezk Exp $
+.\" $Id: amq.8,v 1.3.2.7 2002/12/27 22:44:45 ezk Exp $
.\" $FreeBSD$
.\"
.Dd March 16, 1991
diff --git a/contrib/amd/amq/amq.c b/contrib/amd/amq/amq.c
index e49cabc..56692b9 100644
--- a/contrib/amd/amq/amq.c
+++ b/contrib/amd/amq/amq.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: amq.c,v 1.7.2.5 2001/01/12 22:43:43 ro Exp $
+ * $Id: amq.c,v 1.7.2.8 2002/12/27 22:44:45 ezk Exp $
*
*/
@@ -51,13 +51,13 @@ __FBSDID("$FreeBSD$");
#ifndef lint
char copyright[] = "\
-@(#)Copyright (c) 1997-2001 Erez Zadok\n\
+@(#)Copyright (c) 1997-2003 Erez Zadok\n\
@(#)Copyright (c) 1990 Jan-Simon Pendry\n\
@(#)Copyright (c) 1990 Imperial College of Science, Technology & Medicine\n\
@(#)Copyright (c) 1990 The Regents of the University of California.\n\
@(#)All rights reserved.\n";
#if __GNUC__ < 2
-static char rcsid[] = "$Id: amq.c,v 1.7.2.5 2001/01/12 22:43:43 ro Exp $";
+static char rcsid[] = "$Id: amq.c,v 1.7.2.8 2002/12/27 22:44:45 ezk Exp $";
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* __GNUC__ < 2 */
#endif /* not lint */
diff --git a/contrib/amd/amq/pawd.1 b/contrib/amd/amq/pawd.1
index 6713907..e4471f3 100644
--- a/contrib/amd/amq/pawd.1
+++ b/contrib/amd/amq/pawd.1
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: pawd.1,v 1.2 1998/09/05 06:56:36 obrien Exp $
+.\" $Id: pawd.1,v 1.3.2.3 2002/12/27 22:44:46 ezk Exp $
.\" $FreeBSD$
.\"
.Dd January 6, 1998
diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h
index 252da9b..b0a66c3 100644
--- a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h
+++ b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: nfs_prot_freebsd2.h,v 1.3.2.1 2001/01/10 03:23:21 ezk Exp $
+ * $Id: nfs_prot_freebsd2.h,v 1.3.2.3 2002/12/27 22:44:54 ezk Exp $
* $FreeBSD$
*
*/
diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h
index 6ea5c45..c392497 100644
--- a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h
+++ b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: nfs_prot_freebsd3.h,v 1.5.2.1 2001/01/10 03:23:22 ezk Exp $
+ * $Id: nfs_prot_freebsd3.h,v 1.5.2.6 2003/08/27 19:35:16 ib42 Exp $
* $FreeBSD$
*
*/
@@ -71,6 +71,11 @@ struct nfs_fh3;
# include <ufs/ufs/ufsmount.h>
#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
+/* nfsclient/nfsargs.h was introduced in FreeBSD 5.0, and is needed */
+#ifdef HAVE_NFSCLIENT_NFSARGS_H
+# include <nfsclient/nfsargs.h>
+#endif /* HAVE_NFSCLIENT_NFSARGS_H */
+
/*
* MACROS:
*/
@@ -96,6 +101,7 @@ struct nfs_fh3;
#define na_nlink nlink
#define na_size size
#define na_type type
+#define na_uid uid
#define ne_cookie cookie
#define ne_fileid fileid
#define ne_name name
@@ -176,7 +182,7 @@ typedef writeargs nfswriteargs;
/*
* as of 3.0-RELEASE the nfs_fh3 that is defined in the system headers
* (or the one generated by rpcgen) lacks the proper full definition,
- * listed below. A special macro (aux/macros/struct_nfs_fh3.m4) searches
+ * listed below. A special macro (m4/macros/struct_nfs_fh3.m4) searches
* for this special name before other names.
*/
struct nfs_fh3_freebsd3 {
diff --git a/contrib/amd/doc/stamp-vti b/contrib/amd/doc/stamp-vti
deleted file mode 100644
index 3705a9f..0000000
--- a/contrib/amd/doc/stamp-vti
+++ /dev/null
@@ -1,3 +0,0 @@
-@set UPDATED 3 July 2001
-@set EDITION 6.0.7
-@set VERSION 6.0.7
diff --git a/contrib/amd/fixmount/fixmount.8 b/contrib/amd/fixmount/fixmount.8
index 0f2c9e6..7e9793a 100644
--- a/contrib/amd/fixmount/fixmount.8
+++ b/contrib/amd/fixmount/fixmount.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: fixmount.8,v 1.2 1999/01/10 21:54:26 ezk Exp $
+.\" $Id: fixmount.8,v 1.3.2.5 2003/03/16 01:46:59 ezk Exp $
.\" $FreeBSD$
.\"
.Dd February 26, 1993
diff --git a/contrib/amd/fixmount/fixmount.c b/contrib/amd/fixmount/fixmount.c
index f582724..9cfd736 100644
--- a/contrib/amd/fixmount/fixmount.c
+++ b/contrib/amd/fixmount/fixmount.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: fixmount.c,v 1.5.2.1 2001/01/10 03:23:32 ezk Exp $
+ * $Id: fixmount.c,v 1.5.2.3 2002/12/27 22:45:04 ezk Exp $
* $FreeBSD$
*
*/
diff --git a/contrib/amd/fsinfo/fsinfo.8 b/contrib/amd/fsinfo/fsinfo.8
index 004980d..cad9521 100644
--- a/contrib/amd/fsinfo/fsinfo.8
+++ b/contrib/amd/fsinfo/fsinfo.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1993 Jan-Simon Pendry.
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fsinfo.8 8.1 (Berkeley) 6/28/93
-.\" $Id: fsinfo.8,v 1.2 1999/01/10 21:54:28 ezk Exp $
+.\" $Id: fsinfo.8,v 1.3.2.4 2003/03/31 20:09:02 ezk Exp $
.\" $FreeBSD$
.\"
.Dd June 26, 1999
@@ -63,9 +63,10 @@
The
.Nm
utility takes a set of system configuration information, and generates
-a co-ordinated set of
-.Xr amd ,
-.Xr mount
+a coordinated set of
+.I amd
+,
+.I mount
and
.Xr mountd
configuration files.
diff --git a/contrib/amd/fsinfo/fsinfo.c b/contrib/amd/fsinfo/fsinfo.c
index 111d205..9f271f5 100644
--- a/contrib/amd/fsinfo/fsinfo.c
+++ b/contrib/amd/fsinfo/fsinfo.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1997-1999 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +39,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: fsinfo.c,v 1.4 1999/02/04 07:24:44 ezk Exp $
+ * $Id: fsinfo.c,v 1.5.2.5 2003/07/18 04:50:20 ezk Exp $
* $FreeBSD$
*
*/
@@ -185,9 +186,9 @@ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\
}
if (g_argv[0])
- log("g_argv[0] = %s", g_argv[0]);
+ fsi_log("g_argv[0] = %s", g_argv[0]);
else
- log("g_argv[0] = (nil)");
+ fsi_log("g_argv[0] = (nil)");
}
diff --git a/contrib/amd/hlfsd/hlfsd.8 b/contrib/amd/hlfsd/hlfsd.8
index 9eeeadf..b7a0f0b 100644
--- a/contrib/amd/hlfsd/hlfsd.8
+++ b/contrib/amd/hlfsd/hlfsd.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1989 Jan-Simon Pendry
.\" Copyright (c) 1989 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1989 The Regents of the University of California.
@@ -36,7 +36,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: hlfsd.8,v 1.2 1999/01/10 21:54:32 ezk Exp $
+.\" $Id: hlfsd.8,v 1.3.2.4 2003/03/16 01:47:00 ezk Exp $
.\" $FreeBSD$
.\"
.\" HLFSD was written at Columbia University Computer Science Department, by
@@ -232,7 +232,7 @@ Force
.Nm
to run on systems that cannot turn off the NFS attribute-cache. Use of
this option on those systems is discouraged, as it may result in loss
-or misdelivery of mail. The option is ignored on systems that can turn
+or mis-delivery of mail. The option is ignored on systems that can turn
off the attribute-cache.
.It Fl D Ar log-options
Select from a variety of debugging options. Prefixing an
diff --git a/contrib/amd/hlfsd/hlfsd.c b/contrib/amd/hlfsd/hlfsd.c
index 3601598..fdc3dae 100644
--- a/contrib/amd/hlfsd/hlfsd.c
+++ b/contrib/amd/hlfsd/hlfsd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: hlfsd.c,v 1.7.2.2 2001/01/10 03:23:35 ezk Exp $
+ * $Id: hlfsd.c,v 1.7.2.7 2002/12/27 22:45:08 ezk Exp $
* $FreeBSD$
*
* HLFSD was written at Columbia University Computer Science Department, by
@@ -264,12 +264,12 @@ main(int argc, char *argv[])
* Terminate if did not ask to forcecache (-C) and hlfsd would not be able
* to set the minimum cache intervals.
*/
-#if !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_FIELD_NFS_ARGS_T_ACREGMIN)
+#if !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN)
if (!forcecache) {
fprintf(stderr, "%s: will not be able to turn off attribute caches.\n", am_get_progname());
exit(1);
}
-#endif /* !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_FIELD_NFS_ARGS_T_ACREGMIN) */
+#endif /* !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN) */
switch (argc - optind) {
@@ -421,7 +421,7 @@ main(int argc, char *argv[])
#ifdef HAVE_SIGACTION
sa.sa_handler = proceed;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGUSR2);
sigaction(SIGUSR2, &sa, NULL);
@@ -434,7 +434,7 @@ main(int argc, char *argv[])
#ifdef HAVE_SIGACTION
sa.sa_handler = reaper;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGCHLD);
sigaction(SIGCHLD, &sa, NULL);
@@ -686,7 +686,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = reload;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGALRM);
sigaddset(&(sa.sa_mask), SIGHUP);
@@ -702,7 +702,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = cleanup;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGTERM);
sigaction(SIGTERM, &sa, NULL);
@@ -715,7 +715,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = interlock;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGCHLD);
sigaction(SIGCHLD, &sa, NULL);
@@ -732,7 +732,7 @@ hlfsd_init(void)
# else /* not defined(DEBUG) || defined(DEBUG_PRINT) */
sa.sa_handler = SIG_IGN;
# endif /* not defined(DEBUG) || defined(DEBUG_PRINT) */
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGUSR1);
sigaction(SIGUSR1, &sa, NULL);
@@ -851,16 +851,16 @@ cleanup(int signum)
amuDebug(D_DAEMON)
#endif /* DEBUG */
if (getpid() != masterpid)
- return;
+ return;
#ifdef DEBUG
amuDebug(D_DAEMON)
#endif /* DEBUG */
if (fork() != 0) {
- masterpid = 0;
- am_set_mypid();
- return;
- }
+ masterpid = 0;
+ am_set_mypid();
+ return;
+ }
am_set_mypid();
for (;;) {
@@ -935,17 +935,8 @@ fatal(char *mess)
strcpy(lessmess, mess);
lessmess[messlen - 4] = '\0';
- if (errno < sys_nerr)
- fprintf(stderr, "%s: %s: %s\n", am_get_progname(), lessmess,
-#ifdef HAVE_STRERROR
- strerror(errno)
-#else /* not HAVE_STRERROR */
- sys_errlist[errno]
-#endif /* not HAVE_STRERROR */
- );
- else
- fprintf(stderr, "%s: %s: Error %d\n",
- am_get_progname(), lessmess, errno);
+ fprintf(stderr, "%s: %s: %s\n",
+ am_get_progname(), lessmess, strerror(errno));
}
}
plog(XLOG_FATAL, "%s", mess);
diff --git a/contrib/amd/hlfsd/hlfsd.h b/contrib/amd/hlfsd/hlfsd.h
index 54e7541..3daa8fc 100644
--- a/contrib/amd/hlfsd/hlfsd.h
+++ b/contrib/amd/hlfsd/hlfsd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: hlfsd.h,v 1.4.2.2 2001/01/12 22:47:21 ro Exp $
+ * $Id: hlfsd.h,v 1.4.2.6 2002/12/27 22:45:08 ezk Exp $
* $FreeBSD$
*
* HLFSD was written at Columbia University Computer Science Department, by
@@ -53,7 +53,7 @@
* MACROS AND CONSTANTS:
*/
-#define HLFSD_VERSION "hlfsd 1.1 (1993-2001)"
+#define HLFSD_VERSION "hlfsd 1.2 (1993-2002)"
#define PERS_SPOOLMODE 0755
#define OPEN_SPOOLMODE 01777
#define DOTSTRING "."
@@ -139,7 +139,7 @@ extern SVCXPRT *nfs_program_2_transp; /* For quick_reply() */
extern SVCXPRT *nfsxprt;
extern char *alt_spooldir;
extern char *home_subdir;
-extern char *homedir(int);
+extern char *homedir(int, int);
extern char *mailbox(int, char *);
extern char *passwdfile;
extern char *slinkname;
diff --git a/contrib/amd/hlfsd/homedir.c b/contrib/amd/hlfsd/homedir.c
index 904e2c6..24d5224 100644
--- a/contrib/amd/hlfsd/homedir.c
+++ b/contrib/amd/hlfsd/homedir.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: homedir.c,v 1.5.2.1 2001/01/10 03:23:36 ezk Exp $
+ * $Id: homedir.c,v 1.5.2.10 2002/12/27 22:45:08 ezk Exp $
* $FreeBSD$
*
* HLFSD was written at Columbia University Computer Science Department, by
@@ -68,34 +68,31 @@ static uid2home_t *lastchild;
static uid2home_t *pwtab;
static void delay(uid2home_t *, int);
static void table_add(int, const char *, const char *);
+static char mboxfile[MAXPATHLEN];
+static char *root_home; /* root's home directory */
/* GLOBAL FUNCTIONS */
char *homeof(char *username);
int uidof(char *username);
/* GLOBALS VARIABLES */
-char mboxfile[MAXPATHLEN];
username2uid_t *untab; /* user name table */
-
/*
* Return the home directory pathname for the user with uid "userid".
*/
char *
-homedir(int userid)
+homedir(int userid, int groupid)
{
static char linkval[MAXPATHLEN + 1];
static struct timeval tp;
uid2home_t *found;
char *homename;
struct stat homestat;
+ int old_groupid, old_userid;
clock_valid = 0; /* invalidate logging clock */
- if ((int) userid == 0) { /* force superuser to use "/" as home */
- sprintf(linkval, "/%s", home_subdir);
- return linkval;
- }
if ((found = plt_search(userid)) == (uid2home_t *) NULL) {
return alt_spooldir; /* use alt spool for unknown uid */
}
@@ -105,7 +102,10 @@ homedir(int userid)
found->last_status = 1;
return alt_spooldir; /* use alt spool for / or rel. home */
}
- sprintf(linkval, "%s/%s", homename, home_subdir);
+ if ((int) userid == 0) /* force all uid 0 to use root's home */
+ sprintf(linkval, "%s/%s", root_home, home_subdir);
+ else
+ sprintf(linkval, "%s/%s", homename, home_subdir);
if (noverify) {
found->last_status = 0;
@@ -114,9 +114,9 @@ homedir(int userid)
/*
* To optimize hlfsd, we don't actually check the validity of the
- * symlink if it has been in checked in the last N seconds. It is
+ * symlink if it has been checked in the last N seconds. It is
* very likely that the link, machine, and filesystem are still
- * valid, as long as N is small. But if N ls large, that may not be
+ * valid, as long as N is small. But if N is large, that may not be
* true. That's why the default N is 5 minutes, but we allow the
* user to override this value via a command line option. Note that
* we do not update the last_access_time each time it is accessed,
@@ -144,13 +144,33 @@ homedir(int userid)
amuDebug(D_FORK) {
#endif /* DEBUG */
/* fork child to process request if none in progress */
- if (found->child && kill(found->child, 0))
+ if (found->child && kill(found->child, 0) < 0)
found->child = 0;
if (found->child)
delay(found, 5); /* wait a bit if in progress */
- if (found->child) { /* better safe than sorry - maybe */
- found->last_status = 1;
+
+#if defined(DEBUG) && defined(HAVE_WAITPID)
+ if (found->child) {
+ /* perhaps it's a child we lost count of? let's wait on it */
+ int status, child;
+ if ((child = waitpid((pid_t) found->child, &status, WNOHANG)) > 0) {
+ plog(XLOG_ERROR, "found lost child %d", child);
+ found->child = 0;
+ if (WIFEXITED(status))
+ found->last_status = WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ found->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ found->last_status = 255;
+ }
+ }
+ }
+#endif /* DEBUG && HAVE_WAITPID */
+
+ if (found->child) {
+ found->last_status = 1; /* better safe than sorry - maybe */
return alt_spooldir;
}
if ((found->child = fork()) < 0) {
@@ -184,21 +204,28 @@ homedir(int userid)
*
*/
am_set_mypid(); /* for logging routines */
- if (seteuid(userid) < 0) {
+ if ((old_groupid = setgid(groupid)) < 0) {
+ plog(XLOG_WARNING, "could not setgid to %d: %m", groupid);
+ return linkval;
+ }
+ if ((old_userid = seteuid(userid)) < 0) {
plog(XLOG_WARNING, "could not seteuid to %d: %m", userid);
+ setgid(old_groupid);
return linkval;
}
if (hlfsd_stat(linkval, &homestat) < 0) {
if (errno == ENOENT) { /* make the spool dir if possible */
/* don't use recursive mkdirs here */
if (mkdir(linkval, PERS_SPOOLMODE) < 0) {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "can't make directory %s: %m", linkval);
return alt_spooldir;
}
/* fall through to testing the disk space / quota */
} else { /* the home dir itself must not exist then */
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "bad link to %s: %m", linkval);
return alt_spooldir;
}
@@ -213,11 +240,13 @@ homedir(int userid)
* We are still seteuid to the user at this point.
*/
if (hlfsd_diskspace(linkval) < 0) {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "no more space in %s: %m", linkval);
return alt_spooldir;
} else {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
return linkval;
}
}
@@ -295,30 +324,55 @@ interlock(int signum)
int child;
uid2home_t *lostchild;
int status;
+ int max_errors = 10; /* avoid infinite loops */
#ifdef HAVE_WAITPID
- while ((child = waitpid((pid_t) -1, &status, WNOHANG)) > 0) {
+ while ((child = waitpid((pid_t) -1, &status, WNOHANG)) != 0) {
#else /* not HAVE_WAITPID */
- while ((child = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) {
+ while ((child = wait3(&status, WNOHANG, (struct rusage *) 0)) != 0) {
#endif /* not HAVE_WAITPID */
+ if (child < 0) {
+ plog(XLOG_WARNING, "waitpid/wait3: %m");
+ if (--max_errors > 0)
+ continue;
+ else
+ break;
+ }
+
/* high chances this was the last child forked */
if (lastchild && lastchild->child == child) {
lastchild->child = 0;
if (WIFEXITED(status))
lastchild->last_status = WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ lastchild->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ lastchild->last_status = 255;
+ }
lastchild = (uid2home_t *) NULL;
} else {
/* and if not, we have to search for it... */
+ int found = 0;
for (lostchild = pwtab; lostchild < &pwtab[cur_pwtab_num]; lostchild++) {
if (lostchild->child == child) {
+ lostchild->child = 0;
if (WIFEXITED(status))
lostchild->last_status = WEXITSTATUS(status);
- lostchild->child = 0;
+ else if (WIFSIGNALED(status))
+ lostchild->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ lostchild->last_status = 255;
+ }
+ found = 1;
break;
}
}
+ if (!found)
+ plog(XLOG_ERROR, "no record of child %d found???", child);
}
}
}
@@ -411,7 +465,6 @@ mailbox(int uid, char *username)
static int
plt_compare_fxn(const voidp x, const voidp y)
-
{
uid2home_t *i = (uid2home_t *) x;
uid2home_t *j = (uid2home_t *) y;
@@ -560,6 +613,18 @@ plt_init(void)
hlfsd_setpwent(); /* prepare to read passwd entries */
while ((pent_p = hlfsd_getpwent()) != (struct passwd *) NULL) {
table_add(pent_p->pw_uid, pent_p->pw_dir, pent_p->pw_name);
+ if (STREQ("root", pent_p->pw_name)) {
+ int len;
+ if (root_home)
+ XFREE(root_home);
+ root_home = strdup(pent_p->pw_dir);
+ len = strlen(root_home);
+ /* remove any trailing '/' chars from root's home (even if just one) */
+ while (len > 0 && root_home[len - 1] == '/') {
+ len--;
+ root_home[len] = '\0';
+ }
+ }
}
hlfsd_endpwent();
@@ -568,6 +633,9 @@ plt_init(void)
qsort((char *) untab, cur_pwtab_num, sizeof(username2uid_t),
unt_compare_fxn);
+ if (!root_home)
+ root_home = strdup("");
+
plog(XLOG_INFO, "password map read and sorted");
}
@@ -610,6 +678,9 @@ plt_reset(void)
}
cur_pwtab_num = 0; /* zero current size */
+ if (root_home)
+ XFREE(root_home);
+
return 0; /* resetting ok */
}
@@ -735,7 +806,7 @@ plt_print(int signum)
#else /* not HAVE_MKSTEMP */
mktemp(dumptmp);
if (!dumptmp) {
- plot(XLOG_ERROR, "cannot create temporary dump file");
+ plog(XLOG_ERROR, "cannot create temporary dump file");
return;
}
dumpfd = open(dumptmp, O_RDONLY);
diff --git a/contrib/amd/include/am_defs.h b/contrib/amd/include/am_defs.h
index c42afe0..5e0271d 100644
--- a/contrib/amd/include/am_defs.h
+++ b/contrib/amd/include/am_defs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: am_defs.h,v 1.15.2.9 2001/04/07 00:47:44 ib42 Exp $
+ * $Id: am_defs.h,v 1.15.2.13 2002/12/27 22:45:09 ezk Exp $
* $FreeBSD$
*
*/
@@ -596,24 +596,6 @@ struct ypall_callback;
#endif /* HAVE_LINUX_AUTO_FS_H */
/*
- * Actions to take if <sys/fs/autofs.h> exists.
- */
-#ifdef HAVE_SYS_FS_AUTOFS_H
-# include <sys/fs/autofs.h>
-#endif /* HAVE_SYS_FS_AUTOFS_H */
-
-/*
- * Actions to take if <sys/fs/autofs_prot.h> exists.
- * We really don't want <linux/fs.h> pulled in here
- */
-#ifndef _LINUX_FS_H
-#define _LINUX_FS_H
-#endif /* _LINUX_FS_H */
-#ifdef HAVE_SYS_FS_AUTOFS_PROT_H
-# include <sys/fs/autofs_prot.h>
-#endif /* HAVE_SYS_FS_AUTOFS_PROT_H */
-
-/*
* NFS PROTOCOL HEADER FILES:
*/
@@ -1413,6 +1395,10 @@ extern int wait3(int *statusp, int options, struct rusage *rusage);
extern int vsnprintf(char *, int, const char *, ...);
#endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */
+#ifndef HAVE_EXTERN_XDR_CALLMSG
+extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg);
+#endif /* not HAVE_EXTERN_XDR_CALLMSG */
+
#ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH
extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth);
#endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */
diff --git a/contrib/amd/libamu/mount_fs.c b/contrib/amd/libamu/mount_fs.c
index c4a4738..53198f2 100644
--- a/contrib/amd/libamu/mount_fs.c
+++ b/contrib/amd/libamu/mount_fs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: mount_fs.c,v 1.11.2.5 2001/04/14 21:08:25 ezk Exp $
+ * $Id: mount_fs.c,v 1.11.2.11 2003/05/08 17:57:53 ib42 Exp $
* $FreeBSD$
*
*/
@@ -106,13 +106,10 @@ struct opt_tab mnt_flags[] =
{MNTTAB_OPT_OVERLAY, MNT2_GEN_OPT_OVERLAY},
#endif /* defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY) */
-#if defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST)
- {MNTTAB_OPT_PROPLIST, MNT2_NFS_OPT_PROPLIST},
-#endif /* defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) */
-
-#if defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK)
- {MNTTAB_OPT_NOLOCK, MNT2_NFS_OPT_NONLM},
-#endif /* defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) */
+ /*
+ * Do not define MNT2_NFS_OPT_* entries here! This is for generic
+ * mount(2) options only, not for NFS mount options.
+ */
{0, 0}
};
@@ -123,27 +120,14 @@ int
compute_mount_flags(mntent_t *mntp)
{
struct opt_tab *opt;
- int flags;
+ int flags = 0;
- /* start: this must come first */
#ifdef MNT2_GEN_OPT_NEWTYPE
flags = MNT2_GEN_OPT_NEWTYPE;
-#else /* not MNT2_GEN_OPT_NEWTYPE */
- /* Not all machines have MNT2_GEN_OPT_NEWTYPE (HP-UX 9.01) */
- flags = 0;
-#endif /* not MNT2_GEN_OPT_NEWTYPE */
-
-#if defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY)
- /*
- * Overlay this amd mount (presumably on another amd which died
- * before and left the machine hung). This will allow a new amd or
- * hlfsd to be remounted on top of another one.
- */
- if (hasmntopt(mntp, MNTTAB_OPT_OVERLAY)) {
- flags |= MNT2_GEN_OPT_OVERLAY;
- plog(XLOG_INFO, "using an overlay mount");
- }
-#endif /* defined(MNT2_GEN_OVERLAY) && defined(MNTOPT_OVERLAY) */
+#endif /* MNT2_GEN_OPT_NEWTYPE */
+#ifdef MNT2_GEN_OPT_AUTOMOUNTED
+ flags |= MNT2_GEN_OPT_AUTOMOUNTED;
+#endif /* not MNT2_GEN_OPT_AUTOMOUNTED */
/*
* Crack basic mount options
@@ -301,25 +285,25 @@ again:
* Additional fields in mntent_t
* are fixed up here
*/
-# ifdef HAVE_FIELD_MNTENT_T_MNT_CNODE
+# ifdef HAVE_MNTENT_T_MNT_CNODE
mnt->mnt_cnode = 0;
-# endif /* HAVE_FIELD_MNTENT_T_MNT_CNODE */
+# endif /* HAVE_MNTENT_T_MNT_CNODE */
-# ifdef HAVE_FIELD_MNTENT_T_MNT_RO
+# ifdef HAVE_MNTENT_T_MNT_RO
mnt->mnt_ro = (hasmntopt(mnt, MNTTAB_OPT_RO) != NULL);
-# endif /* HAVE_FIELD_MNTENT_T_MNT_RO */
+# endif /* HAVE_MNTENT_T_MNT_RO */
-# ifdef HAVE_FIELD_MNTENT_T_MNT_TIME
-# ifdef HAVE_FIELD_MNTENT_T_MNT_TIME_STRING
+# ifdef HAVE_MNTENT_T_MNT_TIME
+# ifdef HAVE_MNTENT_T_MNT_TIME_STRING
{ /* allocate enough space for a long */
char *str = (char *) xmalloc(13 * sizeof(char));
sprintf(str, "%ld", time((time_t *) NULL));
mnt->mnt_time = str;
}
-# else /* not HAVE_FIELD_MNTENT_T_MNT_TIME_STRING */
+# else /* not HAVE_MNTENT_T_MNT_TIME_STRING */
mnt->mnt_time = time((time_t *) NULL);
-# endif /* not HAVE_FIELD_MNTENT_T_MNT_TIME_STRING */
-# endif /* HAVE_FIELD_MNTENT_T_MNT_TIME */
+# endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */
+# endif /* HAVE_MNTENT_T_MNT_TIME */
write_mntent(mnt, mnttabname);
@@ -375,7 +359,7 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
fhp->v3.mountres3_u.mountinfo.fhandle.fhandle3_val,
fh3.fh3_length);
-# if defined(HAVE_FIELD_NFS_ARGS_T_FHSIZE) || defined(HAVE_FIELD_NFS_ARGS_T_FH_LEN)
+# if defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN)
/*
* Some systems (Irix/bsdi3) have a separate field in nfs_args for
* the length of the file handle for NFS V3. They insist that
@@ -383,9 +367,9 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
* include the length field.
*/
NFS_FH_DREF(nap->NFS_FH_FIELD, &(fh3.fh3_u.data));
-# else /* not defined(HAVE_FIELD_NFS_ARGS_T_FHSIZE) || defined(HAVE_FIELD_NFS_ARGS_T_FH_LEN) */
+# else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */
NFS_FH_DREF(nap->NFS_FH_FIELD, &fh3);
-# endif /* not defined(HAVE_FIELD_NFS_ARGS_T_FHSIZE) || defined(HAVE_FIELD_NFS_ARGS_T_FH_LEN) */
+# endif /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */
# ifdef MNT2_NFS_OPT_NFSV3
nap->flags |= MNT2_NFS_OPT_NFSV3;
# endif /* MNT2_NFS_OPT_NFSV3 */
@@ -396,24 +380,24 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
#endif /* HAVE_FS_NFS3 */
NFS_FH_DREF(nap->NFS_FH_FIELD, &(fhp->v2.fhs_fh));
-#ifdef HAVE_FIELD_NFS_ARGS_T_FHSIZE
+#ifdef HAVE_NFS_ARGS_T_FHSIZE
# ifdef HAVE_FS_NFS3
if (nfs_version == NFS_VERSION3)
nap->fhsize = fh3.fh3_length;
else
# endif /* HAVE_FS_NFS3 */
nap->fhsize = FHSIZE;
-#endif /* HAVE_FIELD_NFS_ARGS_T_FHSIZE */
+#endif /* HAVE_NFS_ARGS_T_FHSIZE */
/* this is the version of the nfs_args structure, not of NFS! */
-#ifdef HAVE_FIELD_NFS_ARGS_T_FH_LEN
+#ifdef HAVE_NFS_ARGS_T_FH_LEN
# ifdef HAVE_FS_NFS3
if (nfs_version == NFS_VERSION3)
nap->fh_len = fh3.fh3_length;
else
# endif /* HAVE_FS_NFS3 */
nap->fh_len = FHSIZE;
-#endif /* HAVE_FIELD_NFS_ARGS_T_FH_LEN */
+#endif /* HAVE_NFS_ARGS_T_FH_LEN */
/************************************************************************/
/*** HOST NAME ***/
@@ -441,14 +425,14 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
#endif /* MNTTAB_OPT_ACTIMEO */
if (acval) {
-#ifdef HAVE_FIELD_NFS_ARGS_T_ACREGMIN
+#ifdef HAVE_NFS_ARGS_T_ACREGMIN
nap->acregmin = acval; /* min ac timeout for reg files (sec) */
nap->acregmax = acval; /* max ac timeout for reg files (sec) */
-#endif /* HAVE_FIELD_NFS_ARGS_T_ACREGMIN */
-#ifdef HAVE_FIELD_NFS_ARGS_T_ACDIRMIN
+#endif /* HAVE_NFS_ARGS_T_ACREGMIN */
+#ifdef HAVE_NFS_ARGS_T_ACDIRMIN
nap->acdirmin = acval; /* min ac timeout for dirs (sec) */
nap->acdirmax = acval; /* max ac timeout for dirs (sec) */
-#endif /* HAVE_FIELD_NFS_ARGS_T_ACDIRMIN */
+#endif /* HAVE_NFS_ARGS_T_ACDIRMIN */
} else {
#ifdef MNTTAB_OPT_ACREGMIN
nap->acregmin = hasmntval(mntp, MNTTAB_OPT_ACREGMIN);
@@ -504,7 +488,7 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
nap->flags |= MNT2_NFS_OPT_TCP;
#endif /* MNT2_NFS_OPT_TCP */
-#ifdef HAVE_FIELD_NFS_ARGS_T_SOTYPE
+#ifdef HAVE_NFS_ARGS_T_SOTYPE
/* bsdi3 uses this */
if (nfs_proto) {
if (STREQ(nfs_proto, "tcp"))
@@ -512,9 +496,9 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
else if (STREQ(nfs_proto, "udp"))
nap->sotype = SOCK_DGRAM;
}
-#endif /* HAVE_FIELD_NFS_ARGS_T_SOTYPE */
+#endif /* HAVE_NFS_ARGS_T_SOTYPE */
-#ifdef HAVE_FIELD_NFS_ARGS_T_PROTO
+#ifdef HAVE_NFS_ARGS_T_PROTO
nap->proto = 0; /* bsdi3 sets this field to zero */
# ifdef IPPROTO_TCP
if (nfs_proto) {
@@ -524,16 +508,16 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
nap->proto = IPPROTO_UDP;
}
# endif /* IPPROTO_TCP */
-#endif /* HAVE_FIELD_NFS_ARGS_T_SOTYPE */
+#endif /* HAVE_NFS_ARGS_T_SOTYPE */
-#ifdef HAVE_FIELD_NFS_ARGS_T_VERSION
+#ifdef HAVE_NFS_ARGS_T_VERSION
# ifdef NFS_ARGSVERSION
nap->version = NFS_ARGSVERSION; /* BSDI 3.0 and OpenBSD 2.2 */
# endif /* NFS_ARGSVERSION */
# ifdef DG_MOUNT_NFS_VERSION
nap->version = DG_MOUNT_NFS_VERSION; /* dg-ux */
# endif /* DG_MOUNT_NFS_VERSION */
-#endif /* HAVE_FIELD_NFS_ARGS_VERSION */
+#endif /* HAVE_NFS_ARGS_VERSION */
/************************************************************************/
/*** OTHER NFS SOCKET RELATED OPTIONS AND FLAGS ***/
@@ -715,18 +699,23 @@ compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_
nap->flags |= MNT2_NFS_OPT_MAXGRPS;
#endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */
-#ifdef HAVE_FIELD_NFS_ARGS_T_OPTSTR
+#if defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK)
+ if (hasmntopt(mntp, MNTTAB_OPT_NOLOCK) != NULL)
+ nap->flags |= MNT2_NFS_OPT_NONLM;
+#endif /* defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) */
+
+#ifdef HAVE_NFS_ARGS_T_OPTSTR
nap->optstr = mntp->mnt_opts;
-#endif /* HAVE_FIELD_NFS_ARGS_T_OPTSTR */
+#endif /* HAVE_NFS_ARGS_T_OPTSTR */
/************************************************************************/
/*** FINAL ACTIONS ***/
/************************************************************************/
-#ifdef HAVE_FIELD_NFS_ARGS_T_GFS_FLAGS
+#ifdef HAVE_NFS_ARGS_T_GFS_FLAGS
/* Ultrix stores generic flags in nfs_args.gfs_flags. */
nap->gfs_flags = genflags;
-#endif /* HAVE_FIELD_NFS_ARGS_T_FLAGS */
+#endif /* HAVE_NFS_ARGS_T_FLAGS */
return; /* end of compute_nfs_args() function */
}
@@ -864,19 +853,19 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version)
nbp = nap->syncaddr;
plog(XLOG_DEBUG, "NA->syncaddr {netbuf} 0x%x", (int) nbp);
kncp = nap->knconf;
- plog(XLOG_DEBUG, "NA->knconf->semantics %lu", (unsigned long) kncp->knc_semantics);
+ plog(XLOG_DEBUG, "NA->knconf->semantics %lu", (u_long) kncp->knc_semantics);
plog(XLOG_DEBUG, "NA->knconf->protofmly \"%s\"", kncp->knc_protofmly);
plog(XLOG_DEBUG, "NA->knconf->proto \"%s\"", kncp->knc_proto);
- plog(XLOG_DEBUG, "NA->knconf->rdev %lu", kncp->knc_rdev);
+ plog(XLOG_DEBUG, "NA->knconf->rdev %lu", (u_long) kncp->knc_rdev);
/* don't print knconf->unused field */
#else /* not HAVE_TRANSPORT_TYPE_TLI */
sap = (struct sockaddr_in *) &nap->addr;
plog(XLOG_DEBUG, "NA->addr {sockaddr_in} (len=%d) = \"%s\"",
(int) sizeof(struct sockaddr_in),
get_hex_string(sizeof(struct sockaddr_in), (const char *)sap));
-#ifdef HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
plog(XLOG_DEBUG, "NA->addr.sin_len = \"%d\"", sap->sin_len);
-#endif /* HAVE_FIELD_STRUCT_SOCKADDR_SA_LEN */
+#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
plog(XLOG_DEBUG, "NA->addr.sin_family = \"%d\"", sap->sin_family);
plog(XLOG_DEBUG, "NA->addr.sin_port = \"%d\"", sap->sin_port);
plog(XLOG_DEBUG, "NA->addr.sin_addr = \"%s\"",
@@ -884,22 +873,22 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version)
#endif /* not HAVE_TRANSPORT_TYPE_TLI */
plog(XLOG_DEBUG, "NA->hostname = \"%s\"", nap->hostname ? nap->hostname : "null");
-#ifdef HAVE_FIELD_NFS_ARGS_T_NAMLEN
+#ifdef HAVE_NFS_ARGS_T_NAMLEN
plog(XLOG_DEBUG, "NA->namlen = %d", nap->namlen);
-#endif /* HAVE_FIELD_NFS_ARGS_T_NAMLEN */
+#endif /* HAVE_NFS_ARGS_T_NAMLEN */
#ifdef MNT2_NFS_OPT_FSNAME
plog(XLOG_DEBUG, "NA->fsname = \"%s\"", nap->fsname ? nap->fsname : "null");
#endif /* MNT2_NFS_OPT_FSNAME */
-#ifdef HAVE_FIELD_NFS_ARGS_T_FHSIZE
+#ifdef HAVE_NFS_ARGS_T_FHSIZE
plog(XLOG_DEBUG, "NA->fhsize = %d", nap->fhsize);
fhlen = nap->fhsize;
-#endif /* HAVE_FIELD_NFS_ARGS_T_FHSIZE */
-#ifdef HAVE_FIELD_NFS_ARGS_T_FH_LEN
+#endif /* HAVE_NFS_ARGS_T_FHSIZE */
+#ifdef HAVE_NFS_ARGS_T_FH_LEN
plog(XLOG_DEBUG, "NA->fh_len = %d", nap->fh_len);
fhlen = nap->fh_len;
-#endif /* HAVE_FIELD_NFS_ARGS_T_FH_LEN */
+#endif /* HAVE_NFS_ARGS_T_FH_LEN */
/*
* XXX: need to figure out how to correctly print file handles,
@@ -910,32 +899,32 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version)
plog(XLOG_DEBUG, "NA->filehandle = \"%s\"",
get_hex_string(fhlen, (const char *) &nap->NFS_FH_FIELD));
-#ifdef HAVE_FIELD_NFS_ARGS_T_SOTYPE
+#ifdef HAVE_NFS_ARGS_T_SOTYPE
plog(XLOG_DEBUG, "NA->sotype = %d", nap->sotype);
-#endif /* HAVE_FIELD_NFS_ARGS_T_SOTYPE */
-#ifdef HAVE_FIELD_NFS_ARGS_T_PROTO
+#endif /* HAVE_NFS_ARGS_T_SOTYPE */
+#ifdef HAVE_NFS_ARGS_T_PROTO
plog(XLOG_DEBUG, "NA->proto = %d", (int) nap->proto);
-#endif /* HAVE_FIELD_NFS_ARGS_T_PROTO */
-#ifdef HAVE_FIELD_NFS_ARGS_T_VERSION
+#endif /* HAVE_NFS_ARGS_T_PROTO */
+#ifdef HAVE_NFS_ARGS_T_VERSION
plog(XLOG_DEBUG, "NA->version = %d", nap->version);
-#endif /* HAVE_FIELD_NFS_ARGS_T_VERSION */
+#endif /* HAVE_NFS_ARGS_T_VERSION */
plog(XLOG_DEBUG, "NA->flags = 0x%x", (int) nap->flags);
plog(XLOG_DEBUG, "NA->rsize = %d", (int) nap->rsize);
plog(XLOG_DEBUG, "NA->wsize = %d", (int) nap->wsize);
-#ifdef HAVE_FIELD_NFS_ARGS_T_BSIZE
+#ifdef HAVE_NFS_ARGS_T_BSIZE
plog(XLOG_DEBUG, "NA->bsize = %d", nap->bsize);
-#endif /* HAVE_FIELD_NFS_ARGS_T_BSIZE */
+#endif /* HAVE_NFS_ARGS_T_BSIZE */
plog(XLOG_DEBUG, "NA->timeo = %d", (int) nap->timeo);
plog(XLOG_DEBUG, "NA->retrans = %d", (int) nap->retrans);
-#ifdef HAVE_FIELD_NFS_ARGS_T_ACREGMIN
+#ifdef HAVE_NFS_ARGS_T_ACREGMIN
plog(XLOG_DEBUG, "NA->acregmin = %d", (int) nap->acregmin);
plog(XLOG_DEBUG, "NA->acregmax = %d", (int) nap->acregmax);
plog(XLOG_DEBUG, "NA->acdirmin = %d", (int) nap->acdirmin);
plog(XLOG_DEBUG, "NA->acdirmax = %d", (int) nap->acdirmax);
-#endif /* HAVE_FIELD_NFS_ARGS_T_ACREGMIN */
+#endif /* HAVE_NFS_ARGS_T_ACREGMIN */
#ifdef MNTTAB_OPT_SYMTTL
plog(XLOG_DEBUG, "NA->symttl = %d", nap->symttl);
#endif /* MNTTAB_OPT_SYMTTL */
diff --git a/contrib/amd/mk-amd-map/mk-amd-map.8 b/contrib/amd/mk-amd-map/mk-amd-map.8
index f6f31f5..9982e40 100644
--- a/contrib/amd/mk-amd-map/mk-amd-map.8
+++ b/contrib/amd/mk-amd-map/mk-amd-map.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1993 Jan-Simon Pendry
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)mk-amd-map.8 8.1 (Berkeley) 6/28/93
-.\" $Id: mk-amd-map.8,v 1.2 1999/01/10 21:54:41 ezk Exp $
+.\" $Id: mk-amd-map.8,v 1.3.2.3 2002/12/27 22:45:15 ezk Exp $
.\" $FreeBSD$
.\"
.Dd June 28, 1993
diff --git a/contrib/amd/mk-amd-map/mk-amd-map.c b/contrib/amd/mk-amd-map/mk-amd-map.c
index c059f70..83c34b4 100644
--- a/contrib/amd/mk-amd-map/mk-amd-map.c
+++ b/contrib/amd/mk-amd-map/mk-amd-map.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: mk-amd-map.c,v 1.5.2.1 2001/01/10 03:23:42 ezk Exp $
+ * $Id: mk-amd-map.c,v 1.5.2.5 2003/06/09 16:57:46 ezk Exp $
* $FreeBSD$
*/
@@ -287,7 +287,22 @@ main(int argc, char *argv[])
exit(1);
}
+#ifdef HAVE_MKSTEMP
+ {
+ /*
+ * XXX: hack to avoid compiler complaints about mktemp not being
+ * secure, since we have to do a dbm_open on this anyway. So use
+ * mkstemp if you can, and then close the fd, but we get a safe
+ * and unique file name.
+ */
+ int dummyfd;
+ dummyfd = mkstemp(maptmp);
+ if (dummyfd >= 0)
+ close(dummyfd);
+ }
+#else /* not HAVE_MKSTEMP */
mktemp(maptmp);
+#endif /* not HAVE_MKSTEMP */
/* remove existing temps (if any) */
#ifdef HAVE_DB_SUFFIX
@@ -307,7 +322,7 @@ main(int argc, char *argv[])
}
#endif /* not HAVE_DB_SUFFIX */
- db = dbm_open(maptmp, O_RDWR|O_CREAT, 0444);
+ db = dbm_open(maptmp, O_RDWR|O_CREAT|O_EXCL, 0444);
if (!db) {
fprintf(stderr, "cannot initialize temporary database: %s", maptmp);
exit(1);
diff --git a/contrib/amd/scripts/amd.conf.5 b/contrib/amd/scripts/amd.conf.5
index 8e29faa..93edefc 100644
--- a/contrib/amd/scripts/amd.conf.5
+++ b/contrib/amd/scripts/amd.conf.5
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: amd.conf.5,v 1.3 1999/03/30 17:23:08 ezk Exp $
+.\" $Id: amd.conf.5,v 1.7.2.8 2003/03/16 01:47:00 ezk Exp $
.\" $FreeBSD$
.\"
.Dd April 7, 1997
@@ -121,86 +121,56 @@ then amd's top-level mount points will be browsable to
calls. This means you could run for example
.Xr ls 1
and see what keys are available to mount in that directory. Not all entries
-are made visible to
-.Xr readdir 3 :
-the
-.Qq Pa /default
-entry, wildcardentries, and those with a
-.Qq Pa /
-in them are not included. If you specify
-.Qq full
-to this option, all but
-.Qq Pa /default
-will be visible. Note that if you run a command which will attempt to
-.Xr stat 2
-the entries, such as often done by
-.Qq ls -l
-or
-.Qq ls -F ,
-.Nm amd
-will attempt to mount
-.Em every
-entry in that map. This is often called a
-.Em mount storm .
-.It Ic map_options Xo
-(string, default no options)
-.Xc
-This option is the same as specifying map options on the command line to
-.Nm amd ,
-such as
-.Ql cache\&:\&=all .
-.It Ic map_type Xo
-(string, default search all map types)
-.Xc
-If specified, amd will initialize the map only for the type given.
-This is useful to avoid the default map search type used by amd which
-takes longer and can have undesired side-effects such as initializing
-NIS even if not used. Possible values are:
-.Pp
-.Bl -tag -width "nisplus" -compact
-.It Ic file
-plain files
-.It Ic hesiod
-Hesiod name service from MIT
-.It Ic ldap
-Lightweight Directory Access Protocol
-.It Ic ndbm
-(New) dbm style hash files
-.It Ic nis
-Network Information Services (version 2)
-.It Ic nisplus
-Network Information Services Plus (version 3)
-.It Ic passwd
-local password files
-.It Ic union
-union maps
-.El
-.It Ic mount_type Xo
-(string, default=nfs)
-.Xc
-All amd mount types default to
-.Tn NFS .
-That is,
-.Nm amd
-is an
-.Tn NFS
-server on the map mount points, for the local host it is running on. If
-.Qq autofs
-is specified, amd will be an autofs server for those mount points.
-.It Ic search_path Xo
-(string, default no search path)
-.Xc
-This provides a
-(colon-delimited)
-search path for file maps. Using a search path, sites can allow for
-local map customizations and overrides, and can distributed maps in
-several locations as needed.
-.El
-.Ss "Parameters applicable to the global section only"
-.Bl -tag -width 4n
-.It Ic arch Xo
-(string, default to compiled in value)
-.Xc
+are made visible to readdir(3): the "/default" entry, wildcard
+entries, and those with a "/" in them are not included. If you specify
+"full" to this option, all but "/default" will be visible.
+Note that if you run a command which will attempt to
+.BR stat (2)
+the entries, such as often done by "ls -l" or "ls -F", amd will attempt to
+mount
+.I every
+entry in that map. This is often called a ``mount storm''.
+
+.TP
+.BR map_options " (string, default no options)"
+This option is the same as specifying map options on the command line to
+amd, such as "cache:=all".
+
+.TP
+.BR map_type " (string, default search all map types)"
+If specified, amd will initialize the map only for the type given. This is
+useful to avoid the default map search type used by amd which takes longer
+and can have undesired side-effects such as initializing NIS even if not
+used. Possible values are
+
+.nf
+\fBfile\fR plain files
+\fBhesiod\fR Hesiod name service from MIT
+\fBldap\fR Lightweight Directory Access Protocol
+\fBndbm\fR (New) dbm style hash files
+\fBnis\fR Network Information Services (version 2)
+\fBnisplus\fR Network Information Services Plus (version 3)
+\fBpasswd\fR local password files
+\fBunion\fR union maps
+.fi
+
+.TP
+.BR mount_type " (string, default=nfs)"
+All amd mount types must be NFS. That is, amd is an NFS server on the
+map mount points, for the local host it is running on. If "autofs" is
+specified, amd will log an error and convert it to NFS.
+
+.TP
+.BR search_path " (string, default no search path)"
+This provides a (colon-delimited) search path for file maps. Using a search
+path, sites can allow for local map customizations and overrides, and can
+distributed maps in several locations as needed.
+
+.\" **************************************************************************
+.SS Parameters applicable to the global section only
+
+.TP
+.BR arch " (string, default to compiled in value)"
Allows you to override the value of the
.Va arch
.Nm amd
@@ -450,49 +420,95 @@ Specifies the retransmit counter's value in tenths of seconds.
(numeric, default=8)
.Xc
Same as the
-.Ic interval
-part of the
-.Fl t Ar interval.counter
-option to
-.Nm amd .
-Specifies the interval in tenths of seconds, between NFS/RPC/UDP retries.
-.It Ic nis_domain Xo
-(string, default to local NIS domain name)
-.Xc
+.B \-x
+option to amd. Specify any logging options for amd. Options are comma
+delimited, and can be preceded by the string "no" to negate their meaning.
+The "debug" logging option is only available if am-utils was configured with
+--enable-debug. You can get the list of supported debugging and logging
+options by running amd \-H. Possible values are:
+
+.nf
+\fBall\fR all messages
+\fBdebug\fR debug messages
+\fBerror\fR non-fatal system errors
+\fBfatal\fR fatal errors
+\fBinfo\fR information
+\fBmap\fR map errors
+\fBstats\fR additional statistical information
+\fBuser\fR non-fatal user errors
+\fBwarn\fR warnings
+\fBwarning\fR warnings
+.fi
+
+.TP
+.BR nfs_vers " (numeric, default to trying version 3 then 2)"
+By default, amd tries version 3 and then version 2. This option forces the
+overall NFS protocol used to version 3 or 2. It overrides what is in the
+amd maps, and is useful when amd is compiled with NFSv3 support that may not
+be stable. With this option you can turn off the complete usage of NFSv3
+dynamically (without having to recompile amd) until such time as NFSv3
+support is desired again.
+
+.TP
+.BR nfs_retransmit_counter " (numeric, default=11)"
Same as the
-.Fl y
-option to
-.Nm amd .
-Specify an alternative
-.Tn NIS
-domain from which to fetch the
-.Tn NIS
-maps. The default is the system domain name. This option is ignored if
-.Tn NIS
-support is not available.
-.It Ic normalize_hostnames Xo
-(boolean, default=no)
-.Xc
+.I retransmit
+part of the
+.BI \-t " timeout.retransmit"
+option to amd.
+Specifies the number of NFS retransmissions that the kernel will use to
+communicate with amd.
+
+.TP
+.BR nfs_retry_interval " (numeric, default=8)"
Same as the
-.Fl n
-option to
-.Nm amd .
-If
-.Dq yes ,
-then the name refereed to by
-.Va ${rhost}
-is normalized relative to the host database before being used. The effect is
-to translate aliases into
-.Qq official
-names.
-.It Ic os Xo
-(string, default to compiled in value)
-.Xc
+.I timeout
+part of the
+.BI \-t " timeout.retransmit"
+option to amd. Specifies the NFS timeout interval, in
+.I tenths
+of seconds, between NFS/RPC retries (for UDP only).
+This is the value that the kernel will use to
+communicate with amd.
+
+Amd relies on the kernel RPC retransmit mechanism to trigger mount retries.
+The values of the
+.B nfs_retransmit_counter
+and the
+.B nfs_retry_interval
+parameters change the overall retry interval. Too long an interval gives
+poor interactive response; too short an interval causes excessive retries.
+
+.TP
+.BR nfs_proto " (string, default to trying version tcp then udp)"
+By default, amd tries TCP and then UDP. This option forces the overall NFS
+protocol used to TCP or UDP. It overrides what is in the amd maps, and is
+useful when amd is compiled with NFSv3 support that may not be stable. With
+this option you can turn off the complete usage of NFSv3 dynamically
+(without having to recompile amd) until such time as NFSv3 support is
+desired again.
+
+.TP
+.BR nis_domain " (string, default to local NIS domain name)"
Same as the
-.Fl O
-option to
-.Nm amd .
-Allows you to override the compiled-in name of the operating
+.B \-y
+option to amd. Specify an alternative NIS domain from which to fetch the
+NIS maps. The default is the system domain name. This option is ignored if
+NIS support is not available.
+
+.TP
+.BR normalize_hostnames " (boolean, default=no)"
+Same as the
+.B \-n
+option to amd. If "yes", then the name refereed to by ${rhost} is
+normalized relative to the host database before being used. The effect is
+to translate aliases into ``official'' names.
+
+.TP
+.BR os " (string, default to compiled in value)"
+Same as the
+.B \-O
+option to amd. Allows you to override the compiled-in name of the operating
system. Useful when the built-in name is not desired for backward
compatibility reasons. For example, if the build in name is
.Dq sunos5 ,
diff --git a/contrib/amd/wire-test/wire-test.8 b/contrib/amd/wire-test/wire-test.8
index dfb8a86..a849e7d 100644
--- a/contrib/amd/wire-test/wire-test.8
+++ b/contrib/amd/wire-test/wire-test.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-1999 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: wire-test.8,v 1.2 1999/01/10 21:54:44 ezk Exp $
+.\" $Id: wire-test.8,v 1.3.2.4 2002/12/27 22:45:16 ezk Exp $
.\" $FreeBSD$
.\"
.Dd February 26, 1993
diff --git a/contrib/amd/wire-test/wire-test.c b/contrib/amd/wire-test/wire-test.c
index ef5897a..38b7e01 100644
--- a/contrib/amd/wire-test/wire-test.c
+++ b/contrib/amd/wire-test/wire-test.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: wire-test.c,v 1.5.2.1 2001/01/10 03:23:43 ezk Exp $
+ * $Id: wire-test.c,v 1.5.2.3 2002/12/27 22:45:16 ezk Exp $
* $FreeBSD$
*
*/
OpenPOWER on IntegriCloud