diff options
Diffstat (limited to 'contrib/amd')
47 files changed, 3138 insertions, 7121 deletions
diff --git a/contrib/amd/FREEBSD-Xlist b/contrib/amd/FREEBSD-Xlist new file mode 100644 index 0000000..474cf53 --- /dev/null +++ b/contrib/amd/FREEBSD-Xlist @@ -0,0 +1,145 @@ +$FreeBSD$ +*LSM.am-utils +*Makefile.* +*README.autofs +*ac*.m4 +*.old +*acconfig.h +*aux +*autom4te.cache* +*buildall +*config* +*depcomp +*install-sh +*lt* +*missing +*mkinstalldirs +*stamp-h.in +*amd/Makefile.* +*amq/Makefile.* +*commit +*cvs-server.txt +*conf/checkmount/checkmount_aix.c +*conf/checkmount/checkmount_default.c +*conf/checkmount/checkmount_osf.c +*conf/checkmount/checkmount_svr4.c +*conf/checkmount/checkmount_ultrix.c +*conf/fh_dref/fh_dref_aix3.h +*conf/fh_dref/fh_dref_aix42.h +*conf/fh_dref/fh_dref_bsd44.h +*conf/fh_dref/fh_dref_default.h +*conf/fh_dref/fh_dref_hpux.h +*conf/fh_dref/fh_dref_irix.h +*conf/fh_dref/fh_dref_isc3.h +*conf/fh_dref/fh_dref_linux.h +*conf/fh_dref/fh_dref_nextstep.h +*conf/fh_dref/fh_dref_osf2.h +*conf/fh_dref/fh_dref_osf4.h +*conf/fh_dref/fh_dref_sunos3.h +*conf/fh_dref/fh_dref_sunos4.h +*conf/fh_dref/fh_dref_svr4.h +*conf/hn_dref/hn_dref_isc3.h +*conf/hn_dref/hn_dref_linux.h +*conf/mount/mount_aix.c +*conf/mount/mount_bsdi3.c +*conf/mount/mount_freebsd3.c +*conf/mount/mount_hpux.c +*conf/mount/mount_irix5.c +*conf/mount/mount_irix6.c +*conf/mount/mount_isc3.c +*conf/mount/mount_linux.c +*conf/mount/mount_mach3.c +*conf/mount/mount_stellix.c +*conf/mount/mount_svr4.c +*conf/mtab/mtab_aix.c +*conf/mtab/mtab_file.c +*conf/mtab/mtab_isc3.c +*conf/mtab/mtab_mach3.c +*conf/mtab/mtab_osf.c +*conf/mtab/mtab_svr4.c +*conf/mtab/mtab_ultrix.c +*conf/nfs_prot/nfs_prot_aix3.h +*conf/nfs_prot/nfs_prot_aix4.h +*conf/nfs_prot/nfs_prot_aix4_2.h +*conf/nfs_prot/nfs_prot_aix4_3.h +*conf/nfs_prot/nfs_prot_aix5_1.h +*conf/nfs_prot/nfs_prot_bsdi2.h +*conf/nfs_prot/nfs_prot_bsdi3.h +*conf/nfs_prot/nfs_prot_darwin.h +*conf/nfs_prot/nfs_prot_default.h +*conf/nfs_prot/nfs_prot_hpux.h +*conf/nfs_prot/nfs_prot_hpux11.h +*conf/nfs_prot/nfs_prot_irix5.h +*conf/nfs_prot/nfs_prot_irix6.h +*conf/nfs_prot/nfs_prot_linux.h +*conf/nfs_prot/nfs_prot_ncr2.h +*conf/nfs_prot/nfs_prot_netbsd.h +*conf/nfs_prot/nfs_prot_netbsd1_3.h +*conf/nfs_prot/nfs_prot_netbsd1_4.h +*conf/nfs_prot/nfs_prot_nextstep.h +*conf/nfs_prot/nfs_prot_openbsd.h +*conf/nfs_prot/nfs_prot_osf2.h +*conf/nfs_prot/nfs_prot_osf4.h +*conf/nfs_prot/nfs_prot_osf5.h +*conf/nfs_prot/nfs_prot_osf5_1.h +*conf/nfs_prot/nfs_prot_sunos3.h +*conf/nfs_prot/nfs_prot_sunos4.h +*conf/nfs_prot/nfs_prot_sunos5_3.h +*conf/nfs_prot/nfs_prot_sunos5_4.h +*conf/nfs_prot/nfs_prot_sunos5_5.h +*conf/nfs_prot/nfs_prot_sunos5_6.h +*conf/nfs_prot/nfs_prot_sunos5_7.h +*conf/nfs_prot/nfs_prot_sunos5_8.h +*conf/nfs_prot/nfs_prot_svr4.h +*conf/nfs_prot/nfs_prot_ultrix.h +*conf/sa_dref/sa_dref_386bsd.h +*conf/sa_dref/sa_dref_aix3.h +*conf/sa_dref/sa_dref_aoi.h +*conf/sa_dref/sa_dref_default.h +*conf/sa_dref/sa_dref_isc3.h +*conf/sa_dref/sa_dref_linux.h +*conf/sa_dref/sa_dref_svr4.h +*conf/transp/transp_tli.c +*conf/trap/trap_aix3.h +*conf/trap/trap_aux.h +*conf/trap/trap_dgux.h +*conf/trap/trap_hcx.h +*conf/trap/trap_hpux.h +*conf/trap/trap_hpux11.h +*conf/trap/trap_irix.h +*conf/trap/trap_isc3.h +*conf/trap/trap_linux.h +*conf/trap/trap_mach3.h +*conf/trap/trap_news4.h +*conf/trap/trap_rtu6.h +*conf/trap/trap_stellix.h +*conf/trap/trap_svr4.h +*conf/trap/trap_ultrix.h +*conf/umount/umount_default.c +*conf/umount/umount_osf.c +*doc/Makefile.am +*doc/Makefile.in +*doc/am-utils.dvi +*doc/am-utils.info +*doc/am-utils.info-1 +*doc/am-utils.info-2 +*doc/am-utils.info-3 +*doc/am-utils.info-4 +*doc/am-utils.info-5 +*doc/am-utils.info-6 +*doc/am-utils.info-7 +*doc/am-utils.ps +*doc/hlfsd.ps +*doc/mdate-sh +*fixmount/Makefile.* +*fsinfo/Makefile.* +*hlfsd/Makefile.* +*libamu/Makefile.* +*libamu/clnt_sperrno.c +*libamu/memcmp.c +*libamu/strcasecmp.c +*libamu/strdup.c +*libamu/strstr.c +*libamu/ualarm.c +*mk-amd-map/Makefile.* +*wire-test/Makefile.* diff --git a/contrib/amd/FREEBSD-upgrade b/contrib/amd/FREEBSD-upgrade new file mode 100644 index 0000000..a8e6d53 --- /dev/null +++ b/contrib/amd/FREEBSD-upgrade @@ -0,0 +1,99 @@ +# ex:ts=8 +$FreeBSD$ + +AMD (am-utils) 6.0.9 + originals can be found at: ftp://shekel.mcl.cs.columbia.edu/pub/am-utils/ + (http://www.cs.columbia.edu/~ezk/am-utils/index.html) + + +For the import of AMD many files were pruned by: + + tar -X FREEBSD-Xlist -xzf am-utils-6.0.9.tar.gz + +and `find . -name '.cvsignore' -delete` + +Then imported by: + + cvs import -m 'Virgin import of AMD (am-utils) v6.0.9' \ + src/contrib/amd COLUMBIA amd_6_0_9 + +After the import, a separate extraction of am-utils was GNU configured in +the "normal" way. The resulting config.h file should be compared with +src/usr.sbin/amd/include/config.h, and src/usr.sbin/amd/include/config.h +updated as needed. + +To make local changes to amd, simply patch and commit to the main +branch (aka HEAD). Never make local changes on the vendor (COLUMBIA) branch. + +All local changes should be submitted to "amd-dev@majordomo.cs.columbia.edu" +for inclusion in the next vendor release. + +Local changes: + + amd/amd.8 + r1.17 Uniformly refer to a file system as "file system" + r1.16 Add the am-utils homepage to SEE ALSO + r1.15 s/BSD/.Bx/ where appropriate + r1.14 Avoid using parenthesis enclosure macros + r1.13 split punctuation characters + misc fixes + r1.12 mdoc(7)NG + r1.11 Catch a left over reference to "/a" + r1.10 Document change to the default mount dir. + r1.9 Mention "amd -H" in the synopsis + r1.8 Fix miscellaneous mdoc macro argument limit infringements + r1.7 Don't refer to non-existent automount(8) + r1.6 Fix errors in .Xr usage + r1.3 un-mandocafied, un4.4BSD'ed + r1.2 sort cross references + amd/amd.c + r1.7 use /.amd_mnt as default for -a + amq/amq.8 + r1.9 Uniformly refer to a file system as "file system". + r1.8 s/BSD/.Bx/ where appropriate. + r1.6 mdoc(7)NG. + r1.5 Remove reference to non-existent manpage + r1.4 Fix typos + r1.3 un-mandocafied, un4.4BSD'ed + amq/pawd.1 + r1.3 un-mandocafied, un4.4BSD'ed + r1.2 sorting of references + conf/nfs_prot/nfs_prot_freebsd3.h + r1.11 Userland part of nfs client/server split and cleanup + r1.6 restore the standard name nfs_fh3 + r1.3 Fully use our own generated files for NFSv3 + r1.2 rpcgen our own files for NFSv3 support + fixmount/fixmount.8 + r1.8 Uniformly refer to a file system as "file system" + r1.6 split punctuation characters + misc fixes. + r1.5 mdoc(7)NG. + r1.4 ".Mn mountd" -> ".Nm mountd" + r1.3 un-mandocafied, un4.4BSD'ed + r1.2 More sorting of references. + fsinfo/fsinfo.8 + r1.9 add section number to .Xr directive + r1.7 Uniformly refer to a file system as "file system" + r1.6 split punctuation characters + misc fixes + r1.5 mdoc(7)NG + r1.3 describe all of the command line options + r1.2 un-mandocafied, un4.4BSD'ed + mk-amd-map/mk-amd-map.8 + r1.4 removed HISTORY info from the .Os call. + r1.2 un-mandocafied, un4.4BSD'ed + scripts/amd.conf.5 + r1.15 Bring man page back in shape + r1.13 Uniformly refer to a file system as "file system" + r1.12 Avoid using parenthesis enclosure macros + r1.11 mdoc(7)NG + r1.10 Fix miscellaneous mdoc macro argument limit infringements + r1.8 Fix a bunch of broken cross-references + r1.7 Bad reference of uname(2) -> uname(3) + r1.6 Grammer fix and style nits. + r1.5 xfer typo + r1.4 un-mandocafied, un4.4BSD'ed + r1.3 More sorting of references. + wire-test/wire-test.8 + r1.2 un-mandocafied, un4.4BSD'ed + +mbr@FreeBSD.org +obrien@NUXI.com +05-November-1999 diff --git a/contrib/amd/LSM.am-utils b/contrib/amd/LSM.am-utils deleted file mode 100644 index 07b736f..0000000 --- a/contrib/amd/LSM.am-utils +++ /dev/null @@ -1,20 +0,0 @@ -Begin3 -Title: am-utils -Version: 6.0.1 -Entered-date: 08SEP99 -Description: BSD Automounter Utilities - Replaces the old amd-upl102. Offers NFS V3 support, many - new features, and numerous ports. The home page for - am-utils is in http://www.am-utils.org -Keywords: amd amq hlfsd fsinfo wire-test fixmount mk-amd-map automount -Author: ezk@cs.columbia.edu (Erez Zadok) -Maintained-by: ezk@cs.columbia.edu (Erez Zadok) -Primary-site: shekel.mcl.cs.columbia.edu /pub/am-utils - 1.3MB am-utils-6.0.1.tar.gz - 1.3MB am-utils.tar.gz - 1.3MB am-utils-snapshot.tar.gz -Alternate-site: http://www.am-utils.org/mirrors.html -Original-site: ftp.cs.columbia.edu /pub/amd -Platforms: all modern Unix systems -Copying-policy: BSD -End diff --git a/contrib/amd/TODO b/contrib/amd/TODO deleted file mode 100644 index 07fb555..0000000 --- a/contrib/amd/TODO +++ /dev/null @@ -1,177 +0,0 @@ -# -*- text -*- - -Make a tasks file that people can pick jobs off of. - -take a look at am_compat.h and fix everything there... - -fix all $Id bla bla bla $ on every file. -add my own copyright 1997 etc. - -NOT NEEDED: convert DEBUG symbol to ENABLE_DEBUG -NOT NEEDED: convert DEBUG_MEM symbol to ENABLE_DEBUG_MEM - -Use these two somewhere: -AC_DEFINE(AM_UTILS_NAME_PACKAGE, "am-utils") -AC_DEFINE(AM_UTILS_VERSION, "6.0a1) - -check all "dnl XXX: in configure.in - -check for: INLINE, Const->const, P_void, VOIDP - -rename DEBUG_MTAB to DEBUG_MNTTAB -rename UPDATE_MTAB to MOUNT_TABLE_ON_FILE -rename HAS_NIS_MAPS to HAVE_MAP_NIS -rename HAS_TFS to HAVE_FS_TFS -rename SIG_HNDL_TYP to RETSIGTYPE - -remove HOST_EXEC #define from everywhere. add to am_ops.c a static flag -initialized_vops, which if not true, should set the host_ops vector field to -0 or host_umounted. This way let the feature be turned on if -h option to -amd is given. - -nuke all code that is ifdef'd SUNOS4_COMPAT - -rename NEED_MNTOPT_PARSER to HAVE_HASMNTOPT and cleanup the code. also take -the supplied code in amd/mount_fs.c and include it as the library function -libamd/hasmntopt.c - -TLI code needs to be fixed. - -a way to include a site-specific configuration file IFF it exists from -directory local/<${target}.h> - -replace #include WAIT with nothing (HAVE_SYS_WAIT_H?) - -replace SYS5_SIGNALS with HAVE_SYS_WAIT_H (which is on only if it sys/wait.h -exists and is using the newer "int" for type, not "union wait". The macro -AC_HEADER_SYS_WAIT turns on HAVE_SYS_WAIT_H iff wait*() functions are -posix.1 compliant. Make sure you don't remove SYS5_SIGNALS ifdef's that are -not related to wait*() syscalls. - -add username, hostname, and date at which time amd was compiled. - -No more need for MOUNT_HELPER_SOURCE. - -any code which is included by NEED_UMOUNT_FS, should be on iff -MOUNT_TABLE_ON_FILE is on. - -replace NFS_FH_FIELD with references fo ".fh" in calls to -NFS_FH_DREF(src, dst) macro - -For *EVERY* M4 Macro with case/esac, check that the $host_os case entries -are correct. - -I'm not using amd's regexp code. Instead, use generic system code. If the -system has posix style regexp functions, then change amd/map.c to use -correct new prototype. - -use HAVE_SVC_GETREQSET instead of RPC_4. - -replace all "jsp" in *.[hc] $Id: TODO,v 1.1.1.1 1998/11/05 02:04:19 ezk Exp $ with ezk. - -use MNTTAB_FILE_NAME instead of MOUNTED - -use MOUNT_TABLE_ON_FILE instead of READ_MTAB_FROM_FILE - -no more HAS_EMPTY_AUTOMOUNTS, which was used if a df(1) divide by zero bug -was invoked. Instead, change nfs_statfs() code to always return non-zero -values. Then nuke HAS_EMPTY_AUTOMOUNTS. - -REGEXP: use whatever regular expressionlibrary you have on the system, -including regexp.h if available, and using regcomp/regexec. Amd was written -with BSD regexps in mind, not Sys V, so if I use any of those, I have to -watch for correct usage. Otherwise, I can include the older include/re.h -and amd/re.c. Replace HAS_REGEXP with HAVE_REGEXEC. - -The regex code in amd/mapc.c has changed a lot. It probably has bugs. Must -test and debug it!!! - -# string name of filesystem in /etc/mnttab file -Use MNTTAB_TYPE_FOO instead of MTAB_TYPE_FOO. -# string name of mount option in /etc/mnttab file -Use MNTTAB_OPT_FOO instead of MNTOPT_FOO. -# string (or integer?) name of filesystem type in mount(2) syscall -Use MOUNT_TYPE_FOO instead of MNTTYPE_FOO or MOUNT_FOO. -# hex/number of FS mount option in nfs_args passed to mount(2) syscall -Use MNT2_NFS_OPT_FOO instead NFSMNT_FOO. -# hex/number of generic FS mount option directly passed to mount(2) syscall -Use MNT2_GEN_OPT_FOO instead of MS_FOO or M_FOO. - - -update AMD_COMPAT to 6.0 in include/am_utils.h - -convert all mem* functions b* functions (memset to bzero, etc.) or vice -verse. - -put my name/copyright on every src file - -change all struct mnttab/mntent to "mntent_t" - -cleanup lib/resvport.c (TLI vs. Sockets). TLI code is #defin'ed -HAVE_T_OPEN. -[ -setting MTAB_LOCK_FILE (mtab_svr4.c) should be an amd run-time configuration -option. - -change all UMOUNT_FS macros to umount_fs() fxn calls. - -remove getnetbyaddr() from lib/getnetbyaddr.c and then link w/ -lsocket - -take care of various (hlfsd et al) scripts in Makefile.am files. - -rename HOSTNAMESZ to MAXHOSTNAMELEN - -turn on all the NEW_TOPLVL_READDIR code (for "ls" to work in an amd point) - -change all NEW_DEFAULTS to ENABLE_DEFAULT_SELECTOTS (which is now on by -default) - -remove refereces to mnt_freq and mnt_passno in mntent_t since it's not in -use any more. - -remove all the (lint?) comments /*ARGSUSED */ - -change HAS_FOOFS to HAVE_AM_FS_FOO (for example HAS_NFSX -> HAVE_AM_FS_FOO), -but change HAS_UNION_FS to HAVE_AM_FS_UNION. - -some code uses #ifdef M_NEWTYPE to tell if mount(2)'s type field is "char *" -or int. Use MTYPE_TYPE declaration instead (not ifdef macro!) - -change DEBUG_MTAB to DEBUG_MNTTAB - -deal with the changes in values of $os, $arch, and $osver! - -replace SYS5_SIGNALS with REINSTATE_SIGNAL_HANDLER - -figure out how to auto-conf HAS_HESIOD_RELOAD (amd/info_hesiod.c). For now -I've used the macro HAVE_HS_ZONE_TRANSFER. - - - - -****************************************************************************** -PERL SCRIPT TO FIX OLD AMD MAPS: -- fix '=' to ':=' -- fix sos5 -> solaris2, etc. - -****************************************************************************** -USE AS IS: - -- SVC_IN_ARG_TYPE (change from SVC_IN_ARGS_TYPE, with an 'S') -- NFS_FH_TYPE -- MTYPE_TYPE -- MOUNT_TYPE_* NO!!! - -****************************************************************************** -NEW FEATURES: - -- autofs -- cachefs -- dbm/gdbm/db file maps -- add amd option -O (override) to override $os, $osver, $arch, $karch, etc. - -****************************************************************************** -DONE: - -HAS_TFS is gone and all of it's code too. -major code cleanup, removed if 0 code and if notdef diff --git a/contrib/amd/amd/amd.8 b/contrib/amd/amd/amd.8 index 565a550..54b02fd 100644 --- a/contrib/amd/amd/amd.8 +++ b/contrib/amd/amd/amd.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,334 +38,337 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: amd.8,v 1.14.2.1 2006/01/02 18:48:23 ezk Exp $ +.\" $Id: amd.8,v 1.4.2.5 2004/01/06 03:15:16 ezk Exp $ +.\" $FreeBSD$ .\" -.TH AMD 8 "3 November 1989" -.SH NAME -amd \- automatically mount file systems -.SH SYNOPSIS -.B amd -.B \-H -.br -.B amd -[ -.BI \-F " conf_file" -] -.br -.B amd -[ -.B \-nprvHS -] [ -.BI \-a " mount_point" -] [ -.BI \-c " duration" -] [ -.BI \-d " domain" -] [ -.BI \-k " kernel-arch" -] [ -.BI \-l " logfile" -] [ -.BI \-o " op_sys_ver" -] [ -.BI \-t " interval.interval" -] [ -.BI \-w " interval" -] [ -.BI \-x " log-option" -] [ -.BI \-y " YP-domain" -] [ -.BI \-A " arch" -] [ -.BI \-C " cluster-name" -] [ -.BI \-D " option" -] [ -.BI \-F " conf_file" -] [ -.BI \-O " op_sys_name" -] [ -.BI \-T " tag" -] -[ -.I directory -.I mapname -.RI [ " \-map-options " ] -] .\|.\|. -.SH DESCRIPTION -.B Amd -is a daemon that automatically mounts filesystems -whenever a file or directory -within that filesystem is accessed. -Filesystems are automatically unmounted when they -appear to have become quiescent. -.LP -.B Amd +.Dd April 19, 1994 +.Dt AMD 8 +.Os +.Sh NAME +.Nm amd +.Nd automatically mount file systems +.Sh SYNOPSIS +.Nm amd +.Fl H +.Nm amd +.Op Fl F Ar conf_file +.Nm amd +.Op Fl nprvHS +.Op Fl a Ar mount_point +.Op Fl c Ar duration +.Op Fl d Ar domain +.Bk -words +.Op Fl k Ar kernel-arch +.Ek +.Op Fl l Ar logfile +.Op Fl o Ar op_sys_ver +.Op Fl t Ar timeout.retransmit +.Bk -words +.Op Fl w Ar interval +.Ek +.Op Fl x Ar log-option +.Op Fl y Ar YP-domain +.Bk -words +.Op Fl C Ar cluster-name +.Ek +.Op Fl D Ar option +.Op Fl F Ar conf_file +.Op Fl O Ar op_sys_name +.Op Fl T Ar tag +.Oo +.Ar directory mapname +.Op Fl map-options +.Oc +.Ar ... +.Sh DESCRIPTION +.Nm Amd +is a daemon that automatically mounts file systems whenever a file or directory +within that file system is accessed. +File systems are automatically unmounted +when they appear to be quiescent. +.Pp +.Nm Amd operates by attaching itself as an -.SM NFS +.Tn NFS server to each of the specified -.IB directories . +.Ar directories . Lookups within the specified directories are handled by -.BR amd , +.Nm amd , which uses the map defined by -.I mapname +.Ar mapname to determine how to resolve the lookup. -Generally, this will be a host name, some filesystem information -and some mount options for the given filesystem. -.LP +Generally, this will be a host name, +some file system information and some mount options for the given file system. +.Pp In the first form depicted above, -.B amd -will print a short help string. In the second form, if no options are -specified, or the -.B -F +.Nm amd +will print a short help string. +In the second form, if no options are +specified, or if the +.Fl F is used, -.B amd +.Nm amd will read configuration parameters from the file -.I conf_file +.Ar conf_file which defaults to -.BR /etc/amd.conf . +.Pa /etc/amd.conf . The last form is described below. -.SH OPTIONS - -.\"*******************************************************" - -.TP -.BI \-a " temporary-directory" +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl a Ar temporary-directory Specify an alternative location for the real mount points. The default is -.BR /a . - -.TP -.BI \-c " duration" +.Pa /.amd_mnt . +.It Fl c Ar duration Specify a -.IR duration , +.Ar duration , in seconds, that a looked up name remains -cached when not in use. The default is 5 minutes. - -.TP -.BI \-d " domain" -Specify the local domain name. If this option is not +cached when not in use. +The default is 5 minutes. +.It Fl d Ar domain +Specify the local domain name. +If this option is not given the domain name is determined from the hostname. - -.TP -.BI \-k " kernel-arch" -Specifies the kernel architecture. This is used solely +.It Fl k Ar kernel-arch +Specifies the kernel architecture. +This is used solely to set the ${karch} selector. - -.TP -.BI \-l " logfile" +.It Fl l Ar logfile Specify a logfile in which to record mount and unmount events. If -.I logfile +.Ar logfile is the string -.B syslog -then the log messages will be sent to the system log daemon by -.IR syslog (3). -The default syslog facility used is LOG_DAEMON. If you -wish to change it, append its name to the log file name, delimited by a -single colon. For example, if -.I logfile +.Em syslog , +the log messages will be sent to the system log daemon by +.Xr syslog 3 . +The default syslog facility used is LOG_DAEMON. +If you wish to change it, append its name to the log file name, +delimited by a single colon. +For example, if +.Ar logfile is the string -.B syslog:local7 +.Dq Li syslog:local7 then -.B Amd +.Nm amd will log messages via -.IR syslog (3) +.Xr syslog 3 using the LOG_LOCAL7 facility (if it exists on the system). - -.TP -.B \-n +.It Fl n Normalize hostnames. -The name refereed to by ${rhost} is normalized relative to the -host database before being used. The effect is to translate +The name referred to by ${rhost} is normalized relative to the +host database before being used. +The effect is to translate aliases into ``official'' names. - -.TP -.BI \-o " op_sys_ver" -Override the compiled-in version number of the operating system. Useful -when the built in version is not desired for backward compatibility reasons. -For example, if the build in version is ``2.5.1'', you can override it to -``5.5.1'', and use older maps that were written with the latter in mind. - -.TP -.B \-p -Print PID. +.It Fl o Ar op_sys_ver +Override the compiled-in version number of the operating system. +Useful when the built in version is not desired for backward +compatibility reasons. +For example, if the build in version is +.Dq 2.5.1 , +you can override it to +.Dq 5.5.1 , +and use older maps that were written with the latter in mind. +.It Fl p +Print +.Em PID . Outputs the process-id of -.B amd +.Nm amd to standard output where it can be saved into a file. - -.TP -.B \-r +.It Fl r Restart existing mounts. -.B Amd -will scan the mount file table to determine which filesystems -are currently mounted. Whenever one of these would have +.Nm Amd +will scan the mount file table to determine which file systems +are currently mounted. +Whenever one of these would have been auto-mounted, -.B amd -.I inherits +.Nm amd +.Em inherits it. - -.TP -.BI \-t " timeout.retransmit" +.It Fl t Ar timeout.retransmit Specify the NFS timeout -.IR interval , -in tenths of a second, between NFS/RPC retries (for UDP only). The default -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 +.Ar interval , +in tenths of a second, between +.Tn NFS/RPC +retries (for UDP only). +The default +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. - +.Pp Amd relies on the kernel RPC retransmit mechanism to trigger mount retries. -The values of these parameters change the overall retry interval. Too long +The values of these parameters change the overall retry interval. +Too long an interval gives poor interactive response; too short an interval causes excessive retries. - -.TP -.B \-v -Version. Displays version and configuration information on standard error. - -.TP -.BI \-w " interval" +.It Fl v +Version. +Displays version and configuration information on standard error. +.It Fl w Ar interval Specify an -.IR interval , -in seconds, between attempts to dismount -filesystems that have exceeded their cached times. +.Ar interval , +in seconds, between attempts to dismount file systems that have exceeded their +cached times. The default is 2 minutes. - -.TP -.BI \-x " options" -Specify run-time logging options. The options are a comma separated -list chosen from: fatal, error, user, warn, info, map, stats, all. - -.TP -.BI \-y " domain" -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 +.It Fl x Ar options +Specify run-time logging options. +The options are a comma separated list +chosen from: fatal, error, user, warn, info, map, stats, all. +.It Fl y Ar domain +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. - -.TP -.BI \-A " arch" -Specifies the OS architecture. This is used solely to set the ${arch} -selector. - -.TP -.BI \-C " cluster-name" +.It Fl C Ar cluster-name Specify an alternative HP-UX cluster name to use. - -.TP -.BI \-D " option" -Select from a variety of debug options. Prefixing an -option with the strings -.B no -reverses the effect of that option. Options are cumulative. +.It Fl D Ar option +Select from a variety of debug options. +Prefixing an +option with the string +.Em no +reverses the effect of that option. +Options are cumulative. The most useful option is -.BR all . +.Ar all . +.Pp Since -.I \-D +.Fl D is only used for debugging other options are not documented here: -the current supported set of options is listed by the \-v option +the current supported set of options is listed by the +.Fl v +option and a fuller description is available in the program source. - -.TP -.BI \-F " conf_file" -Specify an amd configuration file to use. See -.BR amd.conf (5) -for description of this file's format. This configuration file is used to -specify any options in lieu of typing many of them on the command line. The -.I amd.conf -file includes directives for every command line option amd has, and many -more that are only available via the configuration file facility. The -configuration file specified by this option is processed after all other -options had been processed, regardless of the actual location of this option -on the command line. - -.TP -.B \-H +.It Fl F Ar conf_file +Specify an +.Nm amd +configuration file to use. +See +.Xr amd.conf 5 +for description of this file's format. +This configuration file is used to +specify any options in lieu of typing many of them on the command line. +The +.Nm amd.conf +file includes directives for every command line option amd has, +and many more that are only available via the configuration file +facility. +The configuration file specified by this option is +processed after all other options have been processed, regardless +of the actual location of this option on the command line. +.It Fl H Print help and usage string. - -.TP -.BI \-O " op_sys_name" -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 ``sunos5'', you can override it to -``sos5'', and use older maps which were written with the latter in mind. - -.TP -.B \-S -Do not lock the running executable pages of amd into memory. To improve -amd's performance, systems that support the -.BR plock (3) -call, could lock the amd process into memory. This way there is less chance -the operating system will schedule, page out, and swap the amd process as -needed. This tends improves amd's performance, at the cost of reserving the -memory used by the amd process (making it unavailable for other processes). +.It Fl O Ar op_sys_name +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 , +you can override it to +.Dq sos5 +and use older maps which were written with the latter in mind. +.It Fl S +Do not lock the running executable pages of +.Nm amd +into memory. +To improve +.Nm amd's +performance, systems that support the +.Xr plock 3 +call, could lock the +.Nm amd +process into memory. +This way there is less chance the operating system will +schedule, page out, and swap the +.Nm amd +process as needed. +This tends to improve +.Nm amd's +performance, at the cost of reserving the memory used by the +.Nm amd +process +(making it unavailable for other processes). If this behavior is not desired, use the -.B \-S +.Fl S option. - -.TP -.BI \-T " tag" +.It Fl T Ar tag Specify a tag to use with -.BR amd.conf (5). -All map entries tagged with -.I tag -will be processed. Map entries that are not tagged are always processed. +.Xr amd.conf 5 . +All Map entries tagged with tag will be processed. +Map entries that are not tagged are always processed. Map entries that are tagged with a tag other than -.I tag +.Ar tag will not be processed. - -.SH FILES -.TP 5 -.B /a -directory under which filesystems are dynamically mounted -.TP 5 -.B /etc/amd.conf +.El +.Sh FILES +.Bl -tag -width /axx +.It Pa /.amd_mnt +directory under which file systems are dynamically mounted +.It Pa /etc/amd.conf default configuration file -.SH CAVEATS +.El +.Sh CAVEATS Some care may be required when creating a mount map. -.LP -Symbolic links on an NFS filesystem can be incredibly inefficient. -In most implementations of NFS, their interpolations are not cached -by the kernel and each time a symlink is encountered during a -.I lookuppn -translation it costs an RPC call to the NFS server. -It would appear that a large improvement in real-time +.Pp +Symbolic links on an +.Tn NFS +file system can be incredibly inefficient. +In most implementations of +.Tn NFS , +their interpolations are not cached by +the kernel and each time a symbolic link is +encountered during a +.Em lookuppn +translation it costs an +.Tn RPC +call to the +.Tn NFS +server. +A large improvement in real-time performance could be gained by adding a cache somewhere. -Replacing symlinks with a suitable incarnation of the auto-mounter +Replacing +.Xr symlink 2 +with a suitable incarnation of the auto-mounter results in a large real-time speedup, but also causes a large number of process context switches. -.LP +.Pp A weird imagination is most useful to gain full advantage of all the features. -.SH "SEE ALSO" -.BR amd.conf (5), -.BR amq (8), -.BR domainname (1), -.BR hostname (1), -.BR automount (8), -.BR mount (8), -.BR umount (8), -.BR mtab (5), -.BR syslog (3). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH AUTHORS -Jan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK. -.P -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P +.Sh SEE ALSO +.Xr domainname 1 , +.Xr hostname 1 , +.Xr syslog 3 , +.Xr amd.conf 5 , +.Xr mtab 5 , +.Xr amq 8 , +.Xr mount 8 , +.Xr umount 8 +.Rs +.%T Amd \- The 4.4 BSD Automounter +.Re +.Pp +.Pa http://www.am-utils.org/ +.Sh HISTORY +The +.Nm amd +utility first appeared in +.Bx 4.4 . +.Sh AUTHORS +.An Jan-Simon Pendry Aq jsp@doc.ic.ac.uk , +Department of Computing, Imperial College, London, UK. +.Pp +.An Erez Zadok Aq ezk@am-utils.org , +Department of Computer Science, Columbia University, +New York, USA. +.Pp Other authors and contributors to am-utils are listed in the -.B AUTHORS +.Pa AUTHORS file distributed with am-utils. diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c index 37eab5d..f724bd8 100644 --- a/contrib/amd/amd/amd.c +++ b/contrib/amd/amd/amd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/amd.c + * $Id: amd.c,v 1.8.2.6 2004/01/06 03:15:16 ezk Exp $ + * $FreeBSD$ * */ @@ -53,10 +55,9 @@ struct amu_global_options gopt; /* where global options are stored */ -char pid_fsname[SIZEOF_PID_FSNAME]; /* "kiska.southseas.nz:(pid%d)" */ +char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */ char *hostdomain = "unknown.domain"; -#define SIZEOF_HOSTD (2 * MAXHOSTNAMELEN + 1) /* Host+domain */ -char hostd[SIZEOF_HOSTD]; /* Host+domain */ +char hostd[2 * MAXHOSTNAMELEN + 1]; /* Host+domain */ char *endian = ARCH_ENDIAN; /* Big or Little endian */ char *cpu = HOST_CPU; /* CPU type */ char *PrimNetName; /* name of primary network */ @@ -71,10 +72,6 @@ struct amd_stats amd_stats; /* Server statistics */ struct in_addr myipaddr; /* (An) IP address of this host */ time_t do_mapc_reload = 0; /* mapc_reload() call required? */ -#ifdef HAVE_FS_AUTOFS -int amd_use_autofs = 0; -#endif /* HAVE_FS_AUTOFS */ - #ifdef HAVE_SIGACTION sigset_t masked_sigs; #endif /* HAVE_SIGACTION */ @@ -122,8 +119,10 @@ sighup(int sig) signal(sig, sighup); #endif /* REINSTALL_SIGNAL_HANDLER */ +#ifdef DEBUG if (sig != SIGHUP) dlog("spurious call to sighup"); +#endif /* DEBUG */ /* * Force a reload by zero'ing the timer */ @@ -135,26 +134,7 @@ sighup(int sig) static RETSIGTYPE parent_exit(int sig) { - /* - * This signal handler is called during Amd initialization. The parent - * forks a child to do all the hard automounting work, and waits for a - * SIGQUIT signal from the child. When the parent gets the signal it's - * supposed to call this handler and exit(3), thus completing the - * daemonizing process. Alas, on some systems, especially Linux 2.4/2.6 - * with Glibc, exit(3) doesn't always terminate the parent process. - * Worse, the parent process now refuses to accept any more SIGQUIT - * signals -- they are blocked. What's really annoying is that this - * doesn't happen all the time, suggesting a race condition somewhere. - * (This happens even if I change the logic to use another signal.) I - * traced this to something which exit(3) does in addition to exiting the - * process, probably some atexit() stuff or other side-effects related to - * signal handling. Either way, since at this stage the parent process - * just needs to terminate, I'm simply calling _exit(2). Note also that - * the OpenGroup doesn't list exit(3) as a recommended "Base Interface" - * but they do list _exit(2) as one. This fix seems to work reliably all - * the time. -Erez (2/27/2005) - */ - _exit(0); + exit(0); } @@ -166,7 +146,6 @@ daemon_mode(void) #ifdef HAVE_SIGACTION struct sigaction sa, osa; - memset(&sa, 0, sizeof(sa)); sa.sa_handler = parent_exit; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); @@ -239,7 +218,6 @@ init_global_options(void) #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) static struct utsname un; #endif /* defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) */ - int i; memset(&gopt, 0, sizeof(struct amu_global_options)); @@ -247,17 +225,11 @@ init_global_options(void) gopt.arch = HOST_ARCH; /* automounter temp dir */ - gopt.auto_dir = "/a"; - - /* toplevel attribute cache timeout */ - gopt.auto_attrcache = 0; + gopt.auto_dir = "/.amd_mnt"; /* cluster name */ gopt.cluster = NULL; - /* executable map timeout */ - gopt.exec_map_timeout = AMFS_EXEC_MAP_TIMEOUT; - /* * kernel architecture: this you must get from uname() if possible. */ @@ -289,11 +261,11 @@ init_global_options(void) /* local domain */ gopt.sub_domain = NULL; - /* reset NFS (and toplvl) retransmit counter and retry interval */ - for (i=0; i<AMU_TYPE_MAX; ++i) { - gopt.amfs_auto_retrans[i] = -1; /* -1 means "never set before" */ - gopt.amfs_auto_timeo[i] = -1; /* -1 means "never set before" */ - } + /* NFS retransmit counter */ + gopt.amfs_auto_retrans = -1; + + /* NFS retry interval */ + gopt.amfs_auto_timeo = -1; /* cache duration */ gopt.am_timeo = AM_TTL; @@ -301,13 +273,11 @@ init_global_options(void) /* dismount interval */ gopt.am_timeo_w = AM_TTL_W; - /* map reload intervl */ - gopt.map_reload_interval = ONE_HOUR; - /* - * various CFM_* flags that are on by default. + * various CFM_* flags. + * by default, only the "plock" option is on (if available). */ - gopt.flags = CFM_DEFAULT_FLAGS; + gopt.flags = CFM_PROCESS_LOCK; #ifdef HAVE_MAP_HESIOD /* Hesiod rhs zone */ @@ -324,9 +294,6 @@ init_global_options(void) /* LDAP cache */ gopt.ldap_cache_seconds = 0; gopt.ldap_cache_maxmem = 131072; - - /* LDAP protocol version */ - gopt.ldap_proto_version = 2; #endif /* HAVE_MAP_LDAP */ #ifdef HAVE_MAP_NIS @@ -336,58 +303,17 @@ init_global_options(void) } -/* - * Lock process text and data segment in memory (after forking the daemon) - */ -static void -do_memory_locking(void) -{ -#if defined(HAVE_PLOCK) || defined(HAVE_MLOCKALL) - int locked_ok = 0; -#else /* not HAVE_PLOCK and not HAVE_MLOCKALL */ - plog(XLOG_WARNING, "Process memory locking not supported by the OS"); -#endif /* not HAVE_PLOCK and not HAVE_MLOCKALL */ -#ifdef HAVE_PLOCK -# ifdef _AIX - /* - * On AIX you must lower the stack size using ulimit() before calling - * plock. Otherwise plock will reserve a lot of memory space based on - * your maximum stack size limit. Since it is not easily possible to - * tell what should the limit be, I print a warning before calling - * plock(). See the manual pages for ulimit(1,3,4) on your AIX system. - */ - plog(XLOG_WARNING, "AIX: may need to lower stack size using ulimit(3) before calling plock"); -# endif /* _AIX */ - if (!locked_ok && plock(PROCLOCK) != 0) - plog(XLOG_WARNING, "Couldn't lock process pages in memory using plock(): %m"); - else - locked_ok = 1; -#endif /* HAVE_PLOCK */ -#ifdef HAVE_MLOCKALL - if (!locked_ok && mlockall(MCL_CURRENT|MCL_FUTURE) != 0) - plog(XLOG_WARNING, "Couldn't lock process pages in memory using mlockall(): %m"); - else - locked_ok = 1; -#endif /* HAVE_MLOCKALL */ -#if defined(HAVE_PLOCK) || defined(HAVE_MLOCKALL) - if (locked_ok) - plog(XLOG_INFO, "Locked process pages in memory"); -#endif /* HAVE_PLOCK || HAVE_MLOCKALL */ - -#if defined(HAVE_MADVISE) && defined(MADV_PROTECT) - madvise(0, 0, MADV_PROTECT); /* may be redundant of the above worked out */ -#endif /* defined(HAVE_MADVISE) && defined(MADV_PROTECT) */ -} - - int main(int argc, char *argv[]) { - char *domdot, *verstr, *vertmp; + char *domdot, *verstr; int ppid = 0; int error; char *progname = NULL; /* "amd" */ char hostname[MAXHOSTNAMELEN + 1] = "localhost"; /* Hostname */ +#ifdef HAVE_SIGACTION + struct sigaction sa; +#endif /* HAVE_SIGACTION */ /* * Make sure some built-in assumptions are true before we start @@ -438,6 +364,11 @@ main(int argc, char *argv[]) going_down(1); } +#ifdef DEBUG + /* initialize debugging flags (Register AMQ, Enter daemon mode) */ + debug_flags = D_AMQ | D_DAEMON; +#endif /* DEBUG */ + /* * Initialize global options structure. */ @@ -456,31 +387,73 @@ main(int argc, char *argv[]) *domdot++ = '\0'; hostdomain = domdot; } - xstrlcpy(hostd, hostname, sizeof(hostd)); + strcpy(hostd, hostname); am_set_hostname(hostname); /* - * Setup signal handlers + * Trap interrupts for shutdowns. + */ +#ifdef HAVE_SIGACTION + sa.sa_handler = sigterm; + sa.sa_flags = 0; + sigemptyset(&(sa.sa_mask)); + sigaddset(&(sa.sa_mask), SIGINT); + sigaddset(&(sa.sa_mask), SIGTERM); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); +#else /* not HAVE_SIGACTION */ + (void) signal(SIGINT, sigterm); +#endif /* not HAVE_SIGACTION */ + + /* + * Trap Terminate so that we can shutdown gracefully (some chance) + */ +#ifdef HAVE_SIGACTION + sa.sa_handler = sigterm; + sa.sa_flags = 0; + sigemptyset(&(sa.sa_mask)); + sigaddset(&(sa.sa_mask), SIGTERM); + sigaction(SIGTERM, &sa, NULL); +#else /* not HAVE_SIGACTION */ + (void) signal(SIGTERM, sigterm); +#endif /* not HAVE_SIGACTION */ + + /* + * Hangups tell us to reload the cache */ - /* SIGINT: trap interrupts for shutdowns */ - setup_sighandler(SIGINT, sigterm); - /* SIGTERM: trap terminate so we can shutdown cleanly (some chance) */ - setup_sighandler(SIGTERM, sigterm); - /* SIGHUP: hangups tell us to reload the cache */ - setup_sighandler(SIGHUP, sighup); +#ifdef HAVE_SIGACTION + sa.sa_handler = sighup; + sa.sa_flags = 0; + sigemptyset(&(sa.sa_mask)); + sigaddset(&(sa.sa_mask), SIGHUP); + sigaction(SIGHUP, &sa, NULL); +#else /* not HAVE_SIGACTION */ + (void) signal(SIGHUP, sighup); +#endif /* not HAVE_SIGACTION */ + /* - * SIGCHLD: trap Death-of-a-child. These allow us to pick up the exit - * status of backgrounded mounts. See "sched.c". + * Trap Death-of-a-child. These allow us to + * pick up the exit status of backgrounded mounts. + * See "sched.c". */ - setup_sighandler(SIGCHLD, sigchld); #ifdef HAVE_SIGACTION - /* construct global "masked_sigs" used in nfs_start.c */ + sa.sa_handler = sigchld; + sa.sa_flags = 0; + sigemptyset(&(sa.sa_mask)); + sigaddset(&(sa.sa_mask), SIGCHLD); + sigaction(SIGCHLD, &sa, NULL); + + /* + * construct global "masked_sigs" used in nfs_start.c + */ sigemptyset(&masked_sigs); - sigaddset(&masked_sigs, SIGINT); - sigaddset(&masked_sigs, SIGTERM); sigaddset(&masked_sigs, SIGHUP); sigaddset(&masked_sigs, SIGCHLD); -#endif /* HAVE_SIGACTION */ + sigaddset(&masked_sigs, SIGTERM); + sigaddset(&masked_sigs, SIGINT); +#else /* not HAVE_SIGACTION */ + (void) signal(SIGCHLD, sigchld); +#endif /* not HAVE_SIGACTION */ /* * Fix-up any umask problems. Most systems default @@ -501,21 +474,18 @@ main(int argc, char *argv[]) /* * Log version information. */ - vertmp = get_version_string(); - verstr = strtok(vertmp, "\n"); + verstr = strtok(get_version_string(), "\n"); plog(XLOG_INFO, "AM-UTILS VERSION INFORMATION:"); while (verstr) { plog(XLOG_INFO, "%s", verstr); verstr = strtok(NULL, "\n"); } - XFREE(vertmp); /* - * Get our own IP address so that we can mount the automounter. We pass - * localhost_address which could be used as the default localhost - * name/address in amu_get_myaddress(). + * Get our own IP address so that we + * can mount the automounter. */ - amu_get_myaddress(&myipaddr, gopt.localhost_address); + amu_get_myaddress(&myipaddr); plog(XLOG_INFO, "My ip addr is %s", inet_ntoa(myipaddr)); /* avoid hanging on other NFS servers if started elsewhere */ @@ -530,6 +500,29 @@ main(int argc, char *argv[]) going_down(1); } + /* + * Lock process text and data segment in memory. + */ +#ifdef HAVE_PLOCK + if (gopt.flags & CFM_PROCESS_LOCK) { +# ifdef _AIX + /* + * On AIX you must lower the stack size using ulimit() before calling + * plock. Otherwise plock will reserve a lot of memory space based on + * your maximum stack size limit. Since it is not easily possible to + * tell what should the limit be, I print a warning before calling + * plock(). See the manual pages for ulimit(1,3,4) on your AIX system. + */ + plog(XLOG_WARNING, "AIX: may need to lower stack size using ulimit(3) before calling plock"); +# endif /* _AIX */ + if (plock(PROCLOCK) != 0) { + plog(XLOG_WARNING, "Couldn't lock process text and data segment in memory: %m"); + } else { + plog(XLOG_INFO, "Locked process text and data segment in memory"); + } + } +#endif /* HAVE_PLOCK */ + #ifdef HAVE_MAP_NIS /* * If the domain was specified then bind it here @@ -542,17 +535,14 @@ main(int argc, char *argv[]) } #endif /* HAVE_MAP_NIS */ - if (!amuDebug(D_DAEMON)) +#ifdef DEBUG + amuDebug(D_DAEMON) +#endif /* DEBUG */ ppid = daemon_mode(); - /* - * Lock process text and data segment in memory. - */ - if (gopt.flags & CFM_PROCESS_LOCK) { - do_memory_locking(); - } + sprintf(pid_fsname, "%s:(pid%ld)", am_get_hostname(), (long) am_mypid); - do_mapc_reload = clocktime(NULL) + gopt.map_reload_interval; + do_mapc_reload = clocktime() + ONE_HOUR; /* * Register automounter with system. @@ -560,16 +550,6 @@ main(int argc, char *argv[]) error = mount_automounter(ppid); if (error && ppid) kill(ppid, SIGALRM); - -#ifdef HAVE_FS_AUTOFS - /* - * XXX this should be part of going_down(), but I can't move it there - * because it would be calling non-library code from the library... ugh - */ - if (amd_use_autofs) - destroy_autofs_service(); -#endif /* HAVE_FS_AUTOFS */ - going_down(error); abort(); diff --git a/contrib/amd/amd/amq_subr.c b/contrib/amd/amd/amq_subr.c index 79ecafc..a5c7f24 100644 --- a/contrib/amd/amd/amq_subr.c +++ b/contrib/amd/amd/amq_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/amq_subr.c + * $Id: amq_subr.c,v 1.6.2.6 2004/01/19 00:25:55 ezk Exp $ + * $FreeBSD$ * */ /* @@ -110,10 +112,8 @@ amq_mount_tree_list * amqproc_export_1_svc(voidp argp, struct svc_req *rqstp) { static amq_mount_tree_list aml; - static am_node *mp; - mp = get_exported_ap(0); - aml.amq_mount_tree_list_val = (amq_mount_tree_p *) ((void *) &mp); + aml.amq_mount_tree_list_val = (amq_mount_tree_p *) &exported_ap[0]; aml.amq_mount_tree_list_len = 1; /* XXX */ return &aml; @@ -131,14 +131,16 @@ amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp) switch (opt->as_opt) { case AMOPT_DEBUG: +#ifdef DEBUG if (debug_option(opt->as_str)) +#endif /* DEBUG */ rc = EINVAL; break; case AMOPT_LOGFILE: if (gopt.logfile && opt->as_str && STREQ(gopt.logfile, opt->as_str)) { - if (switch_to_logfile(opt->as_str, orig_umask, 0)) + if (switch_to_logfile(opt->as_str, orig_umask)) rc = EINVAL; } else { rc = EACCES; @@ -154,8 +156,8 @@ amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp) if (amd_state == Run) { plog(XLOG_INFO, "amq says flush cache"); do_mapc_reload = 0; - flush_nfs_fhandle_cache((fserver *) NULL); - flush_srvr_nfs_cache((fserver *) NULL); + flush_nfs_fhandle_cache((fserver *) 0); + flush_srvr_nfs_cache(); } break; } @@ -167,7 +169,7 @@ amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp) amq_mount_info_list * amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp) { - return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */ + return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */ } @@ -193,64 +195,6 @@ amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp) /* - * Process PAWD string of remote pawd tool. - * - * We repeat the resolution of the string until the resolved string resolves - * to itself. This ensures that we follow path resolutions through all - * possible Amd mount points until we reach some sort of convergence. To - * prevent possible infinite loops, we break out of this loop if the strings - * do not converge after MAX_PAWD_TRIES times. - */ -amq_string * -amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp) -{ - static amq_string res; -#define MAX_PAWD_TRIES 10 - int index, len, maxagain = MAX_PAWD_TRIES; - am_node *mp; - char *mountpoint; - char *dir = *(char **) argp; - static char tmp_buf[MAXPATHLEN]; - char prev_buf[MAXPATHLEN]; - - tmp_buf[0] = prev_buf[0] = '\0'; /* default is empty string: no match */ - do { - for (mp = get_first_exported_ap(&index); - mp; - mp = get_next_exported_ap(&index)) { - if (STREQ(mp->am_mnt->mf_ops->fs_type, "toplvl")) - continue; - if (STREQ(mp->am_mnt->mf_ops->fs_type, "auto")) - continue; - mountpoint = (mp->am_link ? mp->am_link : mp->am_mnt->mf_mount); - len = strlen(mountpoint); - if (len == 0) - continue; - if (!NSTREQ(mountpoint, dir, len)) - continue; - if (dir[len] != '\0' && dir[len] != '/') - continue; - xstrlcpy(tmp_buf, mp->am_path, sizeof(tmp_buf)); - xstrlcat(tmp_buf, &dir[len], sizeof(tmp_buf)); - break; - } /* end of "for" loop */ - /* once tmp_buf and prev_buf are equal, break out of "do" loop */ - if (STREQ(tmp_buf, prev_buf)) - break; - else - xstrlcpy(prev_buf, tmp_buf, sizeof(prev_buf)); - } while (--maxagain); - /* check if we couldn't resolve the string after MAX_PAWD_TRIES times */ - if (maxagain <= 0) - plog(XLOG_WARNING, "path \"%s\" did not resolve after %d tries", - tmp_buf, MAX_PAWD_TRIES); - - res = tmp_buf; - return &res; -} - - -/* * XDR routines. */ @@ -258,7 +202,7 @@ amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp) bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp) { - if (!xdr_enum(xdrs, (enum_t *) ((voidp) &objp->as_opt))) { + if (!xdr_enum(xdrs, (enum_t *) & objp->as_opt)) { return (FALSE); } if (!xdr_string(xdrs, &objp->as_str, AMQ_STRLEN)) { @@ -323,16 +267,10 @@ xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp) if (!xdr_amq_mount_tree_node(xdrs, objp)) { return (FALSE); } - if (!xdr_pointer(xdrs, - (char **) ((voidp) &mp->am_osib), - sizeof(amq_mount_tree), - (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { + if (!xdr_pointer(xdrs, (char **) &mp->am_osib, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } - if (!xdr_pointer(xdrs, - (char **) ((voidp) &mp->am_child), - sizeof(amq_mount_tree), - (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { + if (!xdr_pointer(xdrs, (char **) &mp->am_child, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } return (TRUE); @@ -343,21 +281,15 @@ bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) { am_node *mp = (am_node *) objp; - am_node *mnil = NULL; + am_node *mnil = 0; if (!xdr_amq_mount_tree_node(xdrs, objp)) { return (FALSE); } - if (!xdr_pointer(xdrs, - (char **) ((voidp) &mnil), - sizeof(amq_mount_tree), - (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { + if (!xdr_pointer(xdrs, (char **) ((void *)&mnil), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } - if (!xdr_pointer(xdrs, - (char **) ((voidp) &mp->am_child), - sizeof(amq_mount_tree), - (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { + if (!xdr_pointer(xdrs, (char **) &mp->am_child, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } return (TRUE); @@ -401,7 +333,7 @@ bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) { if (!xdr_array(xdrs, - (char **) ((voidp) &objp->amq_mount_tree_list_val), + (char **) &objp->amq_mount_tree_list_val, (u_int *) &objp->amq_mount_tree_list_len, ~0, sizeof(amq_mount_tree_p), @@ -423,7 +355,7 @@ xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) u_int len = 0; for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { - if (!(mf->mf_fsflags & FS_AMQINFO)) + if (!(mf->mf_ops->fs_flags & FS_AMQINFO)) continue; len++; } @@ -434,7 +366,7 @@ xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) */ for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { int up; - if (!(mf->mf_fsflags & FS_AMQINFO)) + if (!(mf->mf_ops->fs_flags & FS_AMQINFO)) continue; if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) { @@ -455,12 +387,20 @@ xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) if (!xdr_int(xdrs, &mf->mf_refc)) { return (FALSE); } - if (FSRV_ERROR(mf->mf_server) || FSRV_ISDOWN(mf->mf_server)) + if (mf->mf_server->fs_flags & FSF_ERROR) up = 0; - else if (FSRV_ISUP(mf->mf_server)) - up = 1; else - up = -1; + switch (mf->mf_server->fs_flags & (FSF_DOWN | FSF_VALID)) { + case FSF_DOWN | FSF_VALID: + up = 0; + break; + case FSF_VALID: + up = 1; + break; + default: + up = -1; + break; + } if (!xdr_int(xdrs, &up)) { return (FALSE); } diff --git a/contrib/amd/amd/get_args.c b/contrib/amd/amd/get_args.c index 12a7d07..e5c3edf 100644 --- a/contrib/amd/amd/get_args.c +++ b/contrib/amd/amd/get_args.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/get_args.c + * $Id: get_args.c,v 1.7.2.6 2004/01/06 03:15:16 ezk Exp $ + * $FreeBSD$ * */ @@ -54,12 +56,17 @@ /* include auto-generated version file */ #include <build_version.h> -char *amu_conf_file = "/etc/amd.conf"; /* default amd configuration file */ +char *conf_file = "/etc/amd.conf"; /* default amd configuration file */ char *conf_tag = NULL; /* default conf file tags to use */ int usage = 0; int use_conf_file = 0; /* default don't use amd.conf file */ char *mnttab_file_name = NULL; /* symbol must be available always */ - +#if 0 +#ifdef DEBUG +int debug_flags = D_AMQ /* Register AMQ */ + | D_DAEMON; /* Enter daemon mode */ +#endif /* DEBUG */ +#endif /* * Return the version string (dynamic buffer) @@ -67,61 +74,48 @@ char *mnttab_file_name = NULL; /* symbol must be available always */ char * get_version_string(void) { - char *vers = NULL; + static char *vers = NULL; char tmpbuf[1024]; char *wire_buf; int wire_buf_len = 0; - size_t len; /* max allocated length (to avoid buf overflow) */ - /* - * First get dynamic string listing all known networks. - * This could be a long list, if host has lots of interfaces. - */ + /* first get dynamic string listing all known networks */ wire_buf = print_wires(); if (wire_buf) wire_buf_len = strlen(wire_buf); - len = 2048 + wire_buf_len; - vers = xmalloc(len); - xsnprintf(vers, len, "%s\n%s\n%s\n%s\n", - "Copyright (c) 1997-2006 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."); - xsnprintf(tmpbuf, sizeof(tmpbuf), "%s version %s (build %d).\n", - PACKAGE_NAME, PACKAGE_VERSION, AMU_BUILD_VERSION); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "Report bugs to %s.\n", PACKAGE_BUGREPORT); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "Configured by %s@%s on date %s.\n", - USER_NAME, HOST_NAME, CONFIG_DATE); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "Built by %s@%s on date %s.\n", - BUILD_USER, BUILD_HOST, BUILD_DATE); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "cpu=%s (%s-endian), arch=%s, karch=%s.\n", - cpu, endian, gopt.arch, gopt.karch); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "full_os=%s, os=%s, osver=%s, vendor=%s, distro=%s.\n", - gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor, DISTRO_NAME); - strlcat(vers, tmpbuf, len); - xsnprintf(tmpbuf, sizeof(tmpbuf), "domain=%s, host=%s, hostd=%s.\n", - hostdomain, am_get_hostname(), hostd); - strlcat(vers, tmpbuf, len); - - strlcat(vers, "Map support for: ", len); - mapc_showtypes(tmpbuf, sizeof(tmpbuf)); - strlcat(vers, tmpbuf, len); - strlcat(vers, ".\nAMFS: ", len); - ops_showamfstypes(tmpbuf, sizeof(tmpbuf)); - strlcat(vers, tmpbuf, len); - strlcat(vers, ", inherit.\nFS: ", len); /* hack: "show" that we support type:=inherit */ - ops_showfstypes(tmpbuf, sizeof(tmpbuf)); - strlcat(vers, tmpbuf, len); + vers = xmalloc(2048 + wire_buf_len); + sprintf(vers, "%s\n%s\n%s\n%s\n", + "Copyright (c) 1997-2004 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."); + sprintf(tmpbuf, "%s version %s (build %d).\n", + PACKAGE, VERSION, AMU_BUILD_VERSION); + strcat(vers, tmpbuf); + sprintf(tmpbuf, "Built by %s@%s on date %s.\n", + USER_NAME, HOST_NAME, CONFIG_DATE); + strcat(vers, tmpbuf); + sprintf(tmpbuf, "cpu=%s (%s-endian), arch=%s, karch=%s.\n", + cpu, endian, gopt.arch, gopt.karch); + strcat(vers, tmpbuf); + sprintf(tmpbuf, "full_os=%s, os=%s, osver=%s, vendor=%s.\n", + gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor); + strcat(vers, tmpbuf); + + strcat(vers, "Map support for: "); + mapc_showtypes(tmpbuf); + strcat(vers, tmpbuf); + strcat(vers, ".\nAMFS: "); + ops_showamfstypes(tmpbuf); + strcat(vers, tmpbuf); + strcat(vers, ".\nFS: "); + ops_showfstypes(tmpbuf); + strcat(vers, tmpbuf); /* append list of networks if available */ if (wire_buf) { - strlcat(vers, wire_buf, len); + strcat(vers, wire_buf); XFREE(wire_buf); } @@ -129,48 +123,13 @@ get_version_string(void) } -static void -show_usage(void) -{ - fprintf(stderr, - "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\ -\t[-k kernel_arch] [-l logfile%s\n\ -\t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\ -\t[-o op_sys_ver] [-O op_sys_name]\n\ -\t[-F conf_file] [-T conf_tag]", am_get_progname(), -#ifdef HAVE_SYSLOG -# ifdef LOG_DAEMON - "|\"syslog[:facility]\"]" -# else /* not LOG_DAEMON */ - "|\"syslog\"]" -# endif /* not LOG_DAEMON */ -#else /* not HAVE_SYSLOG */ - "]" -#endif /* not HAVE_SYSLOG */ - ); - -#ifdef HAVE_MAP_NIS - fputs(" [-y nis-domain]\n", stderr); -#else /* not HAVE_MAP_NIS */ - fputc('\n', stderr); -#endif /* HAVE_MAP_NIS */ - - show_opts('x', xlog_opt); -#ifdef DEBUG - show_opts('D', dbg_opt); -#endif /* DEBUG */ - fprintf(stderr, "\t[directory mapname [-map_options]] ...\n"); -} - - void get_args(int argc, char *argv[]) { - int opt_ch, i; + int opt_ch; FILE *fp = stdin; - char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:"; + char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:H"; char *getopt_args; - int print_version = 0; /* 1 means we should print version info */ #ifdef HAVE_GNU_GETOPT getopt_args = getopt_arguments; @@ -229,30 +188,24 @@ get_args(int argc, char *argv[]) break; case 't': - /* timeo.retrans (also affects toplvl mounts) */ + /* timeo.retrans */ { char *dot = strchr(optarg, '.'); - int i; if (dot) *dot = '\0'; if (*optarg) { - for (i=0; i<AMU_TYPE_MAX; ++i) - gopt.amfs_auto_timeo[i] = atoi(optarg); + gopt.amfs_auto_timeo = atoi(optarg); } if (dot) { - for (i=0; i<AMU_TYPE_MAX; ++i) - gopt.amfs_auto_retrans[i] = atoi(dot + 1); + gopt.amfs_auto_retrans = atoi(dot + 1); *dot = '.'; } } break; case 'v': - /* - * defer to print version info after every variable had been - * initialized. - */ - print_version++; + fputs(get_version_string(), stderr); + exit(0); break; case 'w': @@ -273,10 +226,6 @@ get_args(int argc, char *argv[]) #endif /* not HAVE_MAP_NIS */ break; - case 'A': - gopt.arch = optarg; - break; - case 'C': gopt.cluster = optarg; break; @@ -291,13 +240,12 @@ get_args(int argc, char *argv[]) break; case 'F': - amu_conf_file = optarg; + conf_file = optarg; use_conf_file = 1; break; case 'H': - show_usage(); - exit(1); + goto show_usage; break; case 'O': @@ -322,19 +270,18 @@ get_args(int argc, char *argv[]) * specified, then use that amd.conf file. If the file cannot be opened, * abort amd. If it can be found, open it, parse it, and then close it. */ - if (use_conf_file && amu_conf_file) { - fp = fopen(amu_conf_file, "r"); + if (use_conf_file && conf_file) { + fp = fopen(conf_file, "r"); if (!fp) { char buf[128]; - xsnprintf(buf, sizeof(buf), "Amd configuration file (%s)", - amu_conf_file); + sprintf(buf, "Amd configuration file (%s)", conf_file); perror(buf); exit(1); } yyin = fp; yyparse(); fclose(fp); - if (process_all_regular_maps() != 0) + if (process_last_regular_map() != 0) exit(1); } @@ -347,8 +294,8 @@ get_args(int argc, char *argv[]) #endif /* DEBUG */ /* log information regarding amd.conf file */ - if (use_conf_file && amu_conf_file) - plog(XLOG_INFO, "using configuration file %s", amu_conf_file); + if (use_conf_file && conf_file) + plog(XLOG_INFO, "using configuration file %s", conf_file); #ifdef HAVE_MAP_LDAP /* ensure that if ldap_base is specified, that also ldap_hostports is */ @@ -358,10 +305,8 @@ get_args(int argc, char *argv[]) } #endif /* HAVE_MAP_LDAP */ - if (usage) { - show_usage(); - exit(1); - } + if (usage) + goto show_usage; while (optind <= argc - 2) { char *dir = argv[optind++]; @@ -383,55 +328,76 @@ get_args(int argc, char *argv[]) hostdomain = gopt.sub_domain; if (*hostdomain == '.') hostdomain++; - xstrlcat(hostd, ".", sizeof(hostd)); - xstrlcat(hostd, hostdomain, sizeof(hostd)); + strcat(hostd, "."); + strcat(hostd, hostdomain); #ifdef MOUNT_TABLE_ON_FILE - if (amuDebug(D_MTAB)) - if (gopt.debug_mtab_file) - mnttab_file_name = gopt.debug_mtab_file; /* user supplied debug mtab path */ - else - mnttab_file_name = DEBUG_MNTTAB_FILE; /* default debug mtab path */ +# ifdef DEBUG + if (debug_flags & D_MTAB) + mnttab_file_name = DEBUG_MNTTAB; else +# endif /* DEBUG */ mnttab_file_name = MNTTAB_FILE_NAME; #else /* not MOUNT_TABLE_ON_FILE */ - if (amuDebug(D_MTAB)) +# ifdef DEBUG + if (debug_flags & D_MTAB) dlog("-D mtab option ignored"); +# endif /* DEBUG */ # ifdef MNTTAB_FILE_NAME mnttab_file_name = MNTTAB_FILE_NAME; # endif /* MNTTAB_FILE_NAME */ #endif /* not MOUNT_TABLE_ON_FILE */ + if (switch_to_logfile(gopt.logfile, orig_umask) != 0) + plog(XLOG_USER, "Cannot switch logfile"); + /* * If the kernel architecture was not specified * then use the machine architecture. */ - if (gopt.karch == NULL) + if (gopt.karch == 0) gopt.karch = gopt.arch; - if (gopt.cluster == NULL) + if (gopt.cluster == 0) gopt.cluster = hostdomain; - /* sanity checking, normalize values just in case (toplvl too) */ - for (i=0; i<AMU_TYPE_MAX; ++i) { - if (gopt.amfs_auto_timeo[i] == 0) - gopt.amfs_auto_timeo[i] = AMFS_AUTO_TIMEO; - if (gopt.amfs_auto_retrans[i] == 0) - gopt.amfs_auto_retrans[i] = AMFS_AUTO_RETRANS(i); - if (gopt.amfs_auto_retrans[i] == 0) - gopt.amfs_auto_retrans[i] = 3; /* under very unusual circumstances, could be zero */ - } + if (gopt.amfs_auto_timeo <= 0) + gopt.amfs_auto_timeo = AMFS_AUTO_TIMEO; + if (gopt.amfs_auto_retrans <= 0) + gopt.amfs_auto_retrans = AMFS_AUTO_RETRANS; + if (gopt.amfs_auto_retrans <= 0) + gopt.amfs_auto_retrans = 3; /* XXX */ + return; } - /* finally print version string and exit, if asked for */ - if (print_version) { - fputs(get_version_string(), stderr); - exit(0); - } +show_usage: + fprintf(stderr, + "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\ +\t[-k kernel_arch] [-l logfile%s\n\ +\t[-t timeout.retrans] [-w wait_timeout] [-C cluster_name]\n\ +\t[-o op_sys_ver] [-O op_sys_name]\n\ +\t[-F conf_file] [-T conf_tag]", am_get_progname(), +#ifdef HAVE_SYSLOG +# ifdef LOG_DAEMON + "|\"syslog[:facility]\"]" +# else /* not LOG_DAEMON */ + "|\"syslog\"]" +# endif /* not LOG_DAEMON */ +#else /* not HAVE_SYSLOG */ + "]" +#endif /* not HAVE_SYSLOG */ + ); - if (switch_to_logfile(gopt.logfile, orig_umask, - (gopt.flags & CFM_TRUNCATE_LOG)) != 0) - plog(XLOG_USER, "Cannot switch logfile"); +#ifdef HAVE_MAP_NIS + fputs(" [-y nis-domain]\n", stderr); +#else /* not HAVE_MAP_NIS */ + fputc('\n', stderr); +#endif /* HAVE_MAP_NIS */ - return; + show_opts('x', xlog_opt); +#ifdef DEBUG + show_opts('D', dbg_opt); +#endif /* DEBUG */ + fprintf(stderr, "\t[directory mapname [-map_options]] ...\n"); + exit(1); } diff --git a/contrib/amd/amd/nfs_prot_svc.c b/contrib/amd/amd/nfs_prot_svc.c index 0dd6992..8d67d1b 100644 --- a/contrib/amd/amd/nfs_prot_svc.c +++ b/contrib/amd/amd/nfs_prot_svc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/nfs_prot_svc.c + * $Id: nfs_prot_svc.c,v 1.5.2.6 2004/01/21 04:04:58 ib42 Exp $ + * $FreeBSD$ * */ @@ -68,7 +70,7 @@ extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(am_nfs_fh *, struct svc_req *); /* global variables */ -SVCXPRT *current_transp; +SVCXPRT *nfs_program_2_transp; /* typedefs */ typedef char *(*nfssvcproc_t)(voidp, struct svc_req *); @@ -97,60 +99,30 @@ nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp) char *result; xdrproc_t xdr_argument, xdr_result; nfssvcproc_t local; - -#ifdef HAVE_TRANSPORT_TYPE_TLI - /* - * On TLI systems we don't use an INET network type, but a "ticlts" (see - * /etc/netconfig and conf/transp_tli.c:create_nfs_service). This means - * that packets could only come from the loopback interface, and we don't - * need to check them and filter possibly spoofed packets. Therefore we - * only need to check if the UID caller is correct. - */ -# ifdef HAVE___RPC_GET_LOCAL_UID - uid_t u; - /* extern definition for an internal libnsl function */ - extern int __rpc_get_local_uid(SVCXPRT *transp, uid_t *uid); - if (__rpc_get_local_uid(transp, &u) >= 0 && u != 0) { - plog(XLOG_WARNING, "ignoring request from UID %ld, must be 0", (long) u); - return; - } -# else /* not HAVE___RPC_GET_LOCAL_UID */ - dlog("cannot verify local uid for rpc request"); -# endif /* HAVE___RPC_GET_LOCAL_UID */ -#else /* not HAVE_TRANPORT_TYPE_TLI */ struct sockaddr_in *sinp; char dq[20], dq2[28]; + sinp = amu_svc_getcaller(rqstp->rq_xprt); -# ifdef MNT2_NFS_OPT_RESVPORT +#ifdef MNT2_NFS_OPT_RESVPORT /* Verify that the request comes from a reserved port */ - if (sinp && - ntohs(sinp->sin_port) >= IPPORT_RESERVED && + if ((ntohs(sinp->sin_port) >= IPPORT_RESERVED) && !(gopt.flags & CFM_NFS_INSECURE_PORT)) { plog(XLOG_WARNING, "ignoring request from %s:%u, port not reserved", - inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), + inet_dquad(dq, sinp->sin_addr.s_addr), ntohs(sinp->sin_port)); return; } -# endif /* MNT2_NFS_OPT_RESVPORT */ +#endif /* MNT2_NFS_OPT_RESVPORT */ /* if the address does not match, ignore the request */ - if (sinp && (sinp->sin_addr.s_addr != myipaddr.s_addr)) { - if (gopt.flags & CFM_NFS_ANY_INTERFACE) { - if (!is_interface_local(sinp->sin_addr.s_addr)) { - plog(XLOG_WARNING, "ignoring request from %s:%u, not a local interface", - inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), - ntohs(sinp->sin_port)); - } - } else { - plog(XLOG_WARNING, "ignoring request from %s:%u, expected %s", - inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), - ntohs(sinp->sin_port), - inet_dquad(dq2, sizeof(dq2), myipaddr.s_addr)); - return; - } + if (sinp->sin_addr.s_addr && sinp->sin_addr.s_addr != myipaddr.s_addr) { + plog(XLOG_WARNING, "ignoring request from %s:%u, expected %s", + inet_dquad(dq, sinp->sin_addr.s_addr), + ntohs(sinp->sin_port), + inet_dquad(dq2, myipaddr.s_addr)); + return; } -#endif /* not HAVE_TRANPORT_TYPE_TLI */ - current_transp = NULL; + nfs_program_2_transp = NULL; switch (rqstp->rq_proc) { @@ -187,7 +159,7 @@ nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp) * be stored in the am_node structure and later used for * quick_reply(). */ - current_transp = transp; + nfs_program_2_transp = transp; break; case NFSPROC_READLINK: @@ -285,7 +257,7 @@ nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp) } result = (*local) (&argument, rqstp); - current_transp = NULL; + nfs_program_2_transp = NULL; if (result != NULL && !svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, 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/ops_pcfs.c b/contrib/amd/amd/ops_pcfs.c index 527dc92..5552c43 100644 --- a/contrib/amd/amd/ops_pcfs.c +++ b/contrib/amd/amd/ops_pcfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/ops_pcfs.c + * $Id: ops_pcfs.c,v 1.3.2.5 2004/01/06 03:15:16 ezk Exp $ + * $FreeBSD$ * */ @@ -53,8 +55,8 @@ /* forward definitions */ static char *pcfs_match(am_opts *fo); -static int pcfs_mount(am_node *am, mntfs *mf); -static int pcfs_umount(am_node *am, mntfs *mf); +static int pcfs_fmount(mntfs *mf); +static int pcfs_fumount(mntfs *mf); /* * Ops structure @@ -64,20 +66,17 @@ am_ops pcfs_ops = "pcfs", pcfs_match, 0, /* pcfs_init */ - pcfs_mount, - pcfs_umount, - amfs_error_lookup_child, - amfs_error_mount_child, + amfs_auto_fmount, + pcfs_fmount, + amfs_auto_fumount, + pcfs_fumount, + amfs_error_lookuppn, amfs_error_readdir, 0, /* pcfs_readlink */ 0, /* pcfs_mounted */ 0, /* pcfs_umounted */ - amfs_generic_find_srvr, - 0, /* pcfs_get_wchan */ - FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ -#ifdef HAVE_FS_AUTOFS - AUTOFS_PCFS_FS_FLAGS, -#endif /* HAVE_FS_AUTOFS */ + find_amfs_auto_srvr, + FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO }; @@ -92,7 +91,9 @@ pcfs_match(am_opts *fo) plog(XLOG_USER, "pcfs: no source device specified"); return 0; } +#ifdef DEBUG dlog("PCFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); +#endif /* DEBUG */ /* * Determine magic cookie to put in mtab @@ -102,17 +103,11 @@ pcfs_match(am_opts *fo) static int -mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) +mount_pcfs(char *dir, char *fs_name, char *opts) { pcfs_args_t pcfs_args; mntent_t mnt; int flags; -#if defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK) - int mask; -#endif /* defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK) */ -#if defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID) - char *str; -#endif /* defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID) */ /* * Figure out the name of the file system type. @@ -125,18 +120,12 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); - mnt.mnt_dir = mntdir; + mnt.mnt_dir = dir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_PCFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); -#ifdef HAVE_FS_AUTOFS - if (on_autofs) - flags |= autofs_compute_mount_flags(&mnt); -#endif /* HAVE_FS_AUTOFS */ - if (amuDebug(D_TRACE)) - plog(XLOG_DEBUG, "mount_pcfs: flags=0x%x", (u_int) flags); #ifdef HAVE_PCFS_ARGS_T_FSPEC pcfs_args.fspec = fs_name; @@ -144,46 +133,18 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) #ifdef HAVE_PCFS_ARGS_T_MASK pcfs_args.mask = 0777; /* this may be the msdos file modes */ - if ((mask = hasmntval(&mnt, MNTTAB_OPT_MASK)) > 0) - pcfs_args.mask = mask; - if (amuDebug(D_TRACE)) - plog(XLOG_DEBUG, "mount_pcfs: mask=%o (octal)", (u_int) pcfs_args.mask); #endif /* HAVE_PCFS_ARGS_T_MASK */ #ifdef HAVE_PCFS_ARGS_T_DIRMASK - pcfs_args.dirmask = 0777; /* this may be the msdos dir modes */ - if ((mask = hasmntval(&mnt, MNTTAB_OPT_DIRMASK)) > 0) - pcfs_args.dirmask = mask; - if (amuDebug(D_TRACE)) - plog(XLOG_DEBUG, "mount_pcfs: dirmask=%o (octal)", (u_int) pcfs_args.dirmask); + pcfs_args.dirmask = 0777; /* this may be the msdos dir modes */ #endif /* HAVE_PCFS_ARGS_T_DIRMASK */ #ifdef HAVE_PCFS_ARGS_T_UID - pcfs_args.uid = 0; /* default to root */ - if ((str = hasmntstr(&mnt, MNTTAB_OPT_USER)) != NULL) { - struct passwd *pw; - if ((pw = getpwnam(str)) != NULL) - pcfs_args.uid = pw->pw_uid; - else /* maybe used passed a UID number, not user name */ - pcfs_args.uid = atoi(str); /* atoi returns '0' if it failed */ - XFREE(str); - } - if (amuDebug(D_TRACE)) - plog(XLOG_DEBUG, "mount_pcfs: uid=%d", (int) pcfs_args.uid); + pcfs_args.uid = 0; /* root */ #endif /* HAVE_PCFS_ARGS_T_UID */ #ifdef HAVE_PCFS_ARGS_T_GID - pcfs_args.gid = 0; /* default to wheel/root group */ - if ((str = hasmntstr(&mnt, MNTTAB_OPT_GROUP)) != NULL) { - struct group *gr; - if ((gr = getgrnam(str)) != NULL) - pcfs_args.gid = gr->gr_gid; - else /* maybe used passed a GID number, not group name */ - pcfs_args.gid = atoi(str); /* atoi returns '0' if it failed */ - XFREE(str); - } - if (amuDebug(D_TRACE)) - plog(XLOG_DEBUG, "mount_pcfs: gid=%d", (int) pcfs_args.gid); + pcfs_args.gid = 0; /* wheel */ #endif /* HAVE_PCFS_ARGS_T_GID */ #ifdef HAVE_PCFS_ARGS_T_SECONDSWEST @@ -196,17 +157,16 @@ mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) /* * Call generic mount routine */ - return mount_fs(&mnt, flags, (caddr_t) & pcfs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); + return mount_fs(&mnt, flags, (caddr_t) & pcfs_args, 0, type, 0, NULL, mnttab_file_name); } static int -pcfs_mount(am_node *am, mntfs *mf) +pcfs_fmount(mntfs *mf) { - int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; - error = mount_pcfs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); + error = mount_pcfs(mf->mf_mount, mf->mf_info, mf->mf_mopts); if (error) { errno = error; plog(XLOG_ERROR, "mount_pcfs: %m"); @@ -218,9 +178,7 @@ pcfs_mount(am_node *am, mntfs *mf) static int -pcfs_umount(am_node *am, mntfs *mf) +pcfs_fumount(mntfs *mf) { - int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; - - return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); + return UMOUNT_FS(mf->mf_mount, mnttab_file_name); } diff --git a/contrib/amd/amd/srvr_nfs.c b/contrib/amd/amd/srvr_nfs.c index 0c74a65..67d1724 100644 --- a/contrib/amd/amd/srvr_nfs.c +++ b/contrib/amd/amd/srvr_nfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amd/srvr_nfs.c + * $Id: srvr_nfs.c,v 1.7.2.11 2004/01/06 03:15:16 ezk Exp $ + * $FreeBSD$ * */ @@ -71,6 +73,8 @@ */ #endif /* (FAST_NFS_PING * MAX_ALLOWED_PINGS) >= ALLOWED_MOUNT_TIME */ +#define NPXID_ALLOC(struct ) (++np_xid) + /* structures and typedefs */ typedef struct nfs_private { u_short np_mountd; /* Mount daemon port number */ @@ -85,16 +89,9 @@ typedef struct nfs_private { qelem nfs_srvr_list = {&nfs_srvr_list, &nfs_srvr_list}; /* statics */ -static int global_xid; /* For NFS pings */ -#define XID_ALLOC() (++global_xid) - -#ifdef HAVE_FS_NFS3 -# define NUM_NFS_VERS 2 -#else /* not HAVE_FS_NFS3 */ -# define NUM_NFS_VERS 1 -#endif /* not HAVE_FS_NFS3 */ -static int ping_len[NUM_NFS_VERS]; -static char ping_buf[NUM_NFS_VERS][sizeof(struct rpc_msg) + 32]; +static int np_xid; /* For NFS pings */ +static int ping_len; +static char ping_buf[sizeof(struct rpc_msg) + 32]; #if defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) /* @@ -103,8 +100,6 @@ static char ping_buf[NUM_NFS_VERS][sizeof(struct rpc_msg) + 32]; * Note that Solaris 8 and newer NetBSD systems are switching to UDP first, * so this order may have to be adjusted for Amd in the future once more * vendors make that change. -Erez 11/24/2000 - * - * Or we might simply make this is a platform-specific order. -Ion 09/13/2003 */ static char *protocols[] = { "tcp", "udp", NULL }; #endif /* defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ @@ -113,21 +108,20 @@ static char *protocols[] = { "tcp", "udp", NULL }; static void nfs_keepalive(voidp); + /* - * Flush cached data for an fserver (or for all, if fs==NULL) + * Flush any cached data */ void -flush_srvr_nfs_cache(fserver *fs) +flush_srvr_nfs_cache(void) { - fserver *fs2 = NULL; + fserver *fs = 0; - ITER(fs2, fserver, &nfs_srvr_list) { - if (fs == NULL || fs == fs2) { - nfs_private *np = (nfs_private *) fs2->fs_private; - if (np) { - np->np_mountd_inval = TRUE; - np->np_error = -1; - } + ITER(fs, fserver, &nfs_srvr_list) { + nfs_private *np = (nfs_private *) fs->fs_private; + if (np) { + np->np_mountd_inval = TRUE; + np->np_error = -1; } } } @@ -137,7 +131,7 @@ flush_srvr_nfs_cache(fserver *fs) * Startup the NFS ping for a particular version. */ static void -create_ping_payload(u_long nfs_version) +start_ping(u_long nfs_version) { XDR ping_xdr; struct rpc_msg ping_msg; @@ -147,16 +141,16 @@ create_ping_payload(u_long nfs_version) */ if (nfs_version == 0) { nfs_version = NFS_VERSION; - plog(XLOG_WARNING, "create_ping_payload: nfs_version = 0, changed to 2"); - } else - plog(XLOG_INFO, "create_ping_payload: nfs_version: %d", (int) nfs_version); + plog(XLOG_WARNING, "start_ping: nfs_version = 0 fixed"); + } + plog(XLOG_INFO, "start_ping: nfs_version: %d", (int) nfs_version); rpc_msg_init(&ping_msg, NFS_PROGRAM, nfs_version, NFSPROC_NULL); /* * Create an XDR endpoint */ - xdrmem_create(&ping_xdr, ping_buf[nfs_version - NFS_VERSION], sizeof(ping_buf[0]), XDR_ENCODE); + xdrmem_create(&ping_xdr, ping_buf, sizeof(ping_buf), XDR_ENCODE); /* * Create the NFS ping message @@ -168,7 +162,7 @@ create_ping_payload(u_long nfs_version) /* * Find out how long it is */ - ping_len[nfs_version - NFS_VERSION] = xdr_getpos(&ping_xdr); + ping_len = xdr_getpos(&ping_xdr); /* * Destroy the XDR endpoint - we don't need it anymore @@ -190,7 +184,7 @@ got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, * Find which fileserver we are talking about */ ITER(fs, fserver, &nfs_srvr_list) - if (fs == fs2) + if (fs == fs2) break; if (fs == fs2) { @@ -199,7 +193,9 @@ got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, nfs_private *np = (nfs_private *) fs->fs_private; if (!error && port) { +#ifdef DEBUG dlog("got port (%d) for mountd on %s", (int) port, fs->fs_host); +#endif /* DEBUG */ /* * Grab the port number. Portmap sends back * an u_long in native ordering, so it @@ -210,8 +206,10 @@ got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, np->np_mountd_inval = FALSE; np->np_error = 0; } else { +#ifdef DEBUG dlog("Error fetching port for mountd on %s", fs->fs_host); dlog("\t error=%d, port=%d", error, (int) port); +#endif /* DEBUG */ /* * Almost certainly no mountd running on remote host */ @@ -221,9 +219,13 @@ got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, if (fs->fs_flags & FSF_WANT) wakeup_srvr(fs); } else if (done) { +#ifdef DEBUG dlog("Got portmap for old port request"); +#endif /* DEBUG */ } else { +#ifdef DEBUG dlog("portmap request timed out"); +#endif /* DEBUG */ } } @@ -257,7 +259,7 @@ call_portmap(fserver *fs, AUTH *auth, u_long prog, u_long vers, u_long prot) memset((voidp) &sin, 0, sizeof(sin)); sin = *fs->fs_ip; sin.sin_port = htons(PMAPPORT); - error = fwd_packet(RPC_XID_PORTMAP, iobuf, len, + error = fwd_packet(RPC_XID_PORTMAP, (voidp) iobuf, len, &sin, &sin, (voidp) fs, got_portmap); } else { error = -len; @@ -273,12 +275,6 @@ recompute_portmap(fserver *fs) int error; u_long mnt_version; - /* - * No portmap calls for pure WebNFS servers. - */ - if (fs->fs_flags & FSF_WEBNFS) - return; - if (nfs_auth) error = 0; else @@ -293,11 +289,10 @@ recompute_portmap(fserver *fs) if (fs->fs_version == 0) plog(XLOG_WARNING, "recompute_portmap: nfs_version = 0 fixed"); - plog(XLOG_INFO, "recompute_portmap: NFS version %d on %s", - (int) fs->fs_version, fs->fs_host); + plog(XLOG_INFO, "recompute_portmap: NFS version %d", (int) fs->fs_version); #ifdef HAVE_FS_NFS3 if (fs->fs_version == NFS_VERSION3) - mnt_version = AM_MOUNTVERS3; + mnt_version = MOUNTVERS3; else #endif /* HAVE_FS_NFS3 */ mnt_version = MOUNTVERS; @@ -307,61 +302,19 @@ recompute_portmap(fserver *fs) } -int -get_mountd_port(fserver *fs, u_short *port, wchan_t wchan) -{ - int error = -1; - if (FSRV_ISDOWN(fs)) - return EWOULDBLOCK; - - if (FSRV_ISUP(fs)) { - nfs_private *np = (nfs_private *) fs->fs_private; - if (np->np_error == 0) { - *port = np->np_mountd; - error = 0; - } else { - error = np->np_error; - } - /* - * Now go get the port mapping again in case it changed. - * Note that it is used even if (np_mountd_inval) - * is True. The flag is used simply as an - * indication that the mountd may be invalid, not - * that it is known to be invalid. - */ - if (np->np_mountd_inval) - recompute_portmap(fs); - else - np->np_mountd_inval = TRUE; - } - if (error < 0 && wchan && !(fs->fs_flags & FSF_WANT)) { - /* - * If a wait channel is supplied, and no - * error has yet occurred, then arrange - * that a wakeup is done on the wait channel, - * whenever a wakeup is done on this fs node. - * Wakeup's are done on the fs node whenever - * it changes state - thus causing control to - * come back here and new, better things to happen. - */ - fs->fs_flags |= FSF_WANT; - sched_task(wakeup_task, wchan, (wchan_t) fs); - } - return error; -} - - /* * This is called when we get a reply to an RPC ping. * The value of id was taken from the nfs_private * structure when the ping was transmitted. */ static void -nfs_keepalive_callback(voidp pkt, int len, struct sockaddr_in *sp, struct sockaddr_in *tsp, voidp idv, int done) +nfs_pinged(voidp pkt, int len, struct sockaddr_in *sp, struct sockaddr_in *tsp, voidp idv, int done) { - int xid = (long) idv; /* cast needed for 64-bit archs */ + int xid = (long) idv; /* for 64-bit archs */ fserver *fs; +#ifdef DEBUG int found_map = 0; +#endif /* DEBUG */ if (!done) return; @@ -384,15 +337,19 @@ nfs_keepalive_callback(voidp pkt, int len, struct sockaddr_in *sp, struct sockad } else { if (np->np_ping > 1) srvrlog(fs, "ok"); +#ifdef DEBUG else srvrlog(fs, "starts up"); +#endif /* DEBUG */ fs->fs_flags |= FSF_VALID; } map_flush_srvr(fs); } else { if (fs->fs_flags & FSF_VALID) { +#ifdef DEBUG dlog("file server %s type nfs is still up", fs->fs_host); +#endif /* DEBUG */ } else { if (np->np_ping > 1) srvrlog(fs, "ok"); @@ -409,13 +366,13 @@ nfs_keepalive_callback(voidp pkt, int len, struct sockaddr_in *sp, struct sockad /* * Update ttl for this server */ - np->np_ttl = clocktime(NULL) + + np->np_ttl = clocktime() + (MAX_ALLOWED_PINGS - 1) * FAST_NFS_PING + fs->fs_pinger - 1; /* * New RPC xid... */ - np->np_xid = XID_ALLOC(); + np->np_xid = NPXID_ALLOC(struct ); /* * Failed pings is zero... @@ -428,53 +385,17 @@ nfs_keepalive_callback(voidp pkt, int len, struct sockaddr_in *sp, struct sockad if (np->np_mountd_inval) recompute_portmap(fs); +#ifdef DEBUG found_map++; +#endif /* DEBUG */ break; } } +#ifdef DEBUG if (found_map == 0) dlog("Spurious ping packet"); -} - - -static void -check_fs_addr_change(fserver *fs) -{ - struct hostent *hp = NULL; - struct in_addr ia; - char *old_ipaddr, *new_ipaddr; - - hp = gethostbyname(fs->fs_host); - if (!hp || - hp->h_addrtype != AF_INET || - !STREQ((char *) hp->h_name, fs->fs_host) || - memcmp((voidp) &fs->fs_ip->sin_addr, - (voidp) hp->h_addr, - sizeof(fs->fs_ip->sin_addr)) == 0) - return; - /* if got here: downed server changed IP address */ - old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr)); - memmove((voidp) &ia, (voidp) hp->h_addr, sizeof(struct in_addr)); - new_ipaddr = inet_ntoa(ia); /* ntoa uses static buf */ - plog(XLOG_WARNING, "EZK: down fileserver %s changed ip: %s -> %s", - fs->fs_host, old_ipaddr, new_ipaddr); - XFREE(old_ipaddr); - /* copy new IP addr */ - memmove((voidp) &fs->fs_ip->sin_addr, - (voidp) hp->h_addr, - sizeof(fs->fs_ip->sin_addr)); - /* XXX: do we need to un/set these flags? */ - fs->fs_flags &= ~FSF_DOWN; - fs->fs_flags |= FSF_VALID | FSF_WANT; - map_flush_srvr(fs); /* XXX: a race with flush_srvr_nfs_cache? */ - flush_srvr_nfs_cache(fs); - fs->fs_flags |= FSF_FORCE_UNMOUNT; - -#if 0 - flush_nfs_fhandle_cache(fs); /* done in caller: nfs_keepalive_timeout */ - /* XXX: need to purge nfs_private so that somehow it will get re-initialized? */ -#endif +#endif /* DEBUG */ } @@ -482,7 +403,7 @@ check_fs_addr_change(fserver *fs) * Called when no ping-reply received */ static void -nfs_keepalive_timeout(voidp v) +nfs_timed_out(voidp v) { fserver *fs = v; nfs_private *np = (nfs_private *) fs->fs_private; @@ -503,9 +424,11 @@ nfs_keepalive_timeout(voidp v) /* * If ttl has expired then guess that it is dead */ - if (np->np_ttl < clocktime(NULL)) { + 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. @@ -519,13 +442,14 @@ nfs_keepalive_timeout(voidp v) */ flush_nfs_fhandle_cache(fs); np->np_error = -1; - check_fs_addr_change(fs); /* check if IP addr of fserver changed */ } else { /* * Known to be down */ +#ifdef DEBUG if ((fs->fs_flags & FSF_VALID) == 0) srvrlog(fs, "starts down"); +#endif /* DEBUG */ fs->fs_flags |= FSF_VALID; } if (oflags != fs->fs_flags && (fs->fs_flags & FSF_WANT)) @@ -535,15 +459,17 @@ nfs_keepalive_timeout(voidp v) */ np->np_ping = 0; } else { +#ifdef DEBUG if (np->np_ping > 1) dlog("%d pings to %s failed - at most %d allowed", np->np_ping, fs->fs_host, MAX_ALLOWED_PINGS); +#endif /* DEBUG */ } /* * New RPC xid, so any late responses to the previous ping * get ignored... */ - np->np_xid = XID_ALLOC(); + np->np_xid = NPXID_ALLOC(struct ); /* * Run keepalive again @@ -567,19 +493,19 @@ nfs_keepalive(voidp v) * Send an NFS ping to this node */ - if (ping_len[fs->fs_version - NFS_VERSION] == 0) - create_ping_payload(fs->fs_version); + if (ping_len == 0) + start_ping(fs->fs_version); /* * Queue the packet... */ error = fwd_packet(MK_RPC_XID(RPC_XID_NFSPING, np->np_xid), - ping_buf[fs->fs_version - NFS_VERSION], - ping_len[fs->fs_version - NFS_VERSION], + (voidp) ping_buf, + ping_len, fs->fs_ip, (struct sockaddr_in *) 0, - (voidp) ((long) np->np_xid), /* cast needed for 64-bit archs */ - nfs_keepalive_callback); + (voidp) ((long) np->np_xid), /* for 64-bit archs */ + nfs_pinged); /* * See if a hard error occurred @@ -592,7 +518,7 @@ nfs_keepalive(voidp v) np->np_ping = MAX_ALLOWED_PINGS; /* immediately down */ np->np_ttl = (time_t) 0; /* - * This causes an immediate call to nfs_keepalive_timeout + * This causes an immediate call to nfs_timed_out * whenever the server was thought to be up. * See +++ below. */ @@ -600,13 +526,15 @@ nfs_keepalive(voidp v) break; case 0: +#ifdef DEBUG dlog("Sent NFS ping to %s", fs->fs_host); +#endif /* DEBUG */ break; } /* * Back off the ping interval if we are not getting replies and - * the remote system is known to be down. + * the remote system is know to be down. */ switch (fs->fs_flags & (FSF_DOWN | FSF_VALID)) { case FSF_VALID: /* Up */ @@ -623,41 +551,73 @@ nfs_keepalive(voidp v) break; } +#ifdef DEBUG dlog("NFS timeout in %d seconds", fstimeo); +#endif /* DEBUG */ - fs->fs_cid = timeout(fstimeo, nfs_keepalive_timeout, (voidp) fs); + fs->fs_cid = timeout(fstimeo, nfs_timed_out, (voidp) fs); } -static void -start_nfs_pings(fserver *fs, int pingval) +int +nfs_srvr_port(fserver *fs, u_short *port, voidp wchan) { - if (pingval == 0) /* could be because ping mnt option not found */ - pingval = AM_PINGER; - /* if pings haven't been initalized, then init them for first time */ - if (fs->fs_flags & FSF_PING_UNINIT) { - fs->fs_flags &= ~FSF_PING_UNINIT; - plog(XLOG_INFO, "initializing %s's pinger to %d sec", fs->fs_host, pingval); - goto do_pings; + int error = -1; + if ((fs->fs_flags & FSF_VALID) == FSF_VALID) { + if ((fs->fs_flags & FSF_DOWN) == 0) { + nfs_private *np = (nfs_private *) fs->fs_private; + if (np->np_error == 0) { + *port = np->np_mountd; + error = 0; + } else { + error = np->np_error; + } + /* + * Now go get the port mapping again in case it changed. + * Note that it is used even if (np_mountd_inval) + * is True. The flag is used simply as an + * indication that the mountd may be invalid, not + * that it is known to be invalid. + */ + if (np->np_mountd_inval) + recompute_portmap(fs); + else + np->np_mountd_inval = TRUE; + } else { + error = EWOULDBLOCK; + } } + if (error < 0 && wchan && !(fs->fs_flags & FSF_WANT)) { + /* + * If a wait channel is supplied, and no + * error has yet occurred, then arrange + * that a wakeup is done on the wait channel, + * whenever a wakeup is done on this fs node. + * Wakeup's are done on the fs node whenever + * it changes state - thus causing control to + * come back here and new, better things to happen. + */ + fs->fs_flags |= FSF_WANT; + sched_task(wakeup_task, wchan, (voidp) fs); + } + return error; +} + - if ((fs->fs_flags & FSF_PINGING) && fs->fs_pinger == pingval) { - dlog("already running pings to %s", fs->fs_host); +static void +start_nfs_pings(fserver *fs, int pingval) +{ + if (fs->fs_flags & FSF_PINGING) { +#ifdef DEBUG + dlog("Already running pings to %s", fs->fs_host); +#endif /* DEBUG */ return; } - /* if got here, then we need to update the ping value */ - plog(XLOG_INFO, "changing %s's ping value from %d%s to %d%s", - fs->fs_host, - fs->fs_pinger, (fs->fs_pinger < 0 ? " (off)" : ""), - pingval, (pingval < 0 ? " (off)" : "")); - do_pings: - fs->fs_pinger = pingval; - if (fs->fs_cid) untimeout(fs->fs_cid); if (pingval < 0) { - srvrlog(fs, "wired up (pings disabled)"); + srvrlog(fs, "wired up"); fs->fs_flags |= FSF_VALID; fs->fs_flags &= ~FSF_DOWN; } else { @@ -674,18 +634,17 @@ fserver * find_nfs_srvr(mntfs *mf) { char *host = mf->mf_fo->opt_rhost; + char *nfs_proto = NULL; fserver *fs; int pingval; mntent_t mnt; nfs_private *np; - struct hostent *hp = NULL; - struct sockaddr_in *ip = NULL; + struct hostent *hp = 0; + struct sockaddr_in *ip; u_long nfs_version = 0; /* default is no version specified */ - u_long best_nfs_version = 0; - char *nfs_proto = NULL; /* no IP protocol either */ - int nfs_port = 0; - int nfs_port_opt = 0; - int fserver_is_down = 0; +#ifdef MNTTAB_OPT_PROTO + char *rfsname = mf->mf_fo->opt_rfs; +#endif /* MNTTAB_OPT_PROTO */ /* * Get ping interval from mount options. @@ -695,60 +654,49 @@ find_nfs_srvr(mntfs *mf) mnt.mnt_opts = mf->mf_mopts; pingval = hasmntval(&mnt, "ping"); - if (mf->mf_flags & MFF_NFS_SCALEDOWN) { - /* - * the server granted us a filehandle, but we were unable to mount it. - * therefore, scale down to NFSv2/UDP and try again. - */ - nfs_version = NFS_VERSION; - nfs_proto = "udp"; - plog(XLOG_WARNING, "find_nfs_srvr: NFS mount failed, trying again with NFSv2/UDP"); - mf->mf_flags &= ~MFF_NFS_SCALEDOWN; - } else { - /* - * Get the NFS version from the mount options. This is used - * to decide the highest NFS version to try. - */ + /* + * Get the NFS version from the mount options. This is used + * to decide the highest NFS version to try. + */ #ifdef MNTTAB_OPT_VERS - nfs_version = hasmntval(&mnt, MNTTAB_OPT_VERS); + nfs_version = hasmntval(&mnt, MNTTAB_OPT_VERS); #endif /* MNTTAB_OPT_VERS */ #ifdef MNTTAB_OPT_PROTO - { - char *proto_opt = hasmnteq(&mnt, MNTTAB_OPT_PROTO); - if (proto_opt) { - char **p; - for (p = protocols; *p; p++) - if (NSTREQ(proto_opt, *p, strlen(*p))) { - nfs_proto = *p; - break; - } - if (*p == NULL) - plog(XLOG_WARNING, "ignoring unknown protocol option for %s:%s", - host, mf->mf_fo->opt_rfs); - } + { + char *proto_opt = hasmnteq(&mnt, MNTTAB_OPT_PROTO); + if (proto_opt) { + char **p; + for (p = protocols; *p; p ++) + if (NSTREQ(proto_opt, *p, strlen(*p))) { + nfs_proto = *p; + break; + } + if (*p == NULL) + plog(XLOG_WARNING, "ignoring unknown protocol option for %s:%s", + host, rfsname); } + } #endif /* MNTTAB_OPT_PROTO */ #ifdef HAVE_NFS_NFSV2_H - /* allow overriding if nfsv2 option is specified in mount options */ - if (amu_hasmntopt(&mnt, "nfsv2")) { - nfs_version = NFS_VERSION;/* nullify any ``vers=X'' statements */ - nfs_proto = "udp"; /* nullify any ``proto=tcp'' statements */ - plog(XLOG_WARNING, "found compatibility option \"nfsv2\": set options vers=2,proto=udp for host %s", host); - } + /* allow overriding if nfsv2 option is specified in mount options */ + if (hasmntopt(&mnt, "nfsv2")) { + nfs_version = (u_long) 2; /* nullify any ``vers=X'' statements */ + nfs_proto = "udp"; /* nullify any ``proto=tcp'' statements */ + plog(XLOG_WARNING, "found compatiblity option \"nfsv2\": set options vers=2,proto=udp for host %s", host); + } #endif /* HAVE_NFS_NFSV2_H */ - /* check if we've globally overridden the NFS version/protocol */ - if (gopt.nfs_vers) { - nfs_version = gopt.nfs_vers; - plog(XLOG_INFO, "find_nfs_srvr: force NFS version to %d", - (int) nfs_version); - } - if (gopt.nfs_proto) { - nfs_proto = gopt.nfs_proto; - plog(XLOG_INFO, "find_nfs_srvr: force NFS protocol transport to %s", nfs_proto); - } + /* check if we globally overridden the NFS version/protocol */ + if (gopt.nfs_vers) { + nfs_version = gopt.nfs_vers; + plog(XLOG_INFO, "find_nfs_srvr: force NFS version to %d", + (int) nfs_version); + } + if (gopt.nfs_proto) { + nfs_proto = gopt.nfs_proto; + plog(XLOG_INFO, "find_nfs_srvr: force NFS protocol transport to %s", nfs_proto); } /* @@ -771,148 +719,72 @@ find_nfs_srvr(mntfs *mf) case AF_INET: ip = ALLOC(struct sockaddr_in); memset((voidp) ip, 0, sizeof(*ip)); - /* as per POSIX, sin_len need not be set (used internally by kernel) */ ip->sin_family = AF_INET; memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr)); + + ip->sin_port = htons(NFS_PORT); break; default: - plog(XLOG_USER, "No IP address for host %s", host); - goto no_dns; + ip = 0; + break; } } else { plog(XLOG_USER, "Unknown host: %s", host); - goto no_dns; + ip = 0; } /* - * This may not be the best way to do things, but it really doesn't make - * sense to query a file server which is marked as 'down' for any - * version/proto combination. + * Get the NFS Version, and verify server is up. Probably no + * longer need to start server down below. */ - ITER(fs, fserver, &nfs_srvr_list) { - if (FSRV_ISDOWN(fs) && - STREQ(host, fs->fs_host)) { - plog(XLOG_WARNING, "fileserver %s is already hung - not running NFS proto/version discovery", host); - fs->fs_refc++; - if (ip) - XFREE(ip); - return fs; - } - } - - /* - * Get the NFS Version, and verify server is up. - * If the client only supports NFSv2, hardcode it but still try to - * contact the remote portmapper to see if the service is running. - */ -#ifndef HAVE_FS_NFS3 - nfs_version = NFS_VERSION; - nfs_proto = "udp"; - plog(XLOG_INFO, "The client supports only NFS(2,udp)"); -#endif /* not HAVE_FS_NFS3 */ - - - if (amu_hasmntopt(&mnt, MNTTAB_OPT_PUBLIC)) { - /* - * Use WebNFS to obtain file handles. - */ - mf->mf_flags |= MFF_WEBNFS; - plog(XLOG_INFO, "%s option used, NOT contacting the portmapper on %s", - MNTTAB_OPT_PUBLIC, host); - /* - * Prefer NFSv3/tcp if the client supports it (cf. RFC 2054, 7). - */ - if (!nfs_version) { + if (ip) { #ifdef HAVE_FS_NFS3 - nfs_version = NFS_VERSION3; -#else /* not HAVE_FS_NFS3 */ - nfs_version = NFS_VERSION; -#endif /* not HAVE_FS_NFS3 */ - plog(XLOG_INFO, "No NFS version specified, will use NFSv%d", - (int) nfs_version); - } - if (!nfs_proto) { -#if defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) - nfs_proto = "tcp"; -#else /* not defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ - nfs_proto = "udp"; -#endif /* not defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ - plog(XLOG_INFO, "No NFS protocol transport specified, will use %s", - nfs_proto); - } - } else { /* * Find the best combination of NFS version and protocol. * When given a choice, use the highest available version, * and use TCP over UDP if available. */ - if (check_pmap_up(host, ip)) { - if (nfs_proto) { - best_nfs_version = get_nfs_version(host, ip, nfs_version, nfs_proto); - nfs_port = ip->sin_port; - } -#ifdef MNTTAB_OPT_PROTO - else { - u_int proto_nfs_version; - char **p; - - for (p = protocols; *p; p++) { - proto_nfs_version = get_nfs_version(host, ip, nfs_version, *p); - - if (proto_nfs_version > best_nfs_version) { - best_nfs_version = proto_nfs_version; - nfs_proto = *p; - nfs_port = ip->sin_port; - } + if (nfs_proto) + nfs_version = get_nfs_version(host, ip, nfs_version, nfs_proto); + else { + int best_nfs_version = 0; + int proto_nfs_version; + char **p; + + for (p = protocols; *p; p++) { + proto_nfs_version = get_nfs_version(host, ip, nfs_version, *p); + + if (proto_nfs_version > best_nfs_version) { + best_nfs_version = proto_nfs_version; + nfs_proto = *p; } } -#endif /* MNTTAB_OPT_PROTO */ - } else { - plog(XLOG_INFO, "portmapper service not running on %s", host); + nfs_version = best_nfs_version; } - /* use the portmapper results only nfs_version is not set yet */ - if (!best_nfs_version) { + if (!nfs_version) { /* * If the NFS server is down or does not support the portmapper call * (such as certain Novell NFS servers) we mark it as version 2 and we - * let the nfs code deal with the case when it is down. If/when the - * server comes back up and it can support NFSv3 and/or TCP, it will + * let the nfs code deal with the case that is down. If when the + * server comes back up, it can support NFS V.3 and/or TCP, it will * use those. */ - if (nfs_version == 0) { - nfs_version = NFS_VERSION; - nfs_proto = "udp"; - } - plog(XLOG_INFO, "NFS service not running on %s", host); - fserver_is_down = 1; - } else { - if (nfs_version == 0) - nfs_version = best_nfs_version; - plog(XLOG_INFO, "Using NFS version %d, protocol %s on host %s", - (int) nfs_version, nfs_proto, host); + nfs_version = NFS_VERSION; + nfs_proto = "udp"; } +#else /* not HAVE_FS_NFS3 */ + nfs_version = NFS_VERSION; +#endif /* not HAVE_FS_NFS3 */ } - /* - * Determine the NFS port. - * - * A valid "port" mount option overrides anything else. - * If the port has been determined from the portmapper, use that. - * Default to NFS_PORT otherwise (cf. RFC 2054, 3). - */ - nfs_port_opt = hasmntval(&mnt, MNTTAB_OPT_PORT); - if (nfs_port_opt > 0) - nfs_port = htons(nfs_port_opt); - if (!nfs_port) - nfs_port = htons(NFS_PORT); + if (!nfs_proto) + nfs_proto = "udp"; - dlog("find_nfs_srvr: using port %d for nfs on %s", - (int) ntohs(nfs_port), host); - ip->sin_port = nfs_port; + plog(XLOG_INFO, "Using NFS version %d, protocol %s on host %s", + (int) nfs_version, nfs_proto, host); -no_dns: /* * Try to find an existing fs server structure for this host. * Note that differing versions or protocols have their own structures. @@ -924,46 +796,16 @@ no_dns: nfs_version == fs->fs_version && STREQ(nfs_proto, fs->fs_proto)) { /* - * fill in the IP address -- this is only needed - * if there is a chance an IP address will change - * between mounts. - * Mike Mitchell, mcm@unx.sas.com, 09/08/93 - */ - if (hp && fs->fs_ip && - memcmp((voidp) &fs->fs_ip->sin_addr, - (voidp) hp->h_addr, - sizeof(fs->fs_ip->sin_addr)) != 0) { - struct in_addr ia; - char *old_ipaddr, *new_ipaddr; - old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr)); - memmove((voidp) &ia, (voidp) hp->h_addr, sizeof(struct in_addr)); - new_ipaddr = inet_ntoa(ia); /* ntoa uses static buf */ - plog(XLOG_WARNING, "fileserver %s changed ip: %s -> %s", - fs->fs_host, old_ipaddr, new_ipaddr); - XFREE(old_ipaddr); - flush_nfs_fhandle_cache(fs); - memmove((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)); - } - - /* - * If the new file systems doesn't use WebNFS, the nfs pings may - * try to contact the portmapper. - */ - if (!(mf->mf_flags & MFF_WEBNFS)) - fs->fs_flags &= ~FSF_WEBNFS; - - /* check if pingval needs to be updated/set/reset */ - start_nfs_pings(fs, pingval); - - /* - * Following if statement from Mike Mitchell <mcm@unx.sas.com> - * Initialize the ping data if we aren't pinging now. The np_ttl and - * np_ping fields are especially important. + * following if statement from Mike Mitchell + * <mcm@unx.sas.com> + * Initialize the ping data if we aren't pinging + * now. The np_ttl and np_ping fields are + * especially important. */ if (!(fs->fs_flags & FSF_PINGING)) { np = (nfs_private *) fs->fs_private; np->np_mountd_inval = TRUE; - np->np_xid = XID_ALLOC(); + np->np_xid = NPXID_ALLOC(struct ); np->np_error = -1; np->np_ping = 0; /* @@ -971,12 +813,18 @@ no_dns: * after MAX_ALLOWED_PINGS of the fast variety * have failed. */ - np->np_ttl = MAX_ALLOWED_PINGS * FAST_NFS_PING + clocktime(NULL) - 1; - start_nfs_pings(fs, pingval); - if (fserver_is_down) - fs->fs_flags |= FSF_VALID | FSF_DOWN; + np->np_ttl = MAX_ALLOWED_PINGS * FAST_NFS_PING + clocktime() - 1; } + /* + * fill in the IP address -- this is only needed + * if there is a chance an IP address will change + * between mounts. + * Mike Mitchell, mcm@unx.sas.com, 09/08/93 + */ + if (hp && fs->fs_ip) + memmove((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)); + start_nfs_pings(fs, pingval); fs->fs_refc++; if (ip) XFREE(ip); @@ -1005,32 +853,29 @@ no_dns: mf->mf_flags |= MFF_ERROR; mf->mf_error = ENOENT; } - if (mf->mf_flags & MFF_WEBNFS) - fs->fs_flags |= FSF_WEBNFS; fs->fs_version = nfs_version; fs->fs_proto = nfs_proto; fs->fs_type = MNTTAB_TYPE_NFS; fs->fs_pinger = AM_PINGER; - fs->fs_flags |= FSF_PING_UNINIT; /* pinger hasn't been initialized */ np = ALLOC(struct nfs_private); memset((voidp) np, 0, sizeof(*np)); np->np_mountd_inval = TRUE; - np->np_xid = XID_ALLOC(); + np->np_xid = NPXID_ALLOC(struct ); np->np_error = -1; /* * Initially the server will be deemed dead after * MAX_ALLOWED_PINGS of the fast variety have failed. */ - np->np_ttl = clocktime(NULL) + MAX_ALLOWED_PINGS * FAST_NFS_PING - 1; + np->np_ttl = clocktime() + MAX_ALLOWED_PINGS * FAST_NFS_PING - 1; fs->fs_private = (voidp) np; fs->fs_prfree = (void (*)(voidp)) free; - if (!FSRV_ERROR(fs)) { - /* start of keepalive timer, first updating pingval */ + if (!(fs->fs_flags & FSF_ERROR)) { + /* + * Start of keepalive timer + */ start_nfs_pings(fs, pingval); - if (fserver_is_down) - fs->fs_flags |= FSF_VALID | FSF_DOWN; } /* diff --git a/contrib/amd/amq/amq.8 b/contrib/amd/amq/amq.8 index 203a529..cd023a1 100644 --- a/contrib/amd/amq/amq.8 +++ b/contrib/amd/amq/amq.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,225 +38,183 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: amq.8,v 1.15.2.1 2006/01/02 18:48:24 ezk Exp $ +.\" $Id: amq.8,v 1.3.2.8 2004/01/06 03:15:16 ezk Exp $ +.\" $FreeBSD$ .\" -.TH AMQ 8 "25 April 1989" -.SH NAME -amq \- automounter query tool -.SH SYNOPSIS -.B amq -[ -.BI \-fmpsvwHTU -] [ -.BI \-h " hostname" -] [ -.BI \-l " log_file" -] [ -.BI \-x " log_options" -] [ -.BI \-D " debug_options" -] [ -.BI \-P " program_number" -] [[ -.B \-u -] -.I directory .\|.\|. -] -.SH DESCRIPTION -.B Amq -provides a simple way of determining the current state of -.B amd +.Dd March 16, 1991 +.Dt AMQ 8 +.Os +.Sh NAME +.Nm amq +.Nd automounter query tool +.Sh SYNOPSIS +.Nm amq +.Op Fl fmpsuvTU +.Op Fl h Ar hostname +.Op Fl l Ar log_file +.Op Fl x Ar log_options +.Op Fl D Ar debug_options +.Op Fl M Ar mountmap_entry +.Op Fl P Ar program_number +.Op Ar directory +.Ar ... +.Sh DESCRIPTION +.Nm Amq +provides a simple way of determining the current state of the +.Xr amd 8 program. Communication is by -.SM RPC. -Three modes of operation are supported by the current protocol. By default -a list of mount points and auto-mounted filesystems is output. An -alternative host can be specified using the -.I \-h +.Tn RPC . +Three modes of operation are supported by the current protocol. +By default a list of mount points and auto-mounted file systems +is output. +An alternative host can be specified using the +.Fl h option. -.LP -If -.I directory -names are given, as output by default, then per-filesystem -information is displayed. -.SH OPTIONS - -.TP -.B \-f -Ask the automounter to flush the internal caches and reload all the maps. - -.TP -.BI \-h " hostname" -Specify an alternate host to query. By default the local host is used. In -an -.SM HP-UX -cluster, the root server is queried by default, since that is the system on -which the automounter is normally run. - -.TP -.BI \-l " log_file" +.Pp +If directory names are given, as output by default, +then per file system information is displayed. +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl f +Request automounter to flush the internal caches. +.It Fl h Ar hostname +Query alternate host +.Ar hostname . +By default the local host is used. +In an +.Tn HP-UX +cluster, the root server is queried by default, since +that is the system on which the automounter is normally run. +.It Fl l Ar log_file Tell amd to use -.I log_file -as the log file name. For security reasons, this must be the same log file -which amd used when started. This option is therefore only useful to -refresh amd's open file handle on the log file, so that it can be rotated -and compressed via daily cron jobs. - -.TP -.B \-m -Ask the automounter to provide a list of mounted filesystems, including the -number of references to each filesystem and any error which occurred while -mounting. - -.TP -.B \-p -Return the process ID of the remote or locally running amd. Useful when you -need to send a signal to the local amd process, and would rather not have to -search through the process table. This option is used in the -.I ctl-amd +.Ar log_file +as the log file name. +For security reasons, this must be the same log file which +.Nm amd +used when started. +This option is therefore only useful to +refresh +.Nm amd Ns \'s +open file handle on the log file, so that it can be rotated and compressed via +daily cron jobs. +.It Fl m +Request the automounter to provide a list of mounted file systems, +including the number of references to each file system and any error +which occurred while mounting. +.It Fl p +Return the process ID of the remote or locally running +.Nm amd . +Useful when you need to send a signal to the local +.Nm amd +process, and would rather not have to search through the process table. +This +option is used in the +.Pa ctl-amd script. - -.TP -.B \-s -Ask the automounter to provide system-wide mount statistics. - -.TP -.B \-u -Ask the automounter to unmount the filesystems named in -.I directory -instead of providing -information about them. Unmounts are requested, not forced. They merely -cause the mounted filesystem to timeout, which will be picked up by -.BR amd 's +.It Fl s +Request the automounter to provide system-wide mount statistics. +.It Fl u +Request the automounter to unmount the named file systems +instead of providing information about them. +Unmounts are requested, +not forced. +They merely cause the mounted file system to timeout, +which will be picked up by +.Nm amd Ns \'s main scheduler thus causing the normal timeout action to be taken. - -.TP -.B \-v -Ask the automounter for its version information. This is a subset of the -information output by -.BR amd 's -.I -v +.It Fl v +Request the automounter to provide version information. +This is a subset +of the information provided by +.Nm amd Ns \'s Fl v option. - -.TP -.B \-w -Translate a full pathname as returned by -.IR getpwd (3) -into a short -.B Amd -pathname that goes through its mount points. This option requires that -.B Amd -is running. - -.TP -.BI \-x " log_options" +.It Fl x Ar log_options Ask the automounter to use the logging options specified in -.I log_options +.Ar log_options from now on. - -.TP -.BI \-D " log_options" +.It Fl D Ar debug_options Ask the automounter to use the debugging options specified in -.I debug_options +.Ar debug_options from now on. - -.TP -.B \-H -Display short usage message. - -.TP -.BI \-P " program_number" -Contact an alternate running amd that had registered itself on a different -RPC -.I program_number -and apply all other operations to that instance of the automounter. This is -useful when you run multiple copies of amd, and need to manage each -one separately. If not specified, amq will use the default program number -for amd, 300019. For security reasons, the only alternate program numbers -amd can use range from 300019 to 300029, inclusive. - -.TP -.B \-T +.It Fl M +Pass a mount map entry to +.Nm amd +and wait for it to be evaluated, possibly causing a mount. +This option is highly insecure. +By default, +.Nm amd +and +.Nm amq +do not support it. +It is necessary to configure +.Nm am-utils +with +.Ar --enable-amq-mount +to enable this option. +.It Fl P Ar program_number +Contact an alternate running +.Nm amd +that had registered itself on a different RPC +.Ar program_number +and apply all other operations to that instance of the automounter. +This is useful when running multiple copies of +.Nm amd , +and need to manage each one separately. +If not specified, +.Nm amq +will use the default program number for +.Nm amd , +300019. +For security reasons, the only alternate program numbers +.Nm amd +can use range from 300019 to 300029, inclusive. +.It Fl T Contact -.B amd -using the TCP transport only. Normally -.B amq -will try TCP, and if that failed, will try UDP. - -.TP -.B \-U +.Nm amd +using the TCP transport only. +Normally +.Nm amq +will try TCP, and if that fails, will try UDP. +.It Fl U Contact -.B amd -using UDP (connectionless) transport only. Normally -.B amq -will try TCP, and if that failed, will try UDP. - -.SH FILES -.TP 20 -.B amq.x -.SM RPC +.Nm amd +using UDP (connectionless) transport only. +Normally +.Nm amq +will try TCP, and if that fails, will try UDP. +.El +.Sh FILES +.Bl -tag -width amq.x -compact +.It Pa amq.x +.Tn RPC protocol description. - -.SH CAVEATS -.B Amq +.El +.Sh CAVEATS +.Nm Amq uses a Sun registered -.SM RPC +.Tn RPC program number (300019 decimal) which may not -be in the /etc/rpc database. -.PP -If the TCP wrappers library is available, and the -.B use_tcpwrappers -global -.B amd.conf -option is set to ``yes'', then -.B amd -will verify that the host running -.B amq -is authorized to connect. The -.I amd -service name must used in the -.B /etc/hosts.allow -and -.B /etc/hosts.deny -files. For example, to allow only localhost to connect to -.B amd, -add this line to -.B /etc/hosts.allow: -.PP -.RS -amd: localhost -.RE -.PP -and this line to -.B /etc/hosts.deny: -.PP -.RS -amd: ALL -.RE - -.SH "SEE ALSO" -.BR amd (8), -.BR ctl-amd (8), -.BR amd.conf (5), -.BR hosts_access (5). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" - -.SH AUTHORS -Jan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK. -.P -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +be in the +.Pa /etc/rpc +database. +.Sh SEE ALSO +.Xr amd.conf 5 , +.Xr amd 8 +.Sh HISTORY +.Nm Amq +first appeared in +.Bx 4.4 . +.Sh AUTHORS +.An Jan-Simon Pendry Aq jsp@doc.ic.ac.uk , +Department of Computing, Imperial College, London, UK. +.Pp +.An Erez Zadok Aq ezk@cs.columbia.edu , +Department of Computer Science, Columbia University, New York, USA. +.Pp +.An Other authors and contributors to +.Nm am-utils +are listed in the +.Nm AUTHORS +file distributed with +.Nm am-utils . diff --git a/contrib/amd/amq/amq.c b/contrib/amd/amq/amq.c index 2379b62..d9828ac 100644 --- a/contrib/amd/amq/amq.c +++ b/contrib/amd/amq/amq.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,15 +36,32 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/amq/amq.c + * $Id: amq.c,v 1.7.2.9 2004/01/06 03:15:16 ezk Exp $ * */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + /* * Automounter query tool */ +#ifndef lint +char copyright[] = "\ +@(#)Copyright (c) 1997-2004 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.9 2004/01/06 03:15:16 ezk Exp $"; +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* __GNUC__ < 2 */ +#endif /* not lint */ + #ifdef HAVE_CONFIG_H # include <config.h> #endif /* HAVE_CONFIG_H */ @@ -101,8 +118,8 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) case Full: { - struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime)); - printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%04d %02d:%02d:%02d\n", + struct tm *tp = localtime((time_t *) &mt->mt_mounttime); + printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%02d\n", *dwid, *dwid, *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ *twid, *twid, @@ -118,16 +135,16 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) mt->mt_readlink, mt->mt_statfs, + tp->tm_year > 99 ? tp->tm_year - 100 : tp->tm_year, tp->tm_mon + 1, tp->tm_mday, - tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec); } break; case Stats: { - struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime)); - printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%04d\n", + struct tm *tp = localtime((time_t *) &mt->mt_mounttime); + printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%02d\n", *dwid, *dwid, *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ @@ -138,8 +155,8 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) mt->mt_readlink, mt->mt_statfs, + tp->tm_year > 99 ? tp->tm_year - 100 : tp->tm_year, tp->tm_mon + 1, tp->tm_mday, - tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec); } break; @@ -167,7 +184,7 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) * Display a pwd data */ static void -show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag) +show_pwd(amq_mount_tree *mt, char *path, int *flag) { int len; @@ -175,13 +192,13 @@ show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag) len = strlen(mt->mt_mountpoint); if (NSTREQ(path, mt->mt_mountpoint, len) && !STREQ(mt->mt_directory, mt->mt_mountpoint)) { - char buf[MAXPATHLEN+1]; /* must be same size as 'path' */ - xstrlcpy(buf, mt->mt_directory, sizeof(buf)); - xstrlcat(buf, &path[len], sizeof(buf)); - xstrlcpy(path, buf, l); + char buf[MAXPATHLEN+1]; + strcpy(buf, mt->mt_directory); + strcat(buf, &path[len]); + strcpy(path, buf); *flag = 1; } - show_pwd(mt->mt_next, path, l, flag); + show_pwd(mt->mt_next, path, flag); mt = mt->mt_child; } } @@ -204,7 +221,7 @@ show_mt(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *pwid) static void show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twid) { - u_int i; + int i; switch (e) { @@ -237,7 +254,14 @@ show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twi mi->mi_up > 0 ? "up" : mi->mi_up < 0 ? "starting" : "down"); if (mi->mi_error > 0) { - printf(" (%s)", strerror(mi->mi_error)); + if (mi->mi_error < sys_nerr) +#ifdef HAVE_STRERROR + printf(" (%s)", strerror(mi->mi_error)); +#else /* not HAVE_STRERROR */ + printf(" (%s)", sys_errlist[mi->mi_error]); +#endif /* not HAVE_STRERROR */ + else + printf(" (Error %d)", mi->mi_error); } else if (mi->mi_error < 0) { fputs(" (in progress)", stdout); } @@ -434,8 +458,7 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ am_get_progname(), server); exit(1); } - memset(&server_addr, 0, sizeof(server_addr)); - /* as per POSIX, sin_len need not be set (used internally by kernel) */ + memset(&server_addr, 0, sizeof server_addr); server_addr.sin_family = AF_INET; if (hp) { memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr, @@ -541,8 +564,7 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ char *wd = getcwd(path, MAXPATHLEN+1); amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); amq_mount_tree_p mt; - u_int i; - int flag; + int i, flag; if (!wd) { perror("getcwd"); @@ -552,7 +574,7 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ mt = mlp->amq_mount_tree_list_val[i]; while (1) { flag = 0; - show_pwd(mt, path, sizeof(path), &flag); + show_pwd(mt, path, &flag); if (!flag) { printf("%s\n", path); break; @@ -666,9 +688,8 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ if (mlp) { enum show_opt e = Calc; int mwid = 0, dwid = 0, pwid = 0; - while (e != ShowDone) { - u_int i; + int i; for (i = 0; i < mlp->amq_mount_tree_list_len; i++) { show_mt(mlp->amq_mount_tree_list_val[i], e, &mwid, &dwid, &pwid); diff --git a/contrib/amd/amq/pawd.1 b/contrib/amd/amq/pawd.1 index 73a16b5..954bbab 100644 --- a/contrib/amd/amq/pawd.1 +++ b/contrib/amd/amq/pawd.1 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,53 +38,46 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: pawd.1,v 1.9.2.1 2006/01/02 18:48:24 ezk Exp $ +.\" $Id: pawd.1,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $ +.\" $FreeBSD$ .\" -.TH PAWD 1 "6 Jan 1998" -.SH NAME -pawd \- print automounter working directory -.SH SYNOPSIS -.B pawd -[ -.I path ... -] -.SH DESCRIPTION -.LP -.B pawd +.Dd January 6, 1998 +.Dt PAWD 1 +.Os +.Sh NAME +.Nm pawd +.Nd print automounter working directory +.Sh SYNOPSIS +.Nm +.Op Ar path ... +.Sh DESCRIPTION +.Nm is used to print the current working directory, adjusted to reflect proper paths that can be reused to go through the automounter for the shortest -possible path. In particular, the path printed back does not include any +possible path. +In particular, the path printed back does not include any of -.BR Amd 's -local mount points. Using them is unsafe, because -.B Amd +.Nm Amd Ns \'s +local mount points. +Using them is unsafe, because +.Nm Amd may unmount managed file systems from the mount points, and thus including them in paths may not always find the files within. -.P +.Pp Without any arguments, -.B pawd -will print the automounter adjusted current working directory. With any -number of arguments, it will print the adjusted path of each one of the +.Nm +will print the automounter adjusted current working directory. +With any +number of arguments, it will print the adjusted +.Ar path +of each one of the arguments. -.SH "SEE ALSO" -.BR amd (8), -.BR amq (8), -.BR pwd (1). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH AUTHORS -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.Sh SEE ALSO +.Xr pwd 1 , +.Xr amd 8 , +.Xr amq 8 +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 3.0 . diff --git a/contrib/amd/conf/hn_dref/hn_dref_default.h b/contrib/amd/conf/hn_dref/hn_dref_default.h deleted file mode 100644 index d495ea8..0000000 --- a/contrib/amd/conf/hn_dref/hn_dref_default.h +++ /dev/null @@ -1,2 +0,0 @@ -/* $srcdir/conf/hn_dref/hn_dref_default.h */ -#define NFS_HN_DREF(dst, src) (dst) = (src) diff --git a/contrib/amd/conf/mount/mount_default.c b/contrib/amd/conf/mount/mount_default.c deleted file mode 100644 index 1bdf522..0000000 --- a/contrib/amd/conf/mount/mount_default.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * 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: mount_default.c,v 1.1.2.3 2002/12/27 22:44:48 ezk Exp $ - */ - -/* - * Default mount helper (currently empty) - */ diff --git a/contrib/amd/conf/mount/mount_freebsd3.c b/contrib/amd/conf/mount/mount_freebsd3.c deleted file mode 100644 index 5888ed9..0000000 --- a/contrib/amd/conf/mount/mount_freebsd3.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1997-1998 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 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. - * - * %W% (Berkeley) %G% - * - * $Id: mount_freebsd3.c,v 5.2.2.1 1992/02/09 15:10:08 jsp beta $ - * - */ - -/* - * FreeBSD 3.x (as of snapshot 3.0-980311-SNAP) Mount helper - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif /* HAVE_CONFIG_H */ -#include <am_defs.h> -#include <amu.h> - -/* - * Map from conventional mount arguments - * to FreeBSD 3.0 style arguments. - */ -int -mount_freebsd3(MTYPE_TYPE type, const char *dir, int flags, voidp data) -{ - char const *namelist[] = INITMOUNTNAMES; - - return mount(namelist[type], - dir, - flags, - data); -} diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_aix5_1.h b/contrib/amd/conf/nfs_prot/nfs_prot_aix5_1.h deleted file mode 100644 index e7fb478..0000000 --- a/contrib/amd/conf/nfs_prot/nfs_prot_aix5_1.h +++ /dev/null @@ -1,315 +0,0 @@ -/* - * 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. - * 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: nfs_prot_aix5_1.h,v 1.1.2.3 2002/12/27 22:44:53 ezk Exp $ - * - */ - -#ifndef _AMU_NFS_PROT_H -#define _AMU_NFS_PROT_H - - -/* - * AIX 5.1 has a different aix51_nfs_args structure, hence the separate header. - */ - -#ifdef HAVE_RPCSVC_NFS_PROT_H -# include <rpcsvc/nfs_prot.h> -#endif /* HAVE_RPCSVC_NFS_PROT_H */ -#ifdef HAVE_NFS_NFSV2_H -# include <nfs/nfsv2.h> -#endif /* HAVE_NFS_NFSV2_H */ -#ifdef HAVE_NFS_RPCV2_H -# include <nfs/rpcv2.h> -#endif /* HAVE_NFS_RPCV2_H */ -#ifdef HAVE_SYS_FS_NFS_H -# include <sys/fs/nfs.h> -#endif /* HAVE_SYS_FS_NFS_H */ -#ifdef HAVE_RPCSVC_MOUNT_H -# include <rpcsvc/mount.h> -#endif /* HAVE_RPCSVC_MOUNT_H */ - - -/* - * MACROS - */ - -#ifndef MNTPATHLEN -# define MNTPATHLEN 1024 -#endif /* not MNTPATHLEN */ -#ifndef MNTNAMLEN -# define MNTNAMLEN 255 -#endif /* not MNTNAMLEN */ - -/* map field names */ -#define ex_dir ex_name -#define gr_name g_name -#define gr_next g_next -#define ml_directory ml_path -#define ml_hostname ml_name -#define ml_next ml_nxt - -#define dr_drok_u diropres -#define ca_attributes attributes -#define ca_where where -#define da_fhandle dir -#define da_name name -#define dl_entries entries -#define dl_eof eof -#define dr_status status -#define dr_u diropres_u -#define drok_attributes attributes -#define drok_fhandle file -#define fh_data data -#define la_fhandle from -#define la_to to -#define na_atime atime -#define na_blocks blocks -#define na_blocksize blocksize -#define na_ctime ctime -#define na_fileid fileid -#define na_fsid fsid -#define na_gid gid -#define na_mode mode -#define na_mtime mtime -#define na_nlink nlink -#define na_rdev rdev -#define na_size size -#define na_type type -#define na_uid uid -#define ne_cookie cookie -#define ne_fileid fileid -#define ne_name name -#define ne_nextentry nextentry -#define ns_attr_u attributes -#define ns_status status -#define ns_u attrstat_u -#define nt_seconds seconds -#define nt_useconds useconds -#define ra_count count -#define ra_fhandle file -#define ra_offset offset -#define ra_totalcount totalcount -#define raok_attributes attributes -#define raok_len_u data_len -#define raok_u data -#define raok_val_u data_val -#define rda_cookie cookie -#define rda_count count -#define rda_fhandle dir -#define rdr_reply_u reply -#define rdr_status status -#define rdr_u readdirres_u -#define rlr_data_u data -#define rlr_status status -#define rlr_u readlinkres_u -#define rna_from from -#define rna_to to -#define rr_reply_u reply -#define rr_status status -#define rr_u readres_u -#define sa_atime atime -#define sa_gid gid -#define sa_mode mode -#define sa_mtime mtime -#define sa_size size -#define sa_uid uid -#define sag_attributes attributes -#define sag_fhandle file -#define sfr_reply_u reply -#define sfr_status status -#define sfr_u statfsres_u -#define sfrok_bavail bavail -#define sfrok_bfree bfree -#define sfrok_blocks blocks -#define sfrok_bsize bsize -#define sfrok_tsize tsize -#define sla_attributes attributes -#define sla_from from -#define sla_to to -#define wra_beginoffset beginoffset -#define wra_fhandle file -#define wra_len_u data_len -#define wra_offset offset -#define wra_totalcount totalcount -#define wra_u data -#define wra_val_u data_val - - -/* - * TYPEDEFS: - */ -typedef char *dirpath; -typedef char *name; -typedef struct exports *exports; -typedef struct exports exportnode; -typedef struct groups *groups; -typedef struct groups groupnode; -typedef struct mountlist *mountlist; - -typedef attrstat nfsattrstat; -typedef createargs nfscreateargs; -typedef dirlist nfsdirlist; -typedef diropargs nfsdiropargs; -typedef diropokres nfsdiropokres; -typedef diropres nfsdiropres; -typedef entry nfsentry; -typedef fattr nfsfattr; -typedef ftype nfsftype; -typedef linkargs nfslinkargs; -typedef readargs nfsreadargs; -typedef readdirargs nfsreaddirargs; -typedef readdirres nfsreaddirres; -typedef readlinkres nfsreadlinkres; -typedef readokres nfsreadokres; -typedef readres nfsreadres; -typedef renameargs nfsrenameargs; -typedef sattr nfssattr; -typedef sattrargs nfssattrargs; -typedef statfsokres nfsstatfsokres; -typedef statfsres nfsstatfsres; -typedef symlinkargs nfssymlinkargs; -typedef writeargs nfswriteargs; - - -/* - * EXTERNALS: - */ - - -/* - * STRUCTURES: - */ - -/* - * AIX 5.1 has NFS V3, but it is undefined in the header files. - * so I define everything that's needed for NFS V3 here. - */ -#ifdef MNT_NFS3 - -#define FHSIZE3 64 /* size in bytes of a file handle (v3) */ -#define NFS3_FHSIZE 64 -#define MOUNTVERS3 ((unsigned long)(3)) -#define NFS_V3 ((unsigned long)(3)) - -#if 0 -struct nfs_fh3 { - u_int len; - char val[64]; /* !!! */ -}; -#endif - -struct aix51_nfs_args { - struct sockaddr_in addr; /* server address and port */ - caddr_t u0; /* ??? UNKNOWN ??? */ - unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */ - char *hostname; /* pointer to hostname? */ - char *netname; /* pointer to netname? */ - caddr_t fh; /* pointer to NFS v3 fh? */ - unsigned long u5; /* IBM sux, IBM sux, IBM sux... */ - unsigned long flags; /* flags */ - unsigned long wsize; /* wsize */ - unsigned long rsize; /* rsize */ - unsigned long timeo; /* timeo */ - unsigned long retrans; /* retrans */ - unsigned long acregmin; /* acregmin */ - unsigned long acregmax; /* acregmax */ - unsigned long acdirmin; /* acdirmin */ - unsigned long acdirmax; /* acdirmax */ - unsigned long u15; /* ??? UNKNOWN ??? */ - struct pathcnf *pathconf; /* pathconf */ -}; - -typedef struct { - u_int fhandle3_len; - char *fhandle3_val; -} fhandle3; - -enum mountstat3 { - MNT3_OK = 0, - MNT3ERR_PERM = 1, - MNT3ERR_NOENT = 2, - MNT3ERR_IO = 5, - MNT3ERR_ACCES = 13, - MNT3ERR_NOTDIR = 20, - MNT3ERR_INVAL = 22, - MNT3ERR_NAMETOOLONG = 63, - MNT3ERR_NOTSUPP = 10004, - MNT3ERR_SERVERFAULT = 10006 -}; -typedef enum mountstat3 mountstat3; - -struct mountres3_ok { - fhandle3 fhandle; - struct { - u_int auth_flavors_len; - int *auth_flavors_val; - } auth_flavors; -}; -typedef struct mountres3_ok mountres3_ok; - -struct mountres3 { - mountstat3 fhs_status; - union { - mountres3_ok mountinfo; - } mountres3_u; -}; -typedef struct mountres3 mountres3; - -struct nfs_fh3 { - u_int fh3_length; - union nfs_fh3_u { - struct nfs_fh3_i { - fhandle_t fh3_i; - } nfs_fh3_i; - char data[NFS3_FHSIZE]; - } fh3_u; -}; -typedef struct nfs_fh3 nfs_fh3; - -#endif /* MNT_NFS3 */ - -/* - * EXTERNALS: - */ -extern bool_t xdr_groups(XDR *xdrs, groups *objp); -extern char *yperr_string (int incode); - -#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_darwin.h b/contrib/amd/conf/nfs_prot/nfs_prot_darwin.h deleted file mode 100644 index 9ef1e72..0000000 --- a/contrib/amd/conf/nfs_prot/nfs_prot_darwin.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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. - * 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: nfs_prot_darwin.h,v 1.1.2.4 2002/12/27 22:44:54 ezk Exp $ - * - */ - -#ifndef _AMU_NFS_PROT_H -#define _AMU_NFS_PROT_H - -#ifdef HAVE_RPCSVC_NFS_PROT_H -# include <rpcsvc/nfs_prot.h> -#endif /* HAVE_RPCSVC_NFS_PROT_H */ -#ifdef HAVE_NFS_RPCV2_H -# include <nfs/rpcv2.h> -#endif /* HAVE_NFS_RPCV2_H */ -#ifdef HAVE_NFS_NFS_H -# include <nfs/nfs.h> -#endif /* HAVE_NFS_NFS_H */ -#ifdef HAVE_UFS_UFS_UFSMOUNT_H -# include <ufs/ufs/ufsmount.h> -#endif /* HAVE_UFS_UFS_UFSMOUNT_H */ - -#define MOUNTVERS3 ((unsigned long)(3)) - -typedef struct { - u_int fhandle3_len; - char *fhandle3_val; -} fhandle3; - - -enum mountstat3 { - MNT3_OK = 0, - MNT3ERR_PERM = 1, - MNT3ERR_NOENT = 2, - MNT3ERR_IO = 5, - MNT3ERR_ACCES = 13, - MNT3ERR_NOTDIR = 20, - MNT3ERR_INVAL = 22, - MNT3ERR_NAMETOOLONG = 63, - MNT3ERR_NOTSUPP = 10004, - MNT3ERR_SERVERFAULT = 10006 -}; -typedef enum mountstat3 mountstat3; - -struct mountres3_ok { - fhandle3 fhandle; - struct { - u_int auth_flavors_len; - int *auth_flavors_val; - } auth_flavors; -}; -typedef struct mountres3_ok mountres3_ok; - -struct mountres3 { - mountstat3 fhs_status; - union { - mountres3_ok mountinfo; - } mountres3_u; -}; -typedef struct mountres3 mountres3; - - -/* - * MACROS: - */ -#define dr_drok_u diropres -#define ca_attributes attributes -#define ca_where where -#define da_fhandle dir -#define da_name name -#define dl_entries entries -#define dl_eof eof -#define dr_status status -#define dr_u diropres_u -#define drok_attributes attributes -#define drok_fhandle file -#define fh_data data -#define la_fhandle from -#define la_to to -#define na_atime atime -#define na_ctime ctime -#define na_fileid fileid -#define na_fsid fsid -#define na_gid gid -#define na_mode mode -#define na_mtime mtime -#define na_nlink nlink -#define na_size size -#define na_type type -#define na_uid uid -#define na_blocks blocks -#define na_blocksize blocksize -#define na_rdev rdev -#define ne_cookie cookie -#define ne_fileid fileid -#define ne_name name -#define ne_nextentry nextentry -#define ns_attr_u attributes -#define ns_status status -#define ns_u attrstat_u -#define nt_seconds seconds -#define nt_useconds useconds -#define ra_count count -#define ra_fhandle file -#define ra_offset offset -#define ra_totalcount totalcount -#define raok_attributes attributes -#define raok_len_u data_len -#define raok_u data -#define raok_val_u data_val -#define rda_cookie cookie -#define rda_count count -#define rda_fhandle dir -#define rdr_reply_u reply -#define rdr_status status -#define rdr_u readdirres_u -#define rlr_data_u data -#define rlr_status status -#define rlr_u readlinkres_u -#define rna_from from -#define rna_to to -#define rr_reply_u reply -#define rr_status status -#define rr_u readres_u -#define sa_atime atime -#define sa_gid gid -#define sa_mode mode -#define sa_mtime mtime -#define sa_size size -#define sa_uid uid -#define sag_attributes attributes -#define sag_fhandle file -#define sfr_reply_u reply -#define sfr_status status -#define sfr_u statfsres_u -#define sfrok_bavail bavail -#define sfrok_bfree bfree -#define sfrok_blocks blocks -#define sfrok_bsize bsize -#define sfrok_tsize tsize -#define sla_attributes attributes -#define sla_from from -#define sla_to to -#define wra_beginoffset beginoffset -#define wra_fhandle file -#define wra_len_u data_len -#define wra_offset offset -#define wra_totalcount totalcount -#define wra_u data -#define wra_val_u data_val - -/* - * TYPEDEFS: - */ -typedef attrstat nfsattrstat; -typedef createargs nfscreateargs; -typedef dirlist nfsdirlist; -typedef diropargs nfsdiropargs; -typedef diropokres nfsdiropokres; -typedef diropres nfsdiropres; -typedef entry nfsentry; -typedef fattr nfsfattr; -typedef ftype nfsftype; -typedef linkargs nfslinkargs; -typedef readargs nfsreadargs; -typedef readdirargs nfsreaddirargs; -typedef readdirres nfsreaddirres; -typedef readlinkres nfsreadlinkres; -typedef readokres nfsreadokres; -typedef readres nfsreadres; -typedef renameargs nfsrenameargs; -typedef sattr nfssattr; -typedef sattrargs nfssattrargs; -typedef statfsokres nfsstatfsokres; -typedef statfsres nfsstatfsres; -typedef symlinkargs nfssymlinkargs; -typedef writeargs nfswriteargs; - - -/* - * - * FreeBSD-3.0-RELEASE has NFS V3. Older versions had it only defined - * in the rpcgen source file. If you are on an older system, and you - * want NFSv3 support, you need to regenerate the rpcsvc header files as - * follows: - * cd /usr/include/rpcsvc - * rpcgen -h -C -DWANT_NFS3 mount.x - * rpcgen -h -C -DWANT_NFS3 nfs_prot.x - * If you don't want NFSv3, then you will have to turn off the NFSMNT_NFSV3 - * macro below. If the code doesn't compile, upgrade to the latest 3.0 - * version... - */ -#ifdef NFSMNT_NFSV3 - -# define MOUNT_NFS3 "nfs" /* is this right? */ -# define MNTOPT_NFS3 "nfs" - -/* - * 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 (m4/macros/struct_nfs_fh3.m4) searches - * for this special name before other names. - */ - -#define NFS3_FHSIZE 64 -#define FHSIZE3 64 - -struct nfs_fh3_freebsd3 { - u_int fh3_length; - union nfs_fh3_u { - struct nfs_fh3_i { - fhandle_t fh3_i; - } nfs_fh3_i; - char data[NFS3_FHSIZE]; - } fh3_u; -}; -typedef struct nfs_fh3_freebsd3 nfs_fh3; - -#endif /* NFSMNT_NFSV3 */ - -#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h index cf7ba33..24bc9b3 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-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/conf/nfs_prot/nfs_prot_freebsd2.h + * $Id: nfs_prot_freebsd2.h,v 1.3.2.4 2004/01/06 03:15:19 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 edcc5754..27c535d 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-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,31 +36,38 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/conf/nfs_prot/nfs_prot_freebsd3.h + * $Id: nfs_prot_freebsd3.h,v 1.5.2.7 2004/01/06 03:15:19 ezk Exp $ + * $FreeBSD$ * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H +/* nfs_prot.h defines struct `nfs_fh3', but it is a ``dmr "unwarranted + * chumminess with the C implementation". We need the more complete + * structure, which is defined below. So get the stock `nfs_fh3' + * out of the way. + */ +struct nfs_fh3; +#define nfs_fh3 nfs_fh3_fbsd_ + #ifdef HAVE_RPCSVC_NFS_PROT_H # include <rpcsvc/nfs_prot.h> #endif /* HAVE_RPCSVC_NFS_PROT_H */ + +#undef nfs_fh3 + #ifdef HAVE_NFS_RPCV2_H # include <nfs/rpcv2.h> #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H -# include <nfs/nfs.h> +# include <nfsclient/nfs.h> +# include <nfsserver/nfs.h> #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H -# ifdef HAVE_UFS_UFS_EXTATTR_H -/* - * Define a dummy struct ufs_extattr_per_mount, which is used in struct - * ufsmount in <ufs/ufs/ufsmount.h>. - */ -struct ufs_extattr_per_mount; -# endif /* HAVE_UFS_UFS_EXTATTR_H */ # include <ufs/ufs/ufsmount.h> #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ @@ -172,16 +179,26 @@ typedef writeargs nfswriteargs; # define MOUNT_NFS3 "nfs" /* is this right? */ # define MNTOPT_NFS3 "nfs" -# ifndef HAVE_XDR_LOOKUP3RES /* - * FreeBSD uses different field names than are defined on most other - * systems. + * 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 (m4/macros/struct_nfs_fh3.m4) searches + * for this special name before other names. */ -# define AMU_LOOKUP3RES_OK(x) ((x)->LOOKUP3res_u.resok) -# define AMU_LOOKUP3RES_FAIL(x) ((x)->LOOKUP3res_u.resfail) -# define AMU_LOOKUP3RES_FH_LEN(x) (AMU_LOOKUP3RES_OK(x).object.data.data_len) -# define AMU_LOOKUP3RES_FH_DATA(x) (AMU_LOOKUP3RES_OK(x).object.data.data_val) -# endif /* not HAVE_XDR_LOOKUP3RES */ +struct nfs_fh3_freebsd3 { + u_int fh3_length; + union nfs_fh3_u { + struct nfs_fh3_i { + fhandle_t fh3_i; + } nfs_fh3_i; + char data[NFS3_FHSIZE]; + } fh3_u; +}; +typedef struct nfs_fh3_freebsd3 nfs_fh3_freebsd3; + +/* since we don't use Am-utils's aux/macros/struct_nfs_fh3.m4, we don't get + their special searching. So restore the standard name. */ +typedef struct nfs_fh3_freebsd3 nfs_fh3; #endif /* NFSMNT_NFSV3 */ diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_osf5.h b/contrib/amd/conf/nfs_prot/nfs_prot_osf5.h deleted file mode 100644 index 655e98d..0000000 --- a/contrib/amd/conf/nfs_prot/nfs_prot_osf5.h +++ /dev/null @@ -1,431 +0,0 @@ -/* - * 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. - * 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: nfs_prot_osf5.h,v 1.1.2.4 2002/12/27 22:44:57 ezk Exp $ - * - */ - -#ifndef _AMU_NFS_PROT_H -#define _AMU_NFS_PROT_H - -#ifdef HAVE_RPCSVC_NFS_PROT_H -# include <rpcsvc/nfs_prot.h> -#endif /* HAVE_RPCSVC_NFS_PROT_H */ -#ifdef HAVE_NFS_NFS_H -# include <nfs/nfs.h> -#endif /* HAVE_NFS_NFS_H */ -#ifdef HAVE_RPCSVC_MOUNTV3_H -# include <rpcsvc/mountv3.h> -#endif /* HAVE_RPCSVC_MOUNTV3_H */ -#ifdef HAVE_RPC_RPC_H -# include <rpc/rpc.h> -#endif /* HAVE_RPC_RPC_H */ - -/* avoid conflicts with Irix's EFS */ -#undef MOUNT_EFS /* DCE Episode FS */ - -/* - * The NFSMNT_AUTO flag in Tru64 UNIX V5 has two effects: it causes df and - * mount not to display this mount point without the -e switch, as it did in - * previous releases. Unfortunately it also ignores the timeo mount option, - * disables the usual timeout backof and enforces a timeout of NFS_MAXTIMO - * (20 seconds) instead. This breaks amd which can sometimes take longer to - * respond to an NFS request, causing `nfs server not responding still trying' - * messages. - * - * To avoid this, we need to completely disable this flag on automount points, - * with the unfortunate side effect that they are no longer hidden in df and - * mount output. - */ -#undef MNT2_NFS_OPT_AUTO - -/* - * MACROS - */ - -#define NFS_PORT 2049 -#define NFS_MAXDATA 8192 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_FHSIZE 32 -#define NFS_COOKIESIZE 4 -#define MNTPATHLEN 1024 -#define MNTNAMLEN 255 - -#define NFSMODE_FMT 0170000 -#define NFSMODE_DIR 0040000 -#define NFSMODE_CHR 0020000 -#define NFSMODE_BLK 0060000 -#define NFSMODE_REG 0100000 -#define NFSMODE_LNK 0120000 -#define NFSMODE_SOCK 0140000 -#define NFSMODE_FIFO 0010000 - -#ifndef NFS_PROGRAM -# define NFS_PROGRAM ((u_long)100003) -#endif /* not NFS_PROGRAM */ -#ifndef NFS_VERSION -# define NFS_VERSION ((u_long)2) -#endif /* not NFS_VERSION */ - -#define NFSPROC_NULL ((u_long)0) -#define NFSPROC_GETATTR ((u_long)1) -#define NFSPROC_SETATTR ((u_long)2) -#define NFSPROC_ROOT ((u_long)3) -#define NFSPROC_LOOKUP ((u_long)4) -#define NFSPROC_READLINK ((u_long)5) -#define NFSPROC_READ ((u_long)6) -#define NFSPROC_WRITECACHE ((u_long)7) -#define NFSPROC_WRITE ((u_long)8) -#define NFSPROC_CREATE ((u_long)9) -#define NFSPROC_REMOVE ((u_long)10) -#define NFSPROC_RENAME ((u_long)11) -#define NFSPROC_LINK ((u_long)12) -#define NFSPROC_SYMLINK ((u_long)13) -#define NFSPROC_MKDIR ((u_long)14) -#define NFSPROC_RMDIR ((u_long)15) -#define NFSPROC_READDIR ((u_long)16) -#define NFSPROC_STATFS ((u_long)17) - -/* map field names */ -#define ml_hostname ml_name -#define ml_directory ml_path -#define ml_next ml_nxt -#define gr_next g_next -#define gr_name g_name -#define ex_dir ex_name - -#define drok_attributes drok_attr -#define na_fileid na_nodeid -#define la_fhandle la_from -#define nt_seconds tv_sec -#define nt_useconds tv_usec -#define ra_totalcount ra_totcount -#define sla_to sla_tnm -#define sla_attributes sla_sa -#define sag_fhandle saa_fh -#define sag_attributes saa_sa -#define sfrok_tsize fsok_tsize -#define sfrok_bsize fsok_bsize -#define sfrok_blocks fsok_blocks -#define sfrok_bfree fsok_bfree -#define sfrok_bavail fsok_bavail -#define sfr_status fs_status -#define sfr_u fs_u -#define sfr_reply_u fs_fsok_u -#define wra_fhandle wa_fhandle -#define wra_beginoffset wa_begoff -#define wra_offset wa_offset -#define wra_totalcount wa_totcount -#define wra_u wa_mbuf->m_hdr -#define wra_val_u mh_data -#define wra_len_u mh_len - - -/* - * TYPEDEFS: - */ -typedef char *dirpath; -typedef char *filename; -typedef char *name; -typedef char *nfspath; -typedef char nfscookie[NFS_COOKIESIZE]; -typedef enum nfsftype nfsftype; -typedef enum nfsstat nfsstat; -typedef struct nfssvcfh fhandle; -typedef struct nfsattrstat nfsattrstat; -typedef struct nfscreateargs nfscreateargs; -typedef struct nfsdirlist nfsdirlist; -typedef struct nfsdiropargs nfsdiropargs; -typedef struct nfsdrok nfsdiropokres; -typedef struct nfsdiropres nfsdiropres; -typedef struct nfsentry nfsentry; -typedef struct exports *exports; -typedef struct exports exportnode; -typedef struct nfsfattr nfsfattr; -typedef struct fhstatus fhstatus; -typedef struct groups *groups; -typedef struct groups groupnode; -typedef struct nfslinkargs nfslinkargs; -typedef struct mountlist *mountlist; -typedef struct mountlist mountbody; -typedef struct _nfs_fh _nfs_fh; -typedef struct timeval nfstime; -typedef struct nfsreadargs nfsreadargs; -typedef struct nfsreaddirargs nfsreaddirargs; -typedef struct nfsreaddirres nfsreaddirres; -typedef struct nfsreadlinkres nfsreadlinkres; -typedef struct nfsreadokres nfsreadokres; -typedef struct nfsreadres nfsreadres; -typedef struct nfsrenameargs nfsrenameargs; -typedef struct nfssattr nfssattr; -typedef struct nfssaargs nfssattrargs; -typedef struct nfsstatfsok nfsstatfsokres; -typedef struct nfsstatfs nfsstatfsres; -typedef struct nfsslargs nfssymlinkargs; -typedef struct nfswriteargs nfswriteargs; - - -/* - * EXTERNALS: - */ - -extern void *nfsproc_null_2_svc(void *, struct svc_req *); -extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *); -extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); -extern void *nfsproc_root_2_svc(void *, struct svc_req *); -extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *); -extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); -extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); -extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); -extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); -extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); -extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); -extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); -extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); -extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); -extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *); - -extern bool_t xdr_nfsstat(XDR *, nfsstat*); -extern bool_t xdr_ftype(XDR *, nfsftype*); -extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*); -extern bool_t xdr_nfstime(XDR *, nfstime*); -extern bool_t xdr_fattr(XDR *, nfsfattr*); -extern bool_t xdr_sattr(XDR *, nfssattr*); -extern bool_t xdr_filename(XDR *, filename*); -extern bool_t xdr_nfspath(XDR *, nfspath*); -extern bool_t xdr_attrstat(XDR *, nfsattrstat*); -extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); -extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); -extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); -extern bool_t xdr_diropres(XDR *, nfsdiropres*); -extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); -extern bool_t xdr_readargs(XDR *, nfsreadargs*); -extern bool_t xdr_readokres(XDR *, nfsreadokres*); -extern bool_t xdr_readres(XDR *, nfsreadres*); -extern bool_t xdr_writeargs(XDR *, nfswriteargs*); -extern bool_t xdr_createargs(XDR *, nfscreateargs*); -extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); -extern bool_t xdr_linkargs(XDR *, nfslinkargs*); -extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); -extern bool_t xdr_nfscookie(XDR *, nfscookie); -extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); -extern bool_t xdr_entry(XDR *, nfsentry*); -extern bool_t xdr_dirlist(XDR *, nfsdirlist*); -extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); -extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); -extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); - - -/* - * STRUCTURES: - */ - -struct _nfs_fh { - char data[NFS_FHSIZE]; -}; - -struct nfstime { - u_int nt_seconds; - u_int nt_useconds; -}; - -struct _fattr { - nfsftype na_type; - u_int na_mode; - u_int na_nlink; - u_int na_uid; - u_int na_gid; - u_int na_size; - u_int na_blocksize; - u_int na_rdev; - u_int na_blocks; - u_int na_fsid; - u_int na_fileid; - nfstime na_atime; - nfstime na_mtime; - nfstime na_ctime; -}; - -struct _sattr { - u_int sa_mode; - u_int sa_uid; - u_int sa_gid; - u_int sa_size; - nfstime sa_atime; - nfstime sa_mtime; -}; - -struct _attrstat { - nfsstat ns_status; - union { - nfsfattr ns_attr_u; - } ns_u; -}; - -struct _sattrargs { - struct nfssvcfh sag_fhandle; - nfssattr sag_attributes; -}; - -struct _diropargs { - struct nfssvcfh da_fhandle; /* was dir */ - filename da_name; -}; - -struct _diropokres { - struct nfssvcfh drok_fhandle; - nfsfattr drok_attributes; -}; - -struct _diropres { - nfsstat dr_status; /* was status */ - union { - nfsdiropokres dr_drok_u; /* was diropres */ - } dr_u; /* was diropres_u */ -}; - -struct nfsreadlinkres { - nfsstat rlr_status; - union { - nfspath rlr_data_u; - } rlr_u; -}; - -struct _readargs { - struct nfssvcfh ra_fhandle; - u_int ra_offset; - u_int ra_count; - u_int ra_totalcount; -}; - -struct nfsreadokres { - nfsfattr raok_attributes; - struct { - u_int raok_len_u; - char *raok_val_u; - } raok_u; -}; - -struct nfsreadres { - nfsstat rr_status; - union { - nfsreadokres rr_reply_u; - } rr_u; -}; - -#if 0 -struct _writeargs { - struct nfssvcfh wra_fhandle; - u_int wra_beginoffset; - u_int wra_offset; - u_int wra_totalcount; - struct { - u_int wra_len_u; - char *wra_val_u; - } wra_u; -}; -#endif - -struct nfscreateargs { - nfsdiropargs ca_where; - nfssattr ca_attributes; -}; - -struct nfsrenameargs { - nfsdiropargs rna_from; - nfsdiropargs rna_to; -}; - -struct _linkargs { - struct nfssvcfh la_fhandle; - nfsdiropargs la_to; -}; - -struct _symlinkargs { - nfsdiropargs sla_from; - nfspath sla_to; - nfssattr sla_attributes; -}; - -struct nfsreaddirargs { - struct nfssvcfh rda_fhandle; - nfscookie rda_cookie; - u_int rda_count; -}; - -struct nfsentry { - u_int ne_fileid; - filename ne_name; - nfscookie ne_cookie; - nfsentry *ne_nextentry; -}; - -struct nfsdirlist { - nfsentry *dl_entries; - bool_t dl_eof; -}; - -struct nfsreaddirres { - nfsstat rdr_status; - union { - nfsdirlist rdr_reply_u; - } rdr_u; -}; - -struct _statfsokres { - u_int sfrok_tsize; - u_int sfrok_bsize; - u_int sfrok_blocks; - u_int sfrok_bfree; - u_int sfrok_bavail; -}; - -struct _statfsres { - nfsstat sfr_status; - union { - nfsstatfsokres sfr_reply_u; - } sfr_u; -}; - -#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_sunos5_8.h b/contrib/amd/conf/nfs_prot/nfs_prot_sunos5_8.h deleted file mode 100644 index 6392622..0000000 --- a/contrib/amd/conf/nfs_prot/nfs_prot_sunos5_8.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * 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. - * 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: nfs_prot_sunos5_8.h,v 1.2.2.4 2002/12/27 22:44:59 ezk Exp $ - * - */ - -#ifndef _AMU_NFS_PROT_H -#define _AMU_NFS_PROT_H - -/* - * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because - * it will result in conflicts with <nfs/nfs.h>. The latter is a must - * for NFS V3 specs. - */ - -#ifdef HAVE_NFS_NFS_H -# include <nfs/nfs.h> -#endif /* HAVE_NFS_NFS_H */ - -#ifdef HAVE_RPCSVC_MOUNT_H -# include <rpcsvc/mount.h> -#endif /* HAVE_RPCSVC_MOUNT_H */ - -#ifdef HAVE_RPC_RPC_H -# include <rpc/rpc.h> -#endif /* HAVE_RPC_RPC_H */ - - -/* - * MACROS - */ - -#define NFS_PORT 2049 -#define NFS_MAXDATA 8192 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_FHSIZE 32 -#define NFS_COOKIESIZE 4 - -#define NFSMODE_FMT 0170000 -#define NFSMODE_DIR 0040000 -#define NFSMODE_CHR 0020000 -#define NFSMODE_BLK 0060000 -#define NFSMODE_REG 0100000 -#define NFSMODE_LNK 0120000 -#define NFSMODE_SOCK 0140000 -#define NFSMODE_FIFO 0010000 - -#define NFSPROC_NULL ((unsigned long)(0)) -#define NFSPROC_GETATTR ((unsigned long)(1)) -#define NFSPROC_SETATTR ((unsigned long)(2)) -#define NFSPROC_ROOT ((unsigned long)(3)) -#define NFSPROC_LOOKUP ((unsigned long)(4)) -#define NFSPROC_READLINK ((unsigned long)(5)) -#define NFSPROC_READ ((unsigned long)(6)) -#define NFSPROC_WRITECACHE ((unsigned long)(7)) -#define NFSPROC_WRITE ((unsigned long)(8)) -#define NFSPROC_CREATE ((unsigned long)(9)) -#define NFSPROC_REMOVE ((unsigned long)(10)) -#define NFSPROC_RENAME ((unsigned long)(11)) -#define NFSPROC_LINK ((unsigned long)(12)) -#define NFSPROC_SYMLINK ((unsigned long)(13)) -#define NFSPROC_MKDIR ((unsigned long)(14)) -#define NFSPROC_RMDIR ((unsigned long)(15)) -#define NFSPROC_READDIR ((unsigned long)(16)) -#define NFSPROC_STATFS ((unsigned long)(17)) - - -/* - * TYPEDEFS: - */ - -typedef char *filename; -typedef char *nfspath; -typedef char nfscookie[NFS_COOKIESIZE]; -typedef enum nfsftype nfsftype; -typedef struct attrstat nfsattrstat; -typedef struct createargs nfscreateargs; -typedef struct dirlist nfsdirlist; -typedef struct diropargs nfsdiropargs; -typedef struct diropokres nfsdiropokres; -typedef struct diropres nfsdiropres; -typedef struct entry nfsentry; -typedef struct fattr nfsfattr; -typedef struct linkargs nfslinkargs; -typedef struct nfs_fh nfs_fh; -typedef struct nfstime nfstime; -typedef struct readargs nfsreadargs; -typedef struct readdirargs nfsreaddirargs; -typedef struct readdirres nfsreaddirres; -typedef struct readlinkres nfsreadlinkres; -typedef struct readokres nfsreadokres; -typedef struct readres nfsreadres; -typedef struct renameargs nfsrenameargs; -typedef struct sattr nfssattr; -typedef struct sattrargs nfssattrargs; -typedef struct statfsokres nfsstatfsokres; -typedef struct statfsres nfsstatfsres; -typedef struct symlinkargs nfssymlinkargs; -typedef struct writeargs nfswriteargs; - - -/* - * EXTERNALS: - */ - -extern bool_t xdr_nfsstat(XDR *, nfsstat *); -extern bool_t xdr_ftype(XDR *, nfsftype *); -extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); -extern bool_t xdr_nfstime(XDR *, nfstime *); -extern bool_t xdr_fattr(XDR *, nfsfattr *); -extern bool_t xdr_sattr(XDR *, nfssattr *); -extern bool_t xdr_filename(XDR *, filename *); -extern bool_t xdr_nfspath(XDR *, nfspath *); -extern bool_t xdr_attrstat(XDR *, nfsattrstat *); -extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); -extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); -extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); -extern bool_t xdr_diropres(XDR *, nfsdiropres *); -extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); -extern bool_t xdr_readargs(XDR *, nfsreadargs *); -extern bool_t xdr_readokres(XDR *, nfsreadokres *); -extern bool_t xdr_readres(XDR *, nfsreadres *); -extern bool_t xdr_writeargs(XDR *, nfswriteargs *); -extern bool_t xdr_createargs(XDR *, nfscreateargs *); -extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); -extern bool_t xdr_linkargs(XDR *, nfslinkargs *); -extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); -extern bool_t xdr_nfscookie(XDR *, nfscookie); -extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); -extern bool_t xdr_entry(XDR *, nfsentry *); -extern bool_t xdr_dirlist(XDR *, nfsdirlist *); -extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); -extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); -extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); - -extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); -extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); -extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); -extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); -extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); -extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); -extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); -extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); -extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); -extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); -extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); -extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); -extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); -extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); -extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); -extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); -extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); -extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); -extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); -extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); -extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); -extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); -extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); -extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); -extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); -extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); -extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); -extern void *nfsproc_null_2(void *, CLIENT *); -extern void *nfsproc_null_2_svc(void *, struct svc_req *); -extern void *nfsproc_root_2(void *, CLIENT *); -extern void *nfsproc_root_2_svc(void *, struct svc_req *); -extern void *nfsproc_writecache_2(void *, CLIENT *); -extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); -extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); - - -/* - * ENUMS: - */ - - -/* - * STRUCTURES: - */ - -struct nfs_fh { - char fh_data[NFS_FHSIZE]; -}; - -struct nfstime { - u_int nt_seconds; - u_int nt_useconds; -}; - -struct fattr { - nfsftype na_type; - u_int na_mode; - u_int na_nlink; - u_int na_uid; - u_int na_gid; - u_int na_size; - u_int na_blocksize; - u_int na_rdev; - u_int na_blocks; - u_int na_fsid; - u_int na_fileid; - nfstime na_atime; - nfstime na_mtime; - nfstime na_ctime; -}; - -struct sattr { - u_int sa_mode; - u_int sa_uid; - u_int sa_gid; - u_int sa_size; - nfstime sa_atime; - nfstime sa_mtime; -}; - -struct attrstat { - nfsstat ns_status; - union { - nfsfattr ns_attr_u; - } ns_u; -}; - -struct sattrargs { - nfs_fh sag_fhandle; - nfssattr sag_attributes; -}; - -struct diropargs { - nfs_fh da_fhandle; /* was dir */ - filename da_name; -}; - -struct diropokres { - nfs_fh drok_fhandle; - nfsfattr drok_attributes; -}; - -struct diropres { - nfsstat dr_status; /* was status */ - union { - nfsdiropokres dr_drok_u; /* was diropres */ - } dr_u; /* was diropres_u */ -}; - -struct readlinkres { - nfsstat rlr_status; - union { - nfspath rlr_data_u; - } rlr_u; -}; - -struct readargs { - nfs_fh ra_fhandle; - u_int ra_offset; - u_int ra_count; - u_int ra_totalcount; -}; - -struct readokres { - nfsfattr raok_attributes; - struct { - u_int raok_len_u; - char *raok_val_u; - } raok_u; -}; - -struct readres { - nfsstat rr_status; - union { - nfsreadokres rr_reply_u; - } rr_u; -}; - -struct writeargs { - nfs_fh wra_fhandle; - u_int wra_beginoffset; - u_int wra_offset; - u_int wra_totalcount; - struct { - u_int wra_len_u; - char *wra_val_u; - } wra_u; -}; - -struct createargs { - nfsdiropargs ca_where; - nfssattr ca_attributes; -}; - -struct renameargs { - nfsdiropargs rna_from; - nfsdiropargs rna_to; -}; - -struct linkargs { - nfs_fh la_fhandle; - nfsdiropargs la_to; -}; - -struct symlinkargs { - nfsdiropargs sla_from; - nfspath sla_to; - nfssattr sla_attributes; -}; - -struct readdirargs { - nfs_fh rda_fhandle; - nfscookie rda_cookie; - u_int rda_count; -}; - -struct entry { - u_int ne_fileid; - filename ne_name; - nfscookie ne_cookie; - nfsentry *ne_nextentry; -}; - -struct dirlist { - nfsentry *dl_entries; - bool_t dl_eof; -}; - -struct readdirres { - nfsstat rdr_status; - union { - nfsdirlist rdr_reply_u; - } rdr_u; -}; - -struct statfsokres { - u_int sfrok_tsize; - u_int sfrok_bsize; - u_int sfrok_blocks; - u_int sfrok_bfree; - u_int sfrok_bavail; -}; - -struct statfsres { - nfsstat sfr_status; - union { - nfsstatfsokres sfr_reply_u; - } sfr_u; -}; - -#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/trap/trap_default.h b/contrib/amd/conf/trap/trap_default.h index a132b0e..f671c41 100644 --- a/contrib/amd/conf/trap/trap_default.h +++ b/contrib/amd/conf/trap/trap_default.h @@ -1,2 +1,3 @@ +/* $FreeBSD$ */ /* $srcdir/conf/trap/trap_default.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data) diff --git a/contrib/amd/conf/trap/trap_freebsd3.h b/contrib/amd/conf/trap/trap_freebsd3.h deleted file mode 100644 index 95c6642..0000000 --- a/contrib/amd/conf/trap/trap_freebsd3.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $srcdir/conf/trap/trap_freebsd3.h */ -extern int mount_freebsd3(MTYPE_TYPE type, const char *dir, int flags, voidp data); -#define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_freebsd3(type, mnt->mnt_dir, flags, mnt_data) diff --git a/contrib/amd/cvs-server.txt b/contrib/amd/cvs-server.txt deleted file mode 100644 index 0943963..0000000 --- a/contrib/amd/cvs-server.txt +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################## -Here are generic CVS server instructions: - -(1) Login to the cvs server. Not needed more than once b/c the cvs login - will record your cvs password in $HOME/.cvspass. Change "ezk" for your - CVS user id. - -$ cvs -d :pserver:ezk@shekel.mcl.cs.columbia.edu:/proj/bank/cvsroot login -CVS password: - -Type in your password, crypt(3)'ed in /proj/bank/cvsroot/CVSROOT/passwd. - -(2) Then, check out a fresh copy of 6.1 (experimental) - -$ cvs -d :pserver:ezk@shekel.mcl.cs.columbia.edu:/proj/bank/cvsroot checkout am-utils - -Or, to checkout the stable branch: - -$ cvs -d :pserver:ezk@shekel.mcl.cs.columbia.edu:/proj/bank/cvsroot checkout -r amd-6-0-stable am-utils - -(3) Then you can do normal edit, commit, update, etc. w/o having to worry - about your $CVSROOT or the -d option. - -############################################################################## -To merge changes from the stable branch into the main (experimental) branch: - -$ cvs update -j amd-6-0-stable -kk - -- don't worry about all the files that change; it's probably because of cvs - keywords in the sources -- after the merge, do a 'cvs update -d' and resolve any conflicts - -############################################################################## - -There are two new mailing lists: - -amd-maintainers@shekel.mcl.cs.columbia.edu: for Amd maintainers to - communicate internally w/o exposure to the greater user community. - -amd-cvslog@shekel.mcl.cs.columbia.edu: to get cvs log messages. I've used a - better (I hope) script for loginfo. It provides different output - and can be tweaked as well. -############################################################################## diff --git a/contrib/amd/doc/stamp-vti b/contrib/amd/doc/stamp-vti deleted file mode 100644 index 41b19a3..0000000 --- a/contrib/amd/doc/stamp-vti +++ /dev/null @@ -1,4 +0,0 @@ -@set UPDATED 20 April 2006 -@set UPDATED-MONTH April 2006 -@set EDITION 6.1.5 -@set VERSION 6.1.5 diff --git a/contrib/amd/fixmount/fixmount.8 b/contrib/amd/fixmount/fixmount.8 index e4b700b..b4ecb60 100644 --- a/contrib/amd/fixmount/fixmount.8 +++ b/contrib/amd/fixmount/fixmount.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,140 +38,150 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: fixmount.8,v 1.12.2.1 2006/01/02 18:48:25 ezk Exp $ +.\" $Id: fixmount.8,v 1.3.2.6 2004/01/06 03:15:23 ezk Exp $ +.\" $FreeBSD$ .\" -.TH FIXMOUNT 8 "26 Feb 1993" -.SH NAME -fixmount \- fix remote mount entries -.SH SYNOPSIS -.B fixmount -[ -.B \-adervq -] -[ -.B \-h -.I name -] -.I host +.Dd February 26, 1993 +.Dt FIXMOUNT 8 +.Os +.Sh NAME +.Nm fixmount +.Nd fix remote mount entries +.Sh SYNOPSIS +.Nm +.Op Fl adervq +.Op Fl h Ar name +.Ar host \&... -.SH DESCRIPTION -.IX "fixmount command" "" "\fLfixmount\fP \(em fix remote mount entries" -.LP -.B fixmount +.Sh DESCRIPTION +.Nm is a variant of -.BR showmount (8) +.Xr showmount 8 that can delete bogus mount entries in remote -.BR mountd (8C) +.Xr mountd 8 daemons. The actions specified by the options are performed for each -.I host +.Ar host in turn. -.SH OPTIONS -.TP -.B \-a \-d \-e +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl a Fl d Fl e These options work as in -.BR showmount (8) +.Xr showmount 8 except that only entries pertaining to the local host are printed. -.TP -.B \-r +.It Fl r Removes those remote mount entries on -.I host +.Ar host that do not correspond to current mounts, i.e., which are left-over from a crash or are the result of improper mount protocol. The actuality of mounts is verified using the entries in -.BR /etc/mtab . -.TP -.B \-v -Verify remote mounts. Similar to -.B \-r +.Pa /etc/mtab . +.It Fl v +Verify remote mounts. +Similar to +.Fl r except that only a notification message is printed for each bogus entry -found. The remote mount table is not changed. -.TP -.B \-A -Issues a command to the remote mountd declaring that ALL of its filesystems -have been unmounted. This should be used with caution, as it removes all -remote mount entries pertaining to the local system, whether or not any -filesystems are still mounted locally. -.TP -.B \-q +found. +The remote mount table is not changed. +.It Fl A +Issues a command to the remote mountd declaring that +.Em all +of its file systems have been unmounted. +This should be used with caution, as +it removes all remote mount entries pertaining to the local system, whether or +not any file systems are still mounted locally. +.It Fl q Be quiet. -Suppresses error messages due to timeouts and "Program not registered", -i.e., due to remote hosts not supporting RPC or not running mountd. -.TP -.BI \-h \ name +Suppresses error messages due to timeouts and +.Dq Program not Registered , +i.e., due to remote hosts not supporting RPC or not running +.Nm mountd . +.It Fl h Ar name Pretend the local hostname is -.IR name . +.Ar name . This is useful after the local hostname has been changed and rmtab entries using the old name remain on a remote machine. -Unfortunately, most mountd's won't be able to successfully handle removal +Unfortunately, most mountd's will not be able to successfully handle removal of such entries, so this option is useful in combination with -.B \-v +.Fl v only. -.br +.Pp This option also saves time as comparisons of remotely recorded and local hostnames by address are avoided. -.SH FILES -.TP 20 -.B /etc/mtab +.El +.Sh FILES +.Bl -tag -width /axx +.It Pa /etc/mtab List of current mounts. -.TP -.B /etc/rmtab -Backup file for remote mount entries on NFS server. -.SH "SEE ALSO" -.BR showmount (8), -.BR mtab (5), -.BR rmtab (5), -.BR mountd (8C). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH BUGS +.It Pa /etc/rmtab +Backup file for remote mount entries on +.Tn NFS +server. +.El +.Sh SEE ALSO +.Xr mtab 5 , +.Xr rmtab 5 , +.Xr mountd 8 , +.Xr showmount 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . +.Sh AUTHORS +.An Jan-Simon Pendry Aq jsp@doc.ic.ac.uk , +Department of Computing, Imperial College, London, UK. +.Pp +.An Erez Zadok Aq ezk@cs.columbia.edu , +Department of Computer Science, Columbia University, New York, USA. +.Pp +.An Other authors and contributors to +.Nm am-utils +are listed in the +.Nm AUTHORS +file distributed with +.Nm am-utils . +.Sh BUGS No attempt is made to verify the information in -.B /etc/mtab +.Pa /etc/mtab itself. -.PP +.Pp Since swap file mounts are not recorded in -.BR /etc/mtab , +.Pa /etc/mtab , a heuristic specific to SunOS is used to determine whether such a mount -is actual (replacing the string "swap" with "root" and verifying the resulting -path). -.PP +is actual (replacing the string +.Ql swap +with +.Ql root +and verifying the resulting path). +.Pp Symbolic links on the server will cause the path in the remote entry to differ from the one in -.BR /etc/mtab . -To catch those cases, a filesystem is also deemed mounted if its -.I local +.Pa /etc/mtab . +To catch those cases, a file system is also deemed mounted if its +.Em local mount point is identical to the remote entry. I.e., on a SunOS diskless client, -.B server:/export/share/sunos.4.1.1 +.Pa server:/export/share/sunos.4.1.1 is actually -.BR /usr/share . +.Pa /usr/share . Since the local mount point is -.B /usr/share +.Pa /usr/share as well this will be handled correctly. -.PP -There is no way to clear a stale entry in a remote mountd after the -local hostname (or whatever reverse name resolution returns for it) -has been changed. To take care of these cases, -the remote /etc/rmtab file has to be edited and mountd restarted. -.PP -The RPC timeouts for mountd calls can only be changed by recompiling. -The defaults are 2 seconds for client handle creation and 5 seconds for -RPC calls. -.SH AUTHORS -Andreas Stolcke <stolcke@icsi.berkeley.edu>. -.P -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.Pp +There is no way to clear a stale entry in a remote +.Nm mountd +after the local hostname (or whatever reverse name resolution +returns for it) has been changed. +To take care of these cases, +the remote +.Pa /etc/rmtab +file has to be edited and +.Nm mountd +restarted. +.Pp +The RPC timeouts for +.Nm mountd +calls can only be changed by recompiling. +The defaults are 2 seconds +for client handle creation and 5 seconds for RPC calls. diff --git a/contrib/amd/fixmount/fixmount.c b/contrib/amd/fixmount/fixmount.c index c7c6910..3e00786 100644 --- a/contrib/amd/fixmount/fixmount.c +++ b/contrib/amd/fixmount/fixmount.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/fixmount/fixmount.c + * $Id: fixmount.c,v 1.5.2.4 2004/01/06 03:15:23 ezk Exp $ + * $FreeBSD$ * */ @@ -49,6 +51,10 @@ #define CREATE_TIMEOUT 2 /* seconds */ #define CALL_TIMEOUT 5 /* seconds */ +#ifndef INADDR_NONE +# define INADDR_NONE 0xffffffff +#endif /* not INADDR_NONE */ + /* Constant defs */ #define ALL 1 #define DIRS 2 @@ -115,7 +121,7 @@ is_same_host(char *name1, char *name2, struct in_addr addr2) } else if (!(he = gethostbyname(name1))) { return 0; } else { - xstrlcpy(lasthost, name1, MAXHOSTNAMELEN); + strncpy(lasthost, name1, sizeof(lasthost) - 1); memcpy(&addr1, he->h_addr, sizeof(addr1)); return (addr1.s_addr == addr2.s_addr); } @@ -159,7 +165,7 @@ remove_mount(CLIENT *client, char *host, mountlist ml, int fixit) struct timeval tv; char *pathp = dir_path; - xstrlcpy(dir_path, ml->ml_directory, sizeof(dir_path)); + strncpy(dir_path, ml->ml_directory, sizeof(dir_path)); if (!fixit) { printf("%s: bogus mount %s:%s\n", host, ml->ml_hostname, ml->ml_directory); @@ -321,7 +327,8 @@ main(int argc, char *argv[]) break; case 'h': - xstrlcpy(thishost, optarg, sizeof(thishost)); + strncpy(thishost, optarg, sizeof(thishost)); + thishost[sizeof(thishost) - 1] = '\0'; break; case '?': @@ -361,7 +368,8 @@ main(int argc, char *argv[]) inet_ntoa(thisaddr)); exit(1); } - xstrlcpy(thishost, he->h_name, sizeof(thishost)); + strncpy(thishost, he->h_name, sizeof(thishost)); + thishost[sizeof(thishost) - 1] = '\0'; } else { thisaddr.s_addr = INADDR_NONE; } @@ -490,10 +498,8 @@ inetresport(int ty) struct sockaddr_in addr; int fd; - memset(&addr, 0, sizeof(addr)); - /* as per POSIX, sin_len need not be set (used internally by kernel) */ - - addr.sin_family = AF_INET; /* use internet address family */ + /* Use internet address family */ + addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; if ((fd = socket(AF_INET, ty, 0)) < 0) return -1; @@ -563,8 +569,7 @@ clnt_create_timeout(char *host, struct timeval *tvp) fprintf(stderr, "can't get address of %s\n", host); return NULL; } - memset(&host_addr, 0, sizeof(host_addr)); - /* as per POSIX, sin_len need not be set (used internally by kernel) */ + memset(&host_addr, 0, sizeof host_addr); host_addr.sin_family = AF_INET; if (hp) { memmove((voidp) &host_addr.sin_addr, (voidp) hp->h_addr, diff --git a/contrib/amd/fsinfo/fsinfo.8 b/contrib/amd/fsinfo/fsinfo.8 index f893eb2..815ec7d 100644 --- a/contrib/amd/fsinfo/fsinfo.8 +++ b/contrib/amd/fsinfo/fsinfo.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 Erez Zadok .\" Copyright (c) 1993 Jan-Simon Pendry. .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,89 +33,169 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)fsinfo.8 8.1 (Berkeley) 6/28/93 -.\" $Id: fsinfo.8,v 1.13.2.1 2006/01/02 18:48:25 ezk Exp $ +.\" $Id: fsinfo.8,v 1.3.2.5 2004/01/06 03:15:23 ezk Exp $ +.\" $FreeBSD$ .\" -.TH FSINFO 8 "June 28, 1993" -.SH NAME -fsinfo \- coordinate site-wide filesystem information -.SH SYNOPSIS -.B fsinfo -[ -.B \-v -] [ -.B \-a -.I autodir -] [ -.B \-b -.I bootparams -] [ -.B \-d -.I dumpsets -] [ -.B \-e -.I exports -] [ -.B \-f -.I fstabs -] [ -.B \-h -.I hostname -] [ -.B \-m -.I automounts -] [ -.B \-I -.I dir -] [ -.B \-D -.I string[=string] -] [ -.B \-U -.I string[=string] -] -.I config -.I ... -.SH DESCRIPTION +.Dd June 26, 1999 +.Dt FSINFO 8 +.Os +.Sh NAME +.Nm fsinfo +.Nd co-ordinate site-wide file system information +.Sh SYNOPSIS +.Nm +.Op Fl qv +.Op Fl a Ar autodir +.Op Fl b Ar bootparams_prefix +.Op Fl d Ar dumpsets_prefix +.Op Fl e Ar exports_prefix +.Op Fl f Ar fstabs_prefix +.Op Fl h Ar hostname +.Op Fl m Ar automounts_prefix +.Op Fl I Ar dir +.Oo +.Fl D +.Ar name Ns Op = Ns Ar string +.Oc +.Op Fl U Ar name +.Ar config ... +.Sh DESCRIPTION The -.B fsinfo +.Nm utility takes a set of system configuration information, and generates a coordinated set of -.I amd -, -.I mount +.Xr amd 8 , +.Xr mount 8 and -.I mountd +.Xr mountd 8 configuration files. -.PP +.Pp +The following options are available: +.Bl -tag -width Fl +.It Fl a Ar autodir +Specifies the directory name in which to place the automounter's +mount points. +This defaults to +.Pa /a . +.It Fl b Ar bootparams_prefix +Specifies the prefix for the +.Pa bootparams +file. +If it is not given, then the file will not be generated. +The file will be constructed for the destination machine and will be +placed into a file named +.Pa bootparams +and prefixed by the +.Ar bootparams_prefix +string. +The file generated contains a list of entries describing each +diskless client that can boot from the destination machine. +.It Fl d Ar dumpsets_prefix +Specifies the prefix for the +.Pa dumpsets +file. +If it is not specified, then the file will not be generated. +The file will be for the destination machine and will be placed into a file +named +.Pa dumpsets +prefixed by the +.Ar dumpsets_prefix +string. +This file is for use by +.Tn Imperial College's +local backup system. +.It Fl e Ar exports_prefix +Defines the prefix for the +.Pa exports +files. +If it is not given, then the file will not be generated. +For each machine defined in the configuration files as having disks, +and +.Pa exports +file is constructed and given a file name determined by the name of the +machine, prefixed with the +.Ar exports_prefix +string. +If a machine is defined as diskless, then no +file will be created for it. +The files contain entries +for directories on the machine that may be exported to clients. +.It Fl f Ar fstabs_prefix +This defines the prefix for the +.Pa fstab +files. +The files will only be created if this prefix is defined. +For each machine defined in the configuration files, a +.Pa fstab +file is created with the file name determined by prefixing this +.Ar fstabs_prefix +string with the name of the machine. +These files contain entries +for file systems and partitions to mount at boot time. +.It Fl h Ar hostname +Defines the hostname of the destination machine to process for. +If this is not specified, it defaults to the local machine name, +as returned by +.Xr gethostname 3 . +.It Fl m Ar automounts_prefix +Defines the prefix for the automounter files. +The maps will +only be produced if this option is specified. +The mount maps +suitable for the network defined by the configuration files will +be placed into files with names calculated by prefixing the +.Ar automounts_prefix +string to the name of each map. +.It Fl q +Selects quite mode. +Only error messages that are generated will +be displayed. +.It Fl v +Selects verbose mode. +When this is activated, more messages +will be displayed, and all information discovered when performing the semantic +analysis phase will be displayed. +Each verbose message +is output to the standard output on a line starting with a `#' +character. +.It Fl D Xo +.Ar name Ns Op = Ns Ar string +.Xc +Defines a symbol +.Ar name +for the preprocessor when reading the configuration files. +Equivalent to the +.Em #define +directive. +.It Fl I Ar dir +This option is passed into the preprocessor for the configuration +files. +It specifies directories in which to find include files. +.It Fl U Ar name +Removes and initial definition of the symbol +.Ar name . +Inverse of the +.Fl D +option. +.It Ar config +One or more configuration files to be passed as input to +.Nm fsinfo . +.El +.Pp The -.B fsinfo +.Nm command is fully described in the document -.I "Amd - The 4.4BSD Automounter" -.SH "SEE ALSO" -.BR amd (8), -.BR mount (8), -.BR mountd (8). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH HISTORY +.%T "Amd - The 4.4BSD Automounter" +and in the +.Nm amd +section in +.Xr info 1 . +.Sh "SEE ALSO" +.Xr amd 8 , +.Xr mount 8 , +.Xr mountd 8 +.Sh HISTORY The -.B fsinfo -command first appeared in 4.4BSD. -.SH AUTHORS -Jan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK. -.P -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.Nm +command first appeared in +.Bx 4.4 . diff --git a/contrib/amd/fsinfo/fsinfo.c b/contrib/amd/fsinfo/fsinfo.c index e441a47..21f80382 100644 --- a/contrib/amd/fsinfo/fsinfo.c +++ b/contrib/amd/fsinfo/fsinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -37,7 +37,8 @@ * SUCH DAMAGE. * * - * File: am-utils/fsinfo/fsinfo.c + * $Id: fsinfo.c,v 1.5.2.7 2004/05/12 15:54:31 ezk Exp $ + * $FreeBSD$ * */ @@ -124,7 +125,7 @@ fsi_get_args(int c, char *v[]) break; case 'h': - xstrlcpy(hostname, optarg, sizeof(hostname)); + strncpy(hostname, optarg, sizeof(hostname) - 1); break; case 'e': @@ -156,8 +157,7 @@ fsi_get_args(int c, char *v[]) case 'I': case 'D': case 'U': - /* sizeof(iptr) is actually that of idvbuf. See declaration above */ - xsnprintf(iptr, sizeof(idvbuf), "-%c%s ", ch, optarg); + sprintf(iptr, "-%c%s ", ch, optarg); iptr += strlen(iptr); break; @@ -198,7 +198,7 @@ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\ static char * find_username(void) { - const char *u = getlogin(); + char *u = getlogin(); if (!u) { struct passwd *pw = getpwuid(getuid()); @@ -235,7 +235,6 @@ main(int argc, char *argv[]) perror("gethostname"); exit(1); } - hostname[sizeof(hostname) - 1] = '\0'; /* * Get the username diff --git a/contrib/amd/hlfsd/hlfsd.8 b/contrib/amd/hlfsd/hlfsd.8 index 8c6fb49..9ef049f 100644 --- a/contrib/amd/hlfsd/hlfsd.8 +++ b/contrib/amd/hlfsd/hlfsd.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,288 +36,317 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: hlfsd.8,v 1.11.2.1 2006/01/02 18:48:25 ezk Exp $ +.\" $Id: hlfsd.8,v 1.3.2.5 2004/01/06 03:15:23 ezk Exp $ +.\" $FreeBSD$ .\" .\" HLFSD was written at Columbia University Computer Science Department, by .\" Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@smarts.com> .\" It is distributed under the same terms and conditions as AMD. .\" -.TH HLFSD 8 "14 September 1993" -.SH NAME -hlfsd \- home-link file system daemon -.SH SYNOPSIS -.B hlfsd -[ -.B \-fhnpvC -] [ -.BI \-a " alt_dir" -] [ -.BI \-c " cache-interval" -] [ -.BI \-g " group" -] [ -.BI \-i " reload-interval" -] [ -.BI \-l " logfile" -] [ -.BI \-o " mount-options" -] [ -.BI \-x " log-options" -] [ -.BI \-D " debug-options" -] [ -.BI \-P " password-file" -] -[ -.I linkname -.RI [ " subdir " ] -] -.SH DESCRIPTION -.B Hlfsd -is a daemon which implements a filesystem containing a symbolic link to +.Dd September 14, 1993 +.Dt HLFSD 8 +.Os +.Sh NAME +.Nm hlfsd +.Nd home-link file system daemon +.Sh SYNOPSIS +.Nm +.Op Fl fhnpvC +.Op Fl a Ar alt_dir +.Bk -words +.Op Fl c Ar cache-interval +.Ek +.Op Fl g Ar group +.Bk -words +.Op Fl i Ar reload-interval +.Ek +.Op Fl l Ar logfile +.Bk -words +.Op Fl o Ar mount-options +.Op Fl x Ar log-options +.Op Fl D Ar debug-options +.Op Fl P Ar password-file +.Ek +.Op linkname Op subdir +.Sh DESCRIPTION +.Nm +is a daemon which implements a file system containing a symbolic link to subdirectory within a user's home directory, depending on the user -which accessed that link. It was primarily designed to redirect +which accessed that link. +It was primarily designed to redirect incoming mail to users' home directories, so that it can read from anywhere. -.LP -.B Hlfsd +.Pp +.Nm operates by mounting itself as an -.SM NFS +.Tn NFS server for the directory containing -.IR linkname , +.Ar linkname , which defaults to -.BR /hlfs/home . +.Pa /hlfs/home . Lookups within that directory are handled by -.BR hlfsd , +.Nm hlfsd , which uses the password map to determine how to resolve the lookup. -The directory will be created if it doesn't already exist. The symbolic link will be to the accessing user's home directory, with -.I subdir -appended to it. If not specified, -.I subdir +The +directory will be created if it does not already exist. +The symbolic link will +be to the accessing user's home directory, with +.Ar subdir +appended to it. +If not specified, +.Ar subdir defaults to -.BR .hlfsdir . +.Pa .hlfsdir . This directory will also be created if it does not already exist. -.LP -A SIGTERM sent to -.B hlfsd -will cause it to shutdown. A SIGHUP will flush the internal -caches, and reload the password map. It will also close and -reopen the log file, to enable the original log file to be -removed or rotated. A SIGUSR1 will cause it to dump its internal -table of user IDs and home directories to the file -.BR /usr/tmp/hlfsd.dump.XXXXXX . -.SH OPTIONS -.TP -.BI \-a " alt_dir" -Alternate directory. The name of the directory to which +.Pp +A +.Er SIGHUP +will flush the internal caches, and reload the password map. +It will also +close and reopen the log file, to enable the original log file to be removed +or rotated. +A +.Er SIGUSR1 +will cause it to dump its internal table of user IDs and home directories to +the file +.Pa /usr/tmp/hlfsd.dump.XXXXXX . +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl a Ar alt_dir +Alternate directory. +The name of the directory to which the symbolic link returned by -.B hlfsd -will point, if it cannot access the home directory of the user. This +.Nm +will point, if it cannot access the home directory of the user. +This defaults to -.BR /var/hlfs . -This directory will be created if it doesn't exist. It is expected +.Pa /var/hlfs . +This directory will be created if it does not exist. +It is expected that either users will read these files, or the system administrators -will run a script to resend this "lost mail" to its owner. -.TP -.BI \-c " cache-interval" +will run a script to resend this +.Dq lost mail +to its owner. +.It Fl c Ar cache-interval Caching interval. -.B Hlfsd +.Nm will cache the validity of home directories for this interval, in -seconds. Entries which have been verified within the last -.I cache-interval +seconds. +Entries which have been verified within the last +.Ar cache-interval seconds will not be verified again, since the operation could be expensive, and the entries are most likely still valid. After the interval has expired, -.B hlfsd +.Nm will re-verify the validity of the user's home directory, and -reset the cache time-counter. The default value for -.I cache-interval -is 300 seconds (5 minutes). -.TP -.B \-f -Force fast startup. This option tells -.B hlfsd +reset the cache time-counter. +The default value for +.Ar cache-interval +is 300 seconds +(5 minutes). +.It Fl f +Force fast startup. +This option tells +.Nm to skip startup-time consistency checks such as existence of mount directory, alternate spool directory, symlink to be hidden under the mount directory, their permissions and validity. -.TP -.BI \-g " group" -Set the special group HLFS_GID to -.IR group . +.It Fl g Ar group +Set the special group +.Va HLFS_GID +to +.Ar group . Programs such as -.B from -or -.BR comsat , -which access the mailboxes of other users) must be setgid HLFS_GID to -work properly. The default group is "hlfs". If no group is provided, -and there is no group "hlfs", this feature is disabled. -.TP -.B \-h -Help. Print a brief help message, and exit. -.TP -.BI \-i " reload-interval" -Map-reloading interval. Each -.I reload-interval +.Ic comsat , +(which access the mailboxes of other users) +must be setgid +.Va HLFS_GID +to work properly. +The default group is +.Dq hlfs . +If no group is provided, and there is no group +.Dq hlfs , +this feature is disabled. +.It Fl h +Help. +Print a brief help message, and exit. +.It Fl i Ar reload-interval +Map-reloading interval. +Each +.Ar reload-interval seconds, -.B hlfsd +.Nm will reload the password map. -.B Hlfsd +.Nm needs the password map for the UIDs and home directory pathnames. -.B Hlfsd -schedules a SIGALRM to reload the password maps. A SIGHUP sent to -.B hlfsd -will force it to reload the maps immediately. The default -value for -.I reload-interval -is 900 seconds (15 minutes.) -.TP -.BI \-l " logfile" +.Nm +schedules a +.Va SIGALRM +to reload the password maps. +A +.Va SIGHUP +sent to +.Nm +will force it to reload the maps immediately. +The default value for +.Ar reload-interval +is 900 seconds +(15 minutes). +.It Fl l Ar logfile Specify a log file to which -.B hlfsd -will record events. If -.I logfile +.Nm +will record events. +If +.Pa logfile is the string -.B syslog +.Pa syslog then the log messages will be sent to the system log daemon by -.IR syslog (3), -using the LOG_DAEMON facility. +.Xr syslog 3 , +using the +.Va LOG_DAEMON +facility. This is also the default. -.TP -.B \-n +.It Fl n No verify. -.B Hlfsd +.Nm will not verify the validity of the symbolic link it will be returning, or that the user's home directory contains -sufficient disk-space for spooling. This can speed up -.B hlfsd +sufficient disk-space for spooling. +This can speed up +.Nm at the cost of possibly returning symbolic links to home directories which are not currently accessible or are full. By default, -.B hlfsd +.Nm validates the symbolic-link in the background. The -.B \-n +.Fl n option overrides the meaning of the -.B \-c +.Fl c option, since no caching is necessary. -.TP -.BI \-o " mount-options" -Mount options. Mount options which -.B hlfsd +.It Fl o Ar mount-options +Mount options. +Mount options which +.Nm will use to mount itself on top of -.I dirname. +.Pa dirname . By default, -.IR mount-options -is set to "ro". If the system supports symbolic-link caching, default -options are set to "ro,nocache". -.TP -.B \-p -Print PID. +.Ar mount-options +is set to +.Qq ro . +If the system supports symbolic-link caching, default +options are set to +.Qq ro,nocache . +.It Fl p +Prints +.Va PID . Outputs the process-id of -.B hlfsd +.Nm to standard output where it can be saved into a file. -.TP -.B \-v -Version. Displays version information to standard error. -.TP -.BI \-x " log-options" -Specify run-time logging options. The options are a comma separated +.It Fl v +Version. +Displays version information to standard error. +.It Fl x Ar log-options +Specify run-time logging options. +The options are a comma separated list chosen from: fatal, error, user, warn, info, map, stats, all. -.TP -.BI \-C +.It Fl C Force -.B hlfsd -to run on systems that cannot turn off the NFS attribute-cache. Use of +.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 mis-delivery 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. -.TP -.BI \-D " log-options" -Select from a variety of debugging options. Prefixing an +.It Fl D Ar log-options +Select from a variety of debugging options. +Prefixing an option with the string -.B no -reverses the effect of that option. Options are cumulative. +.Qq no +reverses the effect of that option. +Options are cumulative. The most useful option is -.BR all . +.Em all . Since this option is only used for debugging other options are not -documented here. A fuller description is available in the program -source. A SIGUSR1 sent to -.B hlfsd +documented here. +A fuller description is available in the program +source. +A +.Va SIGUSR1 +sent to +.Nm will cause it to dump its internal password map to the file -.BR /usr/tmp/hlfsd.dump.XXXXXX . -.TP -.BI \-P " password-file" +.Pa /usr/tmp/hlfsd.dump.XXXXXX . +.It Fl P Ar password-file Read the user-name, user-id, and home directory information from the file -.I password-file. +.Ar password-file . Normally, -.B hlfsd +.Nm will use -.IR getpwent (3) -to read the password database. This option allows you to override the +.Xr getpwent 3 +to read the password database. +This option allows you to override the default database, and is useful if you want to map users' mail files to a -directory other than their home directory. Only the username, uid, and +directory other than their home directory. +Only the username, uid, and home-directory fields of the file -.I password-file -are read and checked. All other fields are ignored. The file -.I password-file -must otherwise be compliant with Unix System 7 colon-delimited format -.IR passwd (4). -.SH FILES -.TP 5 -.B /hlfs +.Ar password-file +are read and checked. +All other fields are ignored. +The file +.Ar password-file +must be compliant with +.Ux +System 7 colon-delimited format +.Xr passwd 5 . +.El +.Sh FILES +.Bl -tag -width /axx +.It Pa /hlfs directory under which -.B hlfsd +.Nm mounts itself and manages the symbolic link -.BR home . -.TP 5 -.B .hlfsdir +.Pa home . +.It Pa .hlfsdir default sub-directory in the user's home directory, to which the -.B home +.Pa home symbolic link returned by -.B hlfsd +.Nm points. -.TP 5 -.B /var/hlfs +.It Pa /var/hlfs directory to which -.B home +.Pa home symbolic link returned by -.B hlfsd +.Nm points if it is unable to verify the that user's home directory is accessible. -.SH "SEE ALSO" -.BR amd (8), -.BR automount (8), -.BR cron(8), -.BR getgrent (3), -.BR getpwent (3), -.BR mail(1), -.BR mnttab (4), -.BR mount (8), -.BR mtab (5), -.BR passwd (4), -.BR sendmail (8), -.BR umount (8). -.LP -.IR "HLFSD: Delivering Email to Your $HOME" , -in -.IR "Proc. LISA-VII, The 7th Usenix System Administration Conference" , -November 1993. -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.SH AUTHORS -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -and -Alexander Dupuy <dupuy@smarts.com>, System Management ARTS, -White Plains, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.El +.Sh SEE ALSO +.Xr mail 1 , +.Xr getgrent 3 , +.Xr getpwent 3 , +.Xr mtab 5 , +.Xr passwd 5 , +.Xr amd 8 , +.Xr cron 8 , +.Xr mount 8 , +.Xr sendmail 8 , +.Xr umount 8 +.Rs +.%T HLFSD: Delivering Email to Your $HOME +.%B Proc. LISA-VII, The 7th Usenix System Administration Conference +.%D November 1993 +.Re +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . +.Sh AUTHORS +.An Erez Zadok Aq ezk@cs.columbia.edu , +Department of Computer Science, Columbia University, +New York, USA. +.Pp +.An Alexander Dupuy Aq dupuy@smarts.com , +System Management ARTS, White Plains, New York, USA. diff --git a/contrib/amd/hlfsd/hlfsd.c b/contrib/amd/hlfsd/hlfsd.c index 8703f59..17ee61f 100644 --- a/contrib/amd/hlfsd/hlfsd.c +++ b/contrib/amd/hlfsd/hlfsd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/hlfsd/hlfsd.c + * $Id: hlfsd.c,v 1.7.2.9 2004/01/19 00:25:55 ezk Exp $ + * $FreeBSD$ * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu> @@ -84,7 +86,7 @@ char *logfile = DEFAULT_LOGFILE; char *passwdfile = NULL; /* alternate passwd file to use */ char *slinkname = 0; char hostname[MAXHOSTNAMELEN + 1] = "localhost"; -u_int cache_interval = DEFAULT_CACHE_INTERVAL; +int cache_interval = DEFAULT_CACHE_INTERVAL; gid_t hlfs_gid = (gid_t) INVALIDID; int masterpid = 0; int noverify = 0; @@ -120,17 +122,6 @@ usage(void) } -void -fatalerror(char *str) -{ -#define ERRM ": %m" - size_t l = strlen(str) + sizeof(ERRM) - 1; - char *tmp = strnsave(str, l); - xstrlcat(tmp, ERRM, l); - fatal(tmp); -} - - int main(int argc, char *argv[]) { @@ -318,12 +309,12 @@ main(int argc, char *argv[]) *dot = '\0'; orig_umask = umask(0); if (logfile) - switch_to_logfile(logfile, orig_umask, 0); + switch_to_logfile(logfile, orig_umask); -#ifndef MOUNT_TABLE_ON_FILE - if (amuDebug(D_MTAB)) +#if defined(DEBUG) && !defined(MOUNT_TABLE_ON_FILE) + if (debug_flags & D_MTAB) dlog("-D mtab option ignored"); -#endif /* not MOUNT_TABLE_ON_FILE */ +#endif /* defined(DEBUG) && !defined(MOUNT_TABLE_ON_FILE) */ /* avoid hanging on other NFS servers if started elsewhere */ if (chdir("/") < 0) @@ -347,6 +338,8 @@ main(int argc, char *argv[]) exit(3); } + clock_valid = 0; /* invalidate logging clock */ + if (!forcefast) { /* make sure mount point exists and is at least mode 555 */ if (stat(dir_name, &stmodes) < 0) @@ -391,7 +384,7 @@ main(int argc, char *argv[]) chmod(alt_spooldir, OPEN_SPOOLMODE); /* create failsafe link to alternate spool directory */ - *(slinkname-1) = '/'; /* unsplit dir_name to include link */ + slinkname[-1] = '/'; /* unsplit dir_name to include link */ if (lstat(dir_name, &stmodes) == 0 && (stmodes.st_mode & S_IFMT) != S_IFLNK) { fprintf(stderr, "%s: failsafe %s not a symlink\n", @@ -412,7 +405,7 @@ main(int argc, char *argv[]) } } - *(slinkname-1) = '\0'; /* resplit dir_name */ + slinkname[-1] = '\0'; /* resplit dir_name */ } /* end of "if (!forcefast) {" */ /* @@ -428,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); @@ -441,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); @@ -449,57 +442,53 @@ main(int argc, char *argv[]) signal(SIGCHLD, reaper); #endif /* not HAVE_SIGACTION */ +#ifdef DEBUG /* - * In the parent, if -D daemon, we don't need to + * In the parent, if -D nodaemon (or -D daemon) , we don't need to * set this signal handler. */ - if (!amuDebug(D_DAEMON)) { + amuDebug(D_DAEMON) { +#endif /* DEBUG */ + /* XXX: port to use pure svr4 signals */ s = -99; while (stoplight != SIGUSR2) { plog(XLOG_INFO, "parent waits for child to setup (stoplight=%d)", stoplight); -#ifdef HAVE_SIGSUSPEND - { - sigset_t mask; - sigemptyset(&mask); - s = sigsuspend(&mask); /* wait for child to set up */ - } -#else /* not HAVE_SIGSUSPEND */ s = sigpause(0); /* wait for child to set up */ -#endif /* not HAVE_SIGSUSPEND */ sleep(1); } +#ifdef DEBUG } +#endif /* DEBUG */ /* * setup options to mount table (/etc/{mtab,mnttab}) entry */ - xsnprintf(hostpid_fs, sizeof(hostpid_fs), - "%s:(pid%d)", hostname, masterpid); + sprintf(hostpid_fs, "%s:(pid%d)", hostname, masterpid); memset((char *) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = dir_name; /* i.e., "/mail" */ mnt.mnt_fsname = hostpid_fs; if (mntopts) { mnt.mnt_opts = mntopts; } else { - xstrlcpy(preopts, default_mntopts, sizeof(preopts)); + strcpy(preopts, default_mntopts); /* * Turn off all kinds of attribute and symlink caches as * much as possible. Also make sure that mount does not * show up to df. */ #ifdef MNTTAB_OPT_INTR - xstrlcat(preopts, ",", sizeof(preopts)); - xstrlcat(preopts, MNTTAB_OPT_INTR, sizeof(preopts)); + strcat(preopts, ","); + strcat(preopts, MNTTAB_OPT_INTR); #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_IGNORE - xstrlcat(preopts, ",", sizeof(preopts)); - xstrlcat(preopts, MNTTAB_OPT_IGNORE, sizeof(preopts)); + strcat(preopts, ","); + strcat(preopts, MNTTAB_OPT_IGNORE); #endif /* MNTTAB_OPT_IGNORE */ #ifdef MNT2_GEN_OPT_CACHE - xstrlcat(preopts, ",nocache", sizeof(preopts)); + strcat(preopts, ",nocache"); #endif /* MNT2_GEN_OPT_CACHE */ #ifdef MNT2_NFS_OPT_SYMTTL - xstrlcat(preopts, ",symttl=0", sizeof(preopts)); + strcat(preopts, ",symttl=0"); #endif /* MNT2_NFS_OPT_SYMTTL */ mnt.mnt_opts = preopts; } @@ -510,15 +499,11 @@ main(int argc, char *argv[]) * If they don't appear to support the either the "ignore" mnttab * option entry, or the "auto" one, set the mount type to "nfs". */ -#ifdef HIDE_MOUNT_TYPE mnt.mnt_type = HIDE_MOUNT_TYPE; -#else /* not HIDE_MOUNT_TYPE */ - mnt.mnt_type = "nfs"; -#endif /* not HIDE_MOUNT_TYPE */ /* some systems don't have a mount type, but a mount flag */ #ifndef HAVE_TRANSPORT_TYPE_TLI - amu_get_myaddress(&localsocket.sin_addr, NULL); + amu_get_myaddress(&localsocket.sin_addr); localsocket.sin_family = AF_INET; localsocket.sin_port = htons(nfsxprt->xp_port); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ @@ -527,13 +512,11 @@ main(int argc, char *argv[]) * Update hostname field. * Make some name prog:pid (i.e., hlfsd:174) for hostname */ - xsnprintf(progpid_fs, sizeof(progpid_fs), - "%s:%d", am_get_progname(), masterpid); + sprintf(progpid_fs, "%s:%d", am_get_progname(), masterpid); /* Most kernels have a name length restriction. */ if ((int) strlen(progpid_fs) >= (int) MAXHOSTNAMELEN) - xstrlcpy(progpid_fs + MAXHOSTNAMELEN - 3, "..", - sizeof(progpid_fs) - MAXHOSTNAMELEN + 3); + strcpy(progpid_fs + MAXHOSTNAMELEN - 3, ".."); genflags = compute_mount_flags(&mnt); @@ -541,7 +524,7 @@ main(int argc, char *argv[]) if (retry <= 0) retry = 1; /* XXX */ - memmove(&anh.v2, root_fhp, sizeof(*root_fhp)); + memmove(&anh.v2.fhs_fh, root_fhp, sizeof(*root_fhp)); #ifdef HAVE_TRANSPORT_TYPE_TLI compute_nfs_args(&nfs_args, &mnt, @@ -567,7 +550,6 @@ main(int argc, char *argv[]) compute_nfs_args(&nfs_args, &mnt, genflags, - NULL, &localsocket, NFS_VERSION, /* version 2 */ "udp", /* XXX: shouldn't this be "udp"? */ @@ -583,26 +565,33 @@ main(int argc, char *argv[]) *************************************************************************/ compute_automounter_nfs_args(&nfs_args, &mnt); + clock_valid = 0; /* invalidate logging clock */ + +/* + * The following code could be cleverly ifdef-ed, but I duplicated the + * mount_fs call three times for simplicity and readability. + */ +#ifdef DEBUG /* * For some reason, this mount may have to be done in the background, if I am - * using -D daemon. I suspect that the actual act of mounting requires + * using -D nodebug. I suspect that the actual act of mounting requires * calling to hlfsd itself to invoke one or more of its nfs calls, to stat - * /mail. That means that even if you say -D daemon, at least the mount + * /mail. That means that even if you say -D nodaemon, at least the mount * of hlfsd itself on top of /mail will be done in the background. * The other alternative I have is to run svc_run, but set a special * signal handler to perform the mount in N seconds via some alarm. * -Erez Zadok. */ - if (!amuDebug(D_DAEMON)) { /* Normal case */ - plog(XLOG_INFO, "normal NFS mounting hlfsd service points"); - if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name, 0) < 0) + if (debug_flags & D_DAEMON) { /* asked for -D daemon */ + plog(XLOG_INFO, "parent NFS mounting hlfsd service points"); + if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name) < 0) fatal("nfsmount: %m"); - } else { /* asked for -D daemon */ + } else { /* asked for -D nodaemon */ if (fork() == 0) { /* child runs mount */ am_set_mypid(); foreground = 0; plog(XLOG_INFO, "child NFS mounting hlfsd service points"); - if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name, 0) < 0) { + if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name) < 0) { fatal("nfsmount: %m"); } exit(0); /* all went well */ @@ -610,6 +599,11 @@ main(int argc, char *argv[]) plog(XLOG_INFO, "parent waiting 1sec for mount..."); } } +#else /* not DEBUG */ + plog(XLOG_INFO, "normal NFS mounting hlfsd service points"); + if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 2, "udp", mnttab_file_name) < 0) + fatal("nfsmount: %m"); +#endif /* not DEBUG */ #ifdef HAVE_TRANSPORT_TYPE_TLI /* @@ -627,14 +621,15 @@ main(int argc, char *argv[]) printf("%d\n", masterpid); plog(XLOG_INFO, "hlfsd ready to serve"); +#ifdef DEBUG /* - * If asked not to fork a daemon (-D daemon), then hlfsd_init() + * If asked not to fork a daemon (-D nodaemon), then hlfsd_init() * will not run svc_run. We must start svc_run here. */ - if (amuDebug(D_DAEMON)) { - plog(XLOG_DEBUG, "starting no-daemon debugging svc_run"); + dlog("starting no-daemon debugging svc_run"); + amuDebugNo(D_DAEMON) svc_run(); - } +#endif /* DEBUG */ cleanup(0); /* should never happen here */ return (0); /* everything went fine? */ @@ -649,16 +644,20 @@ hlfsd_init(void) struct sigaction sa; #endif /* HAVE_SIGACTION */ + clock_valid = 0; /* invalidate logging clock */ + /* * Initialize file handles. */ plog(XLOG_INFO, "initializing hlfsd file handles"); hlfsd_init_filehandles(); +#ifdef DEBUG /* - * If not -D daemon then we must fork. + * If -D daemon then we must fork. */ - if (!amuDebug(D_DAEMON)) + amuDebug(D_DAEMON) +#endif /* DEBUG */ child = fork(); if (child < 0) @@ -687,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); @@ -703,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); @@ -716,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); @@ -733,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); @@ -748,14 +747,17 @@ hlfsd_init(void) if (setitimer(ITIMER_REAL, &reloadinterval, (struct itimerval *) 0) < 0) fatal("setitimer: %m"); - clocktime(&startup); + gettimeofday((struct timeval *) ((void *)&startup), (struct timezone *) 0); +#ifdef DEBUG /* - * If not -D daemon, then start serving here in the child, - * and the parent will exit. But if -D daemon, then + * If -D daemon, then start serving here in the child, + * and the parent will exit. But if -D nodaemon, then * skip this code and make sure svc_run is entered elsewhere. */ - if (!amuDebug(D_DAEMON)) { + amuDebug(D_DAEMON) { +#endif /* DEBUG */ + /* * Dissociate from the controlling terminal */ @@ -770,7 +772,9 @@ hlfsd_init(void) plog(XLOG_INFO, "starting svc_run"); svc_run(); cleanup(0); /* should never happen, just in case */ - } +#ifdef DEBUG + } /* end of code that runs iff hlfsd daemonizes */ +#endif /* DEBUG */ } @@ -788,6 +792,8 @@ reload(int signum) int child; int status; + clock_valid = 0; /* invalidate logging clock */ + if (getpid() != masterpid) return; @@ -796,7 +802,7 @@ reload(int signum) * can be rotated) */ if (signum == SIGHUP && logfile) - switch_to_logfile(logfile, orig_umask, 0); + switch_to_logfile(logfile, orig_umask); /* * parent performs the reload, while the child continues to serve @@ -839,21 +845,29 @@ cleanup(int signum) struct stat stbuf; int umount_result; - if (!amuDebug(D_DAEMON)) { + clock_valid = 0; /* invalidate logging clock */ + +#ifdef DEBUG + amuDebug(D_DAEMON) +#endif /* DEBUG */ if (getpid() != masterpid) return; +#ifdef DEBUG + amuDebug(D_DAEMON) +#endif /* DEBUG */ if (fork() != 0) { masterpid = 0; am_set_mypid(); return; } - } am_set_mypid(); for (;;) { - while ((umount_result = UMOUNT_FS(dir_name, mnttab_file_name, 0)) == EBUSY) { + while ((umount_result = UMOUNT_FS(dir_name, mnttab_file_name)) == EBUSY) { +#ifdef DEBUG dlog("cleanup(): umount delaying for 10 seconds"); +#endif /* DEBUG */ sleep(10); } if (stat(dir_name, &stbuf) == 0 && stbuf.st_ino == ROOTID) { @@ -865,14 +879,19 @@ cleanup(int signum) break; } - if (!amuDebug(D_DAEMON)) { - plog(XLOG_INFO, "cleanup(): killing processes and terminating"); +#ifdef DEBUG + dlog("cleanup(): killing processes and terminating"); + amuDebug(D_DAEMON) +#endif /* DEBUG */ kill(masterpid, SIGKILL); + +#ifdef DEBUG + amuDebug(D_DAEMON) +#endif /* DEBUG */ kill(serverpid, SIGKILL); - } plog(XLOG_INFO, "hlfsd terminating with status 0\n"); - _exit(0); + exit(0); } @@ -882,7 +901,7 @@ reaper(int signum) int result; if (wait(&result) == masterpid) { - _exit(4); + exit(4); } } @@ -913,7 +932,7 @@ fatal(char *mess) if (!STREQ(&mess[messlen + 1 - sizeof(ERRM)], ERRM)) fprintf(stderr, "%s: %s\n", am_get_progname(), mess); else { - xstrlcpy(lessmess, mess, sizeof(lessmess)); + strcpy(lessmess, mess); lessmess[messlen - 4] = '\0'; fprintf(stderr, "%s: %s: %s\n", diff --git a/contrib/amd/hlfsd/hlfsd.h b/contrib/amd/hlfsd/hlfsd.h index ed136b6..2334d1b 100644 --- a/contrib/amd/hlfsd/hlfsd.h +++ b/contrib/amd/hlfsd/hlfsd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/hlfsd/hlfsd.h + * $Id: hlfsd.h,v 1.4.2.7 2004/01/06 03:15:23 ezk Exp $ + * $FreeBSD$ * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu> @@ -99,6 +101,9 @@ # define DEFAULT_LOGFILE 0 #endif /* not HAVE)_SYSLOG */ +#define ERRM ": %m" +#define fatalerror(str) \ + (fatal (strcat (strnsave ((str), strlen ((str)) + sizeof (ERRM) - 1), ERRM))) /* * TYPEDEFS: @@ -139,14 +144,14 @@ extern char *mailbox(int, char *); extern char *passwdfile; extern char *slinkname; extern gid_t hlfs_gid; -extern u_int cache_interval; +extern int cache_interval; extern int noverify; extern int serverpid; extern int untab_index(char *username); extern am_nfs_fh *root_fhp; extern am_nfs_fh root; extern nfstime startup; -extern uid2home_t *plt_search(u_int); +extern uid2home_t *plt_search(int); extern username2uid_t *untab; /* user name table */ extern void fatal(char *); extern void plt_init(void); diff --git a/contrib/amd/hlfsd/homedir.c b/contrib/amd/hlfsd/homedir.c index 2ade32f..eef883a 100644 --- a/contrib/amd/hlfsd/homedir.c +++ b/contrib/amd/hlfsd/homedir.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/hlfsd/homedir.c + * $Id: homedir.c,v 1.5.2.11 2004/01/06 03:15:23 ezk Exp $ + * $FreeBSD$ * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu> @@ -65,7 +67,7 @@ static struct passwd passwd_ent; static uid2home_t *lastchild; static uid2home_t *pwtab; static void delay(uid2home_t *, int); -static void table_add(u_int, const char *, const char *); +static void table_add(int, const char *, const char *); static char mboxfile[MAXPATHLEN]; static char *root_home; /* root's home directory */ @@ -89,6 +91,8 @@ homedir(int userid, int groupid) struct stat homestat; int old_groupid, old_userid; + clock_valid = 0; /* invalidate logging clock */ + if ((found = plt_search(userid)) == (uid2home_t *) NULL) { return alt_spooldir; /* use alt spool for unknown uid */ } @@ -99,9 +103,9 @@ homedir(int userid, int groupid) return alt_spooldir; /* use alt spool for / or rel. home */ } if ((int) userid == 0) /* force all uid 0 to use root's home */ - xsnprintf(linkval, sizeof(linkval), "%s/%s", root_home, home_subdir); + sprintf(linkval, "%s/%s", root_home, home_subdir); else - xsnprintf(linkval, sizeof(linkval), "%s/%s", homename, home_subdir); + sprintf(linkval, "%s/%s", homename, home_subdir); if (noverify) { found->last_status = 0; @@ -132,18 +136,41 @@ homedir(int userid, int groupid) } } +#ifdef DEBUG /* - * only run this forking code if did not ask for -D fork + * only run this forking code if asked for -D fork + * or if did not ask for -D nofork */ - if (!amuDebug(D_FORK)) { + 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) { @@ -151,17 +178,21 @@ homedir(int userid, int groupid) return alt_spooldir; } if (found->child) { /* PARENT */ +#ifdef DEBUG if (lastchild) - dlog("cache spill uid = %ld, pid = %ld, home = %s", + plog(XLOG_INFO, "cache spill uid = %ld, pid = %ld, home = %s", (long) lastchild->uid, (long) lastchild->child, lastchild->home); +#endif /* DEBUG */ lastchild = found; return (char *) NULL; /* return NULL to parent, so it can continue */ } - } +#ifdef DEBUG + } /* end of Debug(D_FORK) */ +#endif /* DEBUG */ /* - * CHILD: (or parent if -D fork) + * CHILD: (or parent if -D nofork) * * Check and create dir if needed. * Check disk space and/or quotas too. @@ -227,7 +258,9 @@ hlfsd_diskspace(char *path) char buf[MAXPATHLEN]; int fd, len; - xsnprintf(buf, sizeof(buf), "%s/._hlfstmp_%lu", path, (long) getpid()); + clock_valid = 0; /* invalidate logging clock */ + + sprintf(buf, "%s/._hlfstmp_%lu", path, (long) getpid()); if ((fd = open(buf, O_RDWR | O_CREAT, 0600)) < 0) { plog(XLOG_ERROR, "cannot open %s: %m", buf); return -1; @@ -265,7 +298,10 @@ delay(uid2home_t *found, int secs) { struct timeval tv; - dlog("delaying on child %ld for %d seconds", (long) found->child, secs); +#ifdef DEBUG + if (found) + dlog("delaying on child %ld for %d seconds", (long) found->child, secs); +#endif /* DEBUG */ tv.tv_usec = 0; @@ -288,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); } } } @@ -395,18 +456,15 @@ mailbox(int uid, char *username) if ((home = homeof(username)) == (char *) NULL) return (char *) NULL; if (STREQ(home, "/")) - xsnprintf(mboxfile, sizeof(mboxfile), - "/%s/%s", home_subdir, username); + sprintf(mboxfile, "/%s/%s", home_subdir, username); else - xsnprintf(mboxfile, sizeof(mboxfile), - "%s/%s/%s", home, home_subdir, username); + sprintf(mboxfile, "%s/%s/%s", home, home_subdir, username); return mboxfile; } static int plt_compare_fxn(const voidp x, const voidp y) - { uid2home_t *i = (uid2home_t *) x; uid2home_t *j = (uid2home_t *) y; @@ -481,6 +539,8 @@ hlfsd_getpwent(void) return getpwent(); } + clock_valid = 0; /* invalidate logging clock */ + /* return here to read another entry */ readent: @@ -503,8 +563,7 @@ readent: plog(XLOG_ERROR, "no user name on line %d of %s", passwd_line, passwdfile); goto readent; } - /* pw_name will show up in passwd_ent.pw_name */ - xstrlcpy(pw_name, cp, sizeof(pw_name)); + strcpy(pw_name, cp); /* will show up in passwd_ent.pw_name */ /* skip passwd */ strtok(NULL, ":"); @@ -527,8 +586,7 @@ readent: plog(XLOG_ERROR, "no home dir on line %d of %s", passwd_line, passwdfile); goto readent; } - /* pw_dir will show up in passwd_ent.pw_dir */ - xstrlcpy(pw_dir, cp, sizeof(pw_dir)); + strcpy(pw_dir, cp); /* will show up in passwd_ent.pw_dir */ /* the rest of the fields are unimportant and not being considered */ @@ -591,6 +649,8 @@ plt_reset(void) { int i; + clock_valid = 0; /* invalidate logging clock */ + hlfsd_setpwent(); if (hlfsd_getpwent() == (struct passwd *) NULL) { hlfsd_endpwent(); @@ -631,10 +691,12 @@ plt_reset(void) * n: user ID name */ static void -table_add(u_int u, const char *h, const char *n) +table_add(int u, const char *h, const char *n) { int i; + clock_valid = 0; /* invalidate logging clock */ + if (max_pwtab_num <= 0) { /* was never initialized */ max_pwtab_num = 1; pwtab = (uid2home_t *) xmalloc(max_pwtab_num * @@ -665,8 +727,10 @@ table_add(u_int u, const char *h, const char *n) /* do NOT add duplicate entries (this is an O(N^2) algorithm... */ for (i=0; i<cur_pwtab_num; ++i) if (u == pwtab[i].uid && u != 0 ) { +#ifdef DEBUG dlog("ignoring duplicate home %s for uid %d (already %s)", h, u, pwtab[i].home); +#endif /* DEBUG */ return; } @@ -694,7 +758,7 @@ table_add(u_int u, const char *h, const char *n) * return entry in lookup table */ uid2home_t * -plt_search(u_int u) +plt_search(int u) { int max, min, mid; diff --git a/contrib/amd/include/am_defs.h b/contrib/amd/include/am_defs.h index c2185db..19d2a3b 100644 --- a/contrib/amd/include/am_defs.h +++ b/contrib/amd/include/am_defs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/include/am_defs.h + * $Id: am_defs.h,v 1.15.2.16 2004/05/12 15:54:31 ezk Exp $ + * $FreeBSD$ * */ @@ -68,6 +70,26 @@ char *strchr(), *strrchr(), *strdup(); #endif /* not STDC_HEADERS */ +/* AIX requires this to be the first thing in the file. */ +#ifndef __GNUC__ +# if HAVE_ALLOCA_H +# include <alloca.h> +# else /* not HAVE_ALLOCA_H */ +# ifdef _AIX +/* + * This pragma directive is indented so that pre-ANSI C compilers will + * ignore it, rather than choke on it. + */ + #pragma alloca +# else /* not _AIX */ +# ifndef alloca +/* predefined by HP cc +Olibcalls */ +voidp alloca(); +# endif /* not alloca */ +# endif /* not _AIX */ +# endif /* not HAVE_ALLOCA_H */ +#endif /* not __GNUC__ */ + /* * Handle gcc __attribute__ if available. */ @@ -104,15 +126,6 @@ char *strchr(), *strrchr(), *strdup(); */ #if TIME_WITH_SYS_TIME # include <sys/time.h> -# ifdef _ALL_SOURCE -/* - * AIX 5.2 needs struct sigevent from signal.h to be defined, but I - * don't want to move the inclusion of signal.h this early into this - * file. Luckily, amd doesn't need the size of this structure in any - * other structure that it uses. So we sidestep it for now. - */ -struct sigevent; -# endif /* _ALL_SOURCE */ # include <time.h> #else /* not TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H @@ -146,13 +159,6 @@ struct sigevent; #endif /* HAVE_SYS_TYPES_H */ /* - * Actions to take if HAVE_LIMITS_H is defined. - */ -#if HAVE_LIMITS_H_H -# include <limits.h> -#endif /* HAVE_LIMITS_H */ - -/* * Actions to take if HAVE_UNISTD_H is defined. */ #if HAVE_UNISTD_H @@ -207,12 +213,6 @@ struct sigevent; * Actions to take if HAVE_FCNTL_H is defined. */ #if HAVE_FCNTL_H -# ifdef HAVE_LINUX_LOOP_H -/* so I can mount large files as loop devices */ -/* XXX: need to move these two LARGEFILE defines to a better place */ -# define _LARGEFILE64_SOURCE -# define __USE_LARGEFILE64 -# endif /* HAVE_LINUX_LOOP_H */ # include <fcntl.h> #endif /* HAVE_FCNTL_H */ @@ -365,13 +365,6 @@ extern int errno; #endif /* HAVE_NET_ERRNO_H */ /* - * Actions to take if <net/if.h> exists. - */ -#ifdef HAVE_NET_IF_H -# include <net/if.h> -#endif /* HAVE_NET_IF_H */ - -/* * Actions to take if <net/route.h> exists. */ #ifdef HAVE_NET_ROUTE_H @@ -405,11 +398,11 @@ extern int errno; #endif /* HAVE_SYS_MBUF_H */ /* - * Actions to take if <sys/mman.h> exists. + * Actions to take if <net/if.h> exists. */ -#ifdef HAVE_SYS_MMAN_H -# include <sys/mman.h> -#endif /* HAVE_SYS_MMAN_H */ +#ifdef HAVE_NET_IF_H +# include <net/if.h> +#endif /* HAVE_NET_IF_H */ /* * Actions to take if <netdb.h> exists. @@ -607,77 +600,15 @@ struct ypall_callback; #endif /* HAVE_CDFS_CDFSMOUNT_H */ /* - * Actions to take if <linux/loop.h> exists. - */ -#ifdef HAVE_LINUX_LOOP_H -# ifdef HAVE_LINUX_POSIX_TYPES_H -# include <linux/posix_types.h> -# endif /* HAVE_LINUX_POSIX_TYPES_H */ -/* next dev_t lines needed due to changes in kernel code */ -# undef dev_t -# define dev_t unsigned short /* compatible with Red Hat and SuSE */ -# include <linux/loop.h> -#endif /* HAVE_LINUX_LOOP_H */ - -/* - * AUTOFS PROTOCOL HEADER FILES: - */ - -/* - * Actions to take if <linux/auto_fs[4].h> exists. + * Actions to take if <linux/auto_fs.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_LINUX_AUTO_FS4_H -# include <linux/auto_fs4.h> -#else /* not HAVE_LINUX_AUTO_FS4_H */ -# ifdef HAVE_LINUX_AUTO_FS_H -# include <linux/auto_fs.h> -# endif /* HAVE_LINUX_AUTO_FS_H */ -#endif /* not HAVE_LINUX_AUTO_FS4_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 <rpcsvc/autofs_prot.h> or <sys/fs/autofs_prot.h> exist. - */ -#ifdef HAVE_RPCSVC_AUTOFS_PROT_H -# include <rpcsvc/autofs_prot.h> -#else /* not HAVE_RPCSVC_AUTOFS_PROT_H */ -# ifdef HAVE_SYS_FS_AUTOFS_PROT_H -# include <sys/fs/autofs_prot.h> -# endif /* HAVE_SYS_FS_AUTOFS_PROT_H */ -#endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */ - -/* - * Actions to take if <lber.h> exists. - * This header file is required before <ldap.h> can be included. - */ -#ifdef HAVE_LBER_H -# include <lber.h> -#endif /* HAVE_LBER_H */ - -/* - * Actions to take if <ldap.h> exists. - */ -#ifdef HAVE_LDAP_H -# include <ldap.h> -#endif /* HAVE_LDAP_H */ - -/**************************************************************************** - ** IMPORTANT!!! ** - ** We always include am-utils' amu_autofs_prot.h. ** - ** That is actually defined in "conf/autofs/autofs_${autofs_style}.h" ** - ****************************************************************************/ -#include <amu_autofs_prot.h> - +#ifdef HAVE_LINUX_AUTO_FS_H +# include <linux/auto_fs.h> +#endif /* HAVE_LINUX_AUTO_FS_H */ /* * NFS PROTOCOL HEADER FILES: @@ -692,7 +623,7 @@ struct ypall_callback; /**************************************************************************** ** IMPORTANT!!! ** - ** We always include am-utils' amu_nfs_prot.h. ** + ** We always include am-util's amu_nfs_prot.h. ** ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" ** ****************************************************************************/ #include <amu_nfs_prot.h> @@ -735,29 +666,13 @@ struct ypall_callback; #ifdef HAVE_SYS_FS_NFS_CLNT_H # include <sys/fs/nfs_clnt.h> #endif /* HAVE_SYS_FS_NFS_CLNT_H */ - -/* complex rules for linux/nfs_mount.h: broken on so many systems */ #ifdef HAVE_LINUX_NFS_MOUNT_H -# ifndef _LINUX_NFS_H -# define _LINUX_NFS_H -# endif /* not _LINUX_NFS_H */ -# ifndef _LINUX_NFS2_H -# define _LINUX_NFS2_H -# endif /* not _LINUX_NFS2_H */ -# ifndef _LINUX_NFS3_H -# define _LINUX_NFS3_H -# endif /* not _LINUX_NFS3_H */ -# ifndef _LINUX_NFS_FS_H -# define _LINUX_NFS_FS_H -# endif /* not _LINUX_NFS_FS_H */ -# ifndef _LINUX_IN_H -# define _LINUX_IN_H -# endif /* not _LINUX_IN_H */ -# ifndef __KERNEL__ -# define __KERNEL__ -# endif /* __KERNEL__ */ +# define _LINUX_NFS_H +# define _LINUX_NFS2_H +# define _LINUX_NFS3_H +# define _LINUX_NFS_FS_H +# define _LINUX_IN_H # include <linux/nfs_mount.h> -# undef __KERNEL__ #endif /* HAVE_LINUX_NFS_MOUNT_H */ /* @@ -775,6 +690,21 @@ struct ypall_callback; #endif /* HAVE_HESIOD_H */ /* + * Actions to take if <lber.h> exists. + * This header file is required before <ldap.h> can be included. + */ +#ifdef HAVE_LBER_H +# include <lber.h> +#endif /* HAVE_LBER_H */ + +/* + * Actions to take if <ldap.h> exists. + */ +#ifdef HAVE_LDAP_H +# include <ldap.h> +#endif /* HAVE_LDAP_H */ + +/* * Actions to take if <arpa/nameser.h> exists. * Should be included before <resolv.h>. */ @@ -807,14 +737,6 @@ struct sockaddr_dl; * Actions to take if <resolv.h> exists. */ #ifdef HAVE_RESOLV_H -/* - * On AIX 5.2, both <resolv.h> and <arpa/nameser_compat.h> define MAXDNAME, - * if compiling with gcc -D_USE_IRS (so that we get extern definitions for - * hstrerror() and others). - */ -# if defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) -# undef MAXDNAME -# endif /* defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) */ # include <resolv.h> #endif /* HAVE_RESOLV_H */ @@ -845,10 +767,6 @@ struct sockaddr_dl; #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H # include <msdosfs/msdosfsmount.h> #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */ - -/* - * Actions to take if <fs/msdosfs/msdosfsmount.h> exists. - */ #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H # include <fs/msdosfs/msdosfsmount.h> #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ @@ -866,12 +784,14 @@ struct sockaddr_dl; #ifdef HAVE_SYS_FS_UFS_MOUNT_H # include <sys/fs/ufs_mount.h> #endif /* HAVE_SYS_FS_UFS_MOUNT_H */ -#ifdef HAVE_UFS_UFS_UFSMOUNT_H_off -# error do not include this file here because on netbsd/openbsd it -# error causes errors with other header files. Instead, add it to the -# error specific conf/nfs_prot_*.h file. +/* + * HAVE_UFS_UFS_UFSMOUNT_H should NOT be defined on netbsd/openbsd because it + * causes errors with other header files. Instead, add it to the specific + * conf/nfs_prot_*.h file. + */ +#ifdef HAVE_UFS_UFS_UFSMOUNT_H # include <ufs/ufs/ufsmount.h> -#endif /* HAVE_UFS_UFS_UFSMOUNT_H_off */ +#endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* * Actions to take if <sys/fs/efs_clnt.h> exists. @@ -1001,22 +921,6 @@ struct sockaddr_dl; * Actions to take if <rpcsvc/nis.h> exists. */ #ifdef HAVE_RPCSVC_NIS_H -/* - * Solaris 10 (build 72) defines GROUP_OBJ in <sys/acl.h>, which is included - * in many other header files. <rpcsvc/nis.h> uses GROUP_OBJ inside enum - * zotypes. So if you're unlucky enough to include both headers, you get a - * compile error because the two symbols conflict. - * A similar conflict arises with Sun cc and the definition of "GROUP". - * - * Temp hack: undefine acl.h's GROUP_OBJ and GROUP because they're not needed - * for am-utils. - */ -# ifdef GROUP_OBJ -# undef GROUP_OBJ -# endif /* GROUP_OBJ */ -# ifdef GROUP -# undef GROUP -# endif /* GROUP */ # include <rpcsvc/nis.h> #endif /* HAVE_RPCSVC_NIS_H */ @@ -1221,13 +1125,6 @@ extern char *nc_sperror(void); #endif /* HAVE_SYS_STATFS_H */ /* - * Actions to take if <sys/statvfs.h> exists. - */ -#ifdef HAVE_SYS_STATVFS_H -# include <sys/statvfs.h> -#endif /* HAVE_SYS_STATVFS_H */ - -/* * Actions to take if <sys/vfs.h> exists. */ #ifdef HAVE_SYS_VFS_H @@ -1320,13 +1217,6 @@ extern char *nc_sperror(void); # include <regex.h> #endif /* HAVE_REGEX_H */ -/* - * Actions to take if <tcpd.h> exists. - */ -#if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) -# include <tcpd.h> -#endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ - /****************************************************************************/ /* @@ -1408,16 +1298,6 @@ typedef struct _am_mntent { # endif /* not HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ -/* - * Provide FD_* macros for systems that lack them. - */ -#ifndef FD_SET -# define FD_SET(fd, set) (*(set) |= (1 << (fd))) -# define FD_ISSET(fd, set) (*(set) & (1 << (fd))) -# define FD_CLR(fd, set) (*(set) &= ~(1 << (fd))) -# define FD_ZERO(set) (*(set) = 0) -#endif /* not FD_SET */ - /* * Complete external definitions missing from some systems. @@ -1474,10 +1354,6 @@ extern int getpagesize(void); extern char *getwd(char *s); #endif /* not HAVE_EXTERN_GETWD */ -#if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) -extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, char *client_user); -#endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) */ - #ifndef HAVE_EXTERN_INNETGR extern int innetgr(char *, char *, char *, char *); #endif /* not HAVE_EXTERN_INNETGR */ @@ -1498,10 +1374,6 @@ extern int seteuid(uid_t euid); extern int setitimer(int, struct itimerval *, struct itimerval *); #endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */ -#ifndef HAVE_EXTERN_SLEEP -extern unsigned int sleep(unsigned int seconds); -#endif /* not HAVE_EXTERN_SETITIMER */ - #ifndef HAVE_EXTERN_STRCASECMP /* * define this extern even if function does not exist, for it will @@ -1518,22 +1390,6 @@ extern int strcasecmp(const char *s1, const char *s2); extern char *strdup(const char *s); #endif /* not HAVE_EXTERN_STRDUP */ -#ifndef HAVE_EXTERN_STRLCAT -/* - * define this extern even if function does not exist, for it will - * be filled in by libamu/strlcat.c - */ -extern size_t strlcat(char *dst, const char *src, size_t siz); -#endif /* not HAVE_EXTERN_STRLCAT */ - -#ifndef HAVE_EXTERN_STRLCPY -/* - * define this extern even if function does not exist, for it will - * be filled in by libamu/strlcpy.c - */ -extern size_t strlcpy(char *dst, const char *src, size_t siz); -#endif /* not HAVE_EXTERN_STRLCPY */ - #if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) extern char *strstr(const char *s1, const char *s2); #endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */ @@ -1569,11 +1425,11 @@ extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth); #ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE # include <amu_nfs_prot.h> #endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */ -#include <am_compat.h> -#include <am_xdr_func.h> #include <am_utils.h> #include <amq_defs.h> #include <aux_conf.h> +/* compatibility with old amd, while autoconfiscating it */ +#include <am_compat.h> /****************************************************************************/ @@ -1582,14 +1438,14 @@ extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth); * and those are probably declared in any of the above headers. */ -#ifdef HAVE_HASMNTOPT -# ifdef HAVE_BAD_HASMNTOPT -extern char *amu_hasmntopt(mntent_t *mnt, char *opt); -# else /* not HAVE_BAD_HASMNTOPT */ -# define amu_hasmntopt hasmntopt -# endif /* not HAVE_BAD_HASMNTOPT */ -#else /* not HAVE_HASMNTOPT */ -extern char *amu_hasmntopt(mntent_t *mnt, char *opt); +#ifndef HAVE_HASMNTOPT +extern char *hasmntopt(mntent_t *mnt, char *opt); #endif /* not HAVE_HASMNTOPT */ +/* + * include definitions of all possible xdr functions that are otherwise + * not defined elsewhere. + */ +#include <am_xdr_func.h> + #endif /* not _AM_DEFS_H */ diff --git a/contrib/amd/libamu/clnt_sperrno.c b/contrib/amd/libamu/clnt_sperrno.c deleted file mode 100644 index d3b48d1..0000000 --- a/contrib/amd/libamu/clnt_sperrno.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1997-1998 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 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. - * - * %W% (Berkeley) %G% - * - * $Id: clnt_sperrno.c,v 5.2.2.1 1992/02/09 15:08:40 jsp beta $ - * - */ - -/* - * Early RPC seems to be missing these.. - * Extracted from the RPC 3.9 sources as indicated - */ - -/* @(#)clnt_perror.c 1.1 87/11/04 3.9 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif /* HAVE_CONFIG_H */ -#include <am_defs.h> -#include <amu.h> - - -struct rpc_errtab { - enum clnt_stat status; - char *message; -}; - -static struct rpc_errtab rpc_errlist[] = -{ - {RPC_SUCCESS, - "RPC: Success"}, - {RPC_CANTENCODEARGS, - "RPC: Can't encode arguments"}, - {RPC_CANTDECODERES, - "RPC: Can't decode result"}, - {RPC_CANTSEND, - "RPC: Unable to send"}, - {RPC_CANTRECV, - "RPC: Unable to receive"}, - {RPC_TIMEDOUT, - "RPC: Timed out"}, - {RPC_VERSMISMATCH, - "RPC: Incompatible versions of RPC"}, - {RPC_AUTHERROR, - "RPC: Authentication error"}, - {RPC_PROGUNAVAIL, - "RPC: Program unavailable"}, - {RPC_PROGVERSMISMATCH, - "RPC: Program/version mismatch"}, - {RPC_PROCUNAVAIL, - "RPC: Procedure unavailable"}, - {RPC_CANTDECODEARGS, - "RPC: Server can't decode arguments"}, - {RPC_SYSTEMERROR, - "RPC: Remote system error"}, - {RPC_UNKNOWNHOST, - "RPC: Unknown host"}, -/* { RPC_UNKNOWNPROTO, - * "RPC: Unknown protocol" }, */ - {RPC_PMAPFAILURE, - "RPC: Port mapper failure"}, - {RPC_PROGNOTREGISTERED, - "RPC: Program not registered"}, - {RPC_FAILED, - "RPC: Failed (unspecified error)"} -}; - - -/* - * This interface for use by clntrpc - */ -char * -clnt_sperrno(enum clnt_stat stat) -{ - int i; - - for (i = 0; i < sizeof(rpc_errlist) / sizeof(struct rpc_errtab); i++) { - if (rpc_errlist[i].status == stat) { - return (rpc_errlist[i].message); - } - } - return ("RPC: (unknown error code)"); -} diff --git a/contrib/amd/libamu/mount_fs.c b/contrib/amd/libamu/mount_fs.c index 74f064e..e134c90 100644 --- a/contrib/amd/libamu/mount_fs.c +++ b/contrib/amd/libamu/mount_fs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/libamu/mount_fs.c + * $Id: mount_fs.c,v 1.11.2.12 2004/01/06 03:15:24 ezk Exp $ + * $FreeBSD$ * */ @@ -49,10 +51,9 @@ /* ensure that mount table options are delimited by a comma */ -#define append_opts(old, l, new) { \ - if (*(old) != '\0') \ - xstrlcat(old, ",", l); \ - xstrlcat(old, new, l); } +#define append_opts(old, new) { \ + if (*(old) != '\0') strcat(old, ","); \ + strcat(old, new); } /* * Standard mount flags @@ -107,9 +108,7 @@ struct opt_tab mnt_flags[] = /* * Do not define MNT2_NFS_OPT_* entries here! This is for generic - * mount(2) options only, not for NFS mount options. If you need to put - * something here, it's probably not the right place: see - * include/am_compat.h. + * mount(2) options only, not for NFS mount options. */ {0, 0} @@ -124,7 +123,7 @@ compute_mount_flags(mntent_t *mntp) int flags = 0; #ifdef MNT2_GEN_OPT_NEWTYPE - flags |= MNT2_GEN_OPT_NEWTYPE; + flags = MNT2_GEN_OPT_NEWTYPE; #endif /* MNT2_GEN_OPT_NEWTYPE */ #ifdef MNT2_GEN_OPT_AUTOMOUNTED flags |= MNT2_GEN_OPT_AUTOMOUNTED; @@ -134,7 +133,7 @@ compute_mount_flags(mntent_t *mntp) * Crack basic mount options */ for (opt = mnt_flags; opt->opt; opt++) { - flags |= amu_hasmntopt(mntp, opt->opt) ? opt->flag : 0; + flags |= hasmntopt(mntp, opt->opt) ? opt->flag : 0; } return flags; @@ -159,33 +158,31 @@ compute_automounter_mount_flags(mntent_t *mntp) int -mount_fs(mntent_t *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type, u_long nfs_version, const char *nfs_proto, const char *mnttabname, int on_autofs) +mount_fs(mntent_t *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type, u_long nfs_version, const char *nfs_proto, const char *mnttabname) { int error = 0; #ifdef MOUNT_TABLE_ON_FILE +# ifdef MNTTAB_OPT_DEV + struct stat stb; +# endif /* MNTTAB_OPT_DEV */ char *zopts = NULL, *xopts = NULL; - size_t l; +# if defined(MNTTAB_OPT_DEV) || (defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS)) || defined(MNTTAB_OPT_PROTO) + char optsbuf[48]; +# endif /* defined(MNTTAB_OPT_DEV) || (defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS)) || defined(MNTTAB_OPT_PROTO) */ #endif /* MOUNT_TABLE_ON_FILE */ - char *mnt_dir = 0; - -#ifdef NEED_AUTOFS_SPACE_HACK - char *old_mnt_dir = 0; - /* perform space hack */ - if (on_autofs) { - old_mnt_dir = mnt->mnt_dir; - mnt->mnt_dir = mnt_dir = autofs_strdup_space_hack(old_mnt_dir); - } else -#endif /* NEED_AUTOFS_SPACE_HACK */ - mnt_dir = strdup(mnt->mnt_dir); - dlog("'%s' fstype " MTYPE_PRINTF_TYPE " (%s) flags %#x (%s)", - mnt_dir, type, mnt->mnt_type, flags, mnt->mnt_opts); +#ifdef DEBUG + dlog("%s fstype " MTYPE_PRINTF_TYPE " (%s) flags %#x (%s)", + mnt->mnt_dir, type, mnt->mnt_type, flags, mnt->mnt_opts); +#endif /* DEBUG */ again: + clock_valid = 0; + error = MOUNT_TRAP(type, mnt, flags, mnt_data); if (error < 0) { - plog(XLOG_ERROR, "'%s': mount: %m", mnt_dir); + plog(XLOG_ERROR, "%s: mount: %m", mnt->mnt_dir); /* * The following code handles conditions which shouldn't * occur. They are possible either because amd screws up @@ -193,18 +190,33 @@ again: * messed with the mount point. Both have been known to * happen. -- stolcke 2/22/95 */ - if (errno == EBUSY) { + if (errno == ENOENT) { + /* + * Occasionally the mount point vanishes, probably + * due to some race condition. Just recreate it + * as necessary. + */ + errno = mkdirs(mnt->mnt_dir, 0555); + if (errno != 0 && errno != EEXIST) + plog(XLOG_ERROR, "%s: mkdirs: %m", mnt->mnt_dir); + else { + plog(XLOG_WARNING, "extra mkdirs required for %s", + mnt->mnt_dir); + error = MOUNT_TRAP(type, mnt, flags, mnt_data); + } + } else if (errno == EBUSY) { /* * Also, sometimes unmount isn't called, e.g., because * our mountlist is garbled. This leaves old mount * points around which need to be removed before we * can mount something new in their place. */ - errno = umount_fs(mnt_dir, mnttabname, on_autofs); + errno = umount_fs(mnt->mnt_dir, mnttabname); if (errno != 0) - plog(XLOG_ERROR, "'%s': umount: %m", mnt_dir); + plog(XLOG_ERROR, "%s: umount: %m", mnt->mnt_dir); else { - plog(XLOG_WARNING, "extra umount required for '%s'", mnt_dir); + plog(XLOG_WARNING, "extra umount required for %s", + mnt->mnt_dir); error = MOUNT_TRAP(type, mnt, flags, mnt_data); } } @@ -214,16 +226,8 @@ again: sleep(1); goto again; } - -#ifdef NEED_AUTOFS_SPACE_HACK - /* Undo space hack */ - if (on_autofs) - mnt->mnt_dir = old_mnt_dir; -#endif /* NEED_AUTOFS_SPACE_HACK */ - if (error < 0) { - error = errno; - goto out; + return errno; } #ifdef MOUNT_TABLE_ON_FILE @@ -231,28 +235,23 @@ again: * Allocate memory for options: * dev=..., vers={2,3}, proto={tcp,udp} */ - l = strlen(mnt->mnt_opts) + 48; - zopts = (char *) xmalloc(l); + zopts = (char *) xmalloc(strlen(mnt->mnt_opts) + 48); /* copy standard options */ xopts = mnt->mnt_opts; - xstrlcpy(zopts, xopts, l); + strcpy(zopts, xopts); # ifdef MNTTAB_OPT_DEV - { - /* add the extra dev= field to the mount table */ - struct stat stb; - if (lstat(mnt_dir, &stb) == 0) { - char optsbuf[48]; - if (sizeof(stb.st_dev) == 2) /* e.g. SunOS 4.1 */ - xsnprintf(optsbuf, sizeof(optsbuf), "%s=%04lx", - MNTTAB_OPT_DEV, (u_long) stb.st_dev & 0xffff); - else /* e.g. System Vr4 */ - xsnprintf(optsbuf, sizeof(optsbuf), "%s=%08lx", - MNTTAB_OPT_DEV, (u_long) stb.st_dev); - append_opts(zopts, l, optsbuf); - } + /* add the extra dev= field to the mount table */ + if (lstat(mnt->mnt_dir, &stb) == 0) { + if (sizeof(stb.st_dev) == 2) /* e.g. SunOS 4.1 */ + sprintf(optsbuf, "%s=%04lx", + MNTTAB_OPT_DEV, (u_long) stb.st_dev & 0xffff); + else /* e.g. System Vr4 */ + sprintf(optsbuf, "%s=%08lx", + MNTTAB_OPT_DEV, (u_long) stb.st_dev); + append_opts(zopts, optsbuf); } # endif /* MNTTAB_OPT_DEV */ @@ -263,10 +262,8 @@ again: */ if (nfs_version == NFS_VERSION3 && hasmntval(mnt, MNTTAB_OPT_VERS) != NFS_VERSION3) { - char optsbuf[48]; - xsnprintf(optsbuf, sizeof(optsbuf), - "%s=%d", MNTTAB_OPT_VERS, NFS_VERSION3); - append_opts(zopts, l, optsbuf); + sprintf(optsbuf, "%s=%d", MNTTAB_OPT_VERS, NFS_VERSION3); + append_opts(zopts, optsbuf); } # endif /* defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS) */ @@ -275,10 +272,9 @@ again: * add the extra proto={tcp,udp} field to the mount table, * unless already specified by user. */ - if (nfs_proto && !amu_hasmntopt(mnt, MNTTAB_OPT_PROTO)) { - char optsbuf[48]; - xsnprintf(optsbuf, sizeof(optsbuf), "%s=%s", MNTTAB_OPT_PROTO, nfs_proto); - append_opts(zopts, l, optsbuf); + if (nfs_proto && !hasmntopt(mnt, MNTTAB_OPT_PROTO)) { + sprintf(optsbuf, "%s=%s", MNTTAB_OPT_PROTO, nfs_proto); + append_opts(zopts, optsbuf); } # endif /* MNTTAB_OPT_PROTO */ @@ -294,15 +290,14 @@ again: # endif /* HAVE_MNTENT_T_MNT_CNODE */ # ifdef HAVE_MNTENT_T_MNT_RO - mnt->mnt_ro = (amu_hasmntopt(mnt, MNTTAB_OPT_RO) != NULL); + mnt->mnt_ro = (hasmntopt(mnt, MNTTAB_OPT_RO) != NULL); # endif /* HAVE_MNTENT_T_MNT_RO */ # ifdef HAVE_MNTENT_T_MNT_TIME # ifdef HAVE_MNTENT_T_MNT_TIME_STRING { /* allocate enough space for a long */ - size_t l = 13 * sizeof(char); - char *str = (char *) xmalloc(l); - xsnprintf(str, l, "%ld", time((time_t *) NULL)); + char *str = (char *) xmalloc(13 * sizeof(char)); + sprintf(str, "%ld", time((time_t *) NULL)); mnt->mnt_time = str; } # else /* not HAVE_MNTENT_T_MNT_TIME_STRING */ @@ -320,126 +315,7 @@ again: # endif /* MNTTAB_OPT_DEV */ #endif /* MOUNT_TABLE_ON_FILE */ - out: - XFREE(mnt_dir); - return error; -} - - -/* - * Compute all NFS attribute cache related flags separately. Note that this - * function now computes attribute-cache flags for both Amd's automount - * points (NFS) as well as any normal NFS mount that Amd performs. Edit - * with caution. - */ -static void -compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) -{ - int acval = 0; - int err_acval = 1; /* 1 means we found no 'actimeo' value */ -#if defined(HAVE_NFS_ARGS_T_ACREGMIN) || defined(HAVE_NFS_ARGS_T_ACREGMAX) || defined(HAVE_NFS_ARGS_T_ACDIRMIN) || defined(HAVE_NFS_ARGS_T_ACDIRMAX) - int err_acrdmm; /* for ac{reg,dir}{min,max} */ -#endif /* HAVE_NFS_ARGS_T_AC{REG,DIR}{MIN,MAX} */ - - /************************************************************************/ - /*** ATTRIBUTE CACHES ***/ - /************************************************************************/ - /* - * acval is set to 0 at the top of the function. If actimeo mount option - * exists and defined in mntopts, then its acval is set to it. - * If the value is non-zero, then we set all attribute cache fields to it. - * If acval is zero, it means it was never defined in mntopts or the - * actimeo mount option does not exist, in which case we check for - * individual mount options per attribute cache. - * Regardless of the value of acval, mount flags are set based directly - * on the values of the attribute caches. - */ -#ifdef MNTTAB_OPT_ACTIMEO - err_acval = hasmntvalerr(mntp, MNTTAB_OPT_ACTIMEO, &acval); /* attr cache timeout (sec) */ -#endif /* MNTTAB_OPT_ACTIMEO */ - - /*** acregmin ***/ -#ifdef HAVE_NFS_ARGS_T_ACREGMIN - err_acrdmm = 1; /* 1 means we found no acregmin value */ - if (!err_acval) { - nap->acregmin = acval; /* min ac timeout for reg files (sec) */ - } else { -# ifdef MNTTAB_OPT_ACREGMIN - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMIN, (int *) &nap->acregmin); -# else /* not MNTTAB_OPT_ACREGMIN */ - nap->acregmin = 0; -# endif /* not MNTTAB_OPT_ACREGMIN */ - } - /* set this flag iff we changed acregmin (possibly to zero) */ -# ifdef MNT2_NFS_OPT_ACREGMIN - if (!err_acval || !err_acrdmm) - nap->flags |= MNT2_NFS_OPT_ACREGMIN; -# endif /* MNT2_NFS_OPT_ACREGMIN */ -#endif /* HAVE_NFS_ARGS_T_ACREGMIN */ - - /*** acregmax ***/ -#ifdef HAVE_NFS_ARGS_T_ACREGMAX - err_acrdmm = 1; /* 1 means we found no acregmax value */ - if (!err_acval) { - nap->acregmax = acval; /* max ac timeout for reg files (sec) */ - } else { -# ifdef MNTTAB_OPT_ACREGMAX - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMAX, (int *) &nap->acregmax); -# else /* not MNTTAB_OPT_ACREGMAX */ - nap->acregmax = 0; -# endif /* not MNTTAB_OPT_ACREGMAX */ - } - /* set this flag iff we changed acregmax (possibly to zero) */ -# ifdef MNT2_NFS_OPT_ACREGMAX - if (!err_acval || !err_acrdmm) - nap->flags |= MNT2_NFS_OPT_ACREGMAX; -# endif /* MNT2_NFS_OPT_ACREGMAX */ -#endif /* HAVE_NFS_ARGS_T_ACREGMAX */ - - /*** acdirmin ***/ -#ifdef HAVE_NFS_ARGS_T_ACDIRMIN - err_acrdmm = 1; /* 1 means we found no acdirmin value */ - if (!err_acval) { - nap->acdirmin = acval; /* min ac timeout for dirs (sec) */ - } else { -# ifdef MNTTAB_OPT_ACDIRMIN - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMIN, (int *) &nap->acdirmin); -# else /* not MNTTAB_OPT_ACDIRMIN */ - nap->acdirmin = 0; -# endif /* not MNTTAB_OPT_ACDIRMIN */ - } - /* set this flag iff we changed acdirmin (possibly to zero) */ -# ifdef MNT2_NFS_OPT_ACDIRMIN - if (!err_acval || !err_acrdmm) - nap->flags |= MNT2_NFS_OPT_ACDIRMIN; -# endif /* MNT2_NFS_OPT_ACDIRMIN */ -#endif /* HAVE_NFS_ARGS_T_ACDIRMIN */ - - /*** acdirmax ***/ -#ifdef HAVE_NFS_ARGS_T_ACDIRMAX - err_acrdmm = 1; /* 1 means we found no acdirmax value */ - if (!err_acval) { - nap->acdirmax = acval; /* max ac timeout for dirs (sec) */ - } else { -# ifdef MNTTAB_OPT_ACDIRMAX - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMAX, (int *) &nap->acdirmax); -# else /* not MNTTAB_OPT_ACDIRMAX */ - nap->acdirmax = 0; -# endif /* not MNTTAB_OPT_ACDIRMAX */ - } - /* set this flag iff we changed acdirmax (possibly to zero) */ -# ifdef MNT2_NFS_OPT_ACDIRMAX - if (!err_acval || !err_acrdmm) - nap->flags |= MNT2_NFS_OPT_ACDIRMAX; -# endif /* MNT2_NFS_OPT_ACDIRMAX */ -#endif /* HAVE_NFS_ARGS_T_ACDIRMAX */ - - - /* don't cache attributes */ -#if defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC) - if (amu_hasmntopt(mntp, MNTTAB_OPT_NOAC) != NULL) - nap->flags |= MNT2_NFS_OPT_NOAC; -#endif /* defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC) */ + return 0; } @@ -458,28 +334,31 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) * fs_name: remote file system name to mount */ void -compute_nfs_args(nfs_args_t *nap, - mntent_t *mntp, - int genflags, - struct netconfig *nfsncp, - struct sockaddr_in *ip_addr, - u_long nfs_version, - char *nfs_proto, - am_nfs_handle_t *fhp, - char *host_name, - char *fs_name) +#ifdef HAVE_TRANSPORT_TYPE_TLI +compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name) +#else /* not HAVE_TRANSPORT_TYPE_TLI */ +compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name) +#endif /* not HAVE_TRANSPORT_TYPE_TLI */ { + int acval = 0; +#ifdef HAVE_FS_NFS3 + static am_nfs_fh3 fh3; /* static, b/c gcc on aix corrupts stack */ +#endif /* HAVE_FS_NFS3 */ + /* initialize just in case */ memset((voidp) nap, 0, sizeof(nfs_args_t)); - /* compute all of the NFS attribute-cache flags */ - compute_nfs_attrcache_flags(nap, mntp); - /************************************************************************/ /*** FILEHANDLE DATA AND LENGTH ***/ /************************************************************************/ #ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) { + memset((voidp) &fh3, 0, sizeof(am_nfs_fh3)); + fh3.fh3_length = fhp->v3.mountres3_u.mountinfo.fhandle.fhandle3_len; + memmove(fh3.fh3_u.data, + fhp->v3.mountres3_u.mountinfo.fhandle.fhandle3_val, + fh3.fh3_length); + # 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 @@ -487,9 +366,9 @@ compute_nfs_args(nfs_args_t *nap, * the file handle set in nfs_args be plain bytes, and not * include the length field. */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3.am_fh3_data); + NFS_FH_DREF(nap->NFS_FH_FIELD, &(fh3.fh3_u.data)); # else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3); + NFS_FH_DREF(nap->NFS_FH_FIELD, &fh3); # 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; @@ -499,12 +378,12 @@ compute_nfs_args(nfs_args_t *nap, # endif /* MNT2_NFS_OPT_VER3 */ } else #endif /* HAVE_FS_NFS3 */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v2); + NFS_FH_DREF(nap->NFS_FH_FIELD, &(fhp->v2.fhs_fh)); #ifdef HAVE_NFS_ARGS_T_FHSIZE # ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) - nap->fhsize = fhp->v3.am_fh3_length; + nap->fhsize = fh3.fh3_length; else # endif /* HAVE_FS_NFS3 */ nap->fhsize = FHSIZE; @@ -514,7 +393,7 @@ compute_nfs_args(nfs_args_t *nap, #ifdef HAVE_NFS_ARGS_T_FH_LEN # ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) - nap->fh_len = fhp->v3.am_fh3_length; + nap->fh_len = fh3.fh3_length; else # endif /* HAVE_FS_NFS3 */ nap->fh_len = FHSIZE; @@ -523,17 +402,75 @@ compute_nfs_args(nfs_args_t *nap, /************************************************************************/ /*** HOST NAME ***/ /************************************************************************/ - /* - * XXX: warning, using xstrlcpy in NFS_HN_DREF, which may corrupt a - * struct nfs_args, or truncate our concocted "hostname:/path" - * string prematurely. - */ NFS_HN_DREF(nap->hostname, host_name); #ifdef MNT2_NFS_OPT_HOSTNAME nap->flags |= MNT2_NFS_OPT_HOSTNAME; #endif /* MNT2_NFS_OPT_HOSTNAME */ /************************************************************************/ + /*** ATTRIBUTE CACHES ***/ + /************************************************************************/ + /* + * acval is set to 0 at the top of the function. If actimeo mount option + * exists and defined in mntopts, then it acval is set to it. + * If the value is non-zero, then we set all attribute cache fields to it. + * If acval is zero, it means it was never defined in mntopts or the + * actimeo mount option does not exist, in which case we check for + * individual mount options per attribute cache. + * Regardless of the value of acval, mount flags are set based directly + * on the values of the attribute caches. + */ +#ifdef MNTTAB_OPT_ACTIMEO + acval = hasmntval(mntp, MNTTAB_OPT_ACTIMEO); /* attr cache timeout (sec) */ +#endif /* MNTTAB_OPT_ACTIMEO */ + + if (acval) { +#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_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_NFS_ARGS_T_ACDIRMIN */ + } else { +#ifdef MNTTAB_OPT_ACREGMIN + nap->acregmin = hasmntval(mntp, MNTTAB_OPT_ACREGMIN); +#endif /* MNTTAB_OPT_ACREGMIN */ +#ifdef MNTTAB_OPT_ACREGMAX + nap->acregmax = hasmntval(mntp, MNTTAB_OPT_ACREGMAX); +#endif /* MNTTAB_OPT_ACREGMAX */ +#ifdef MNTTAB_OPT_ACDIRMIN + nap->acdirmin = hasmntval(mntp, MNTTAB_OPT_ACDIRMIN); +#endif /* MNTTAB_OPT_ACDIRMIN */ +#ifdef MNTTAB_OPT_ACDIRMAX + nap->acdirmax = hasmntval(mntp, MNTTAB_OPT_ACDIRMAX); +#endif /* MNTTAB_OPT_ACDIRMAX */ + } /* end of "if (acval)" statement */ + +#ifdef MNT2_NFS_OPT_ACREGMIN + if (nap->acregmin) + nap->flags |= MNT2_NFS_OPT_ACREGMIN; +#endif /* MNT2_NFS_OPT_ACREGMIN */ +#ifdef MNT2_NFS_OPT_ACREGMAX + if (nap->acregmax) + nap->flags |= MNT2_NFS_OPT_ACREGMAX; +#endif /* MNT2_NFS_OPT_ACREGMAX */ +#ifdef MNT2_NFS_OPT_ACDIRMIN + if (nap->acdirmin) + nap->flags |= MNT2_NFS_OPT_ACDIRMIN; +#endif /* MNT2_NFS_OPT_ACDIRMIN */ +#ifdef MNT2_NFS_OPT_ACDIRMAX + if (nap->acdirmax) + nap->flags |= MNT2_NFS_OPT_ACDIRMAX; +#endif /* MNT2_NFS_OPT_ACDIRMAX */ + +#ifdef MNTTAB_OPT_NOAC /* don't cache attributes */ + if (hasmntopt(mntp, MNTTAB_OPT_NOAC) != NULL) + nap->flags |= MNT2_NFS_OPT_NOAC; +#endif /* MNTTAB_OPT_NOAC */ + + /************************************************************************/ /*** IP ADDRESS OF REMOTE HOST ***/ /************************************************************************/ if (ip_addr) { @@ -587,9 +524,9 @@ compute_nfs_args(nfs_args_t *nap, /************************************************************************/ #ifdef MNT2_NFS_OPT_NOCONN /* check if user specified to use unconnected or connected sockets */ - if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCONN) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_NOCONN) != NULL) nap->flags |= MNT2_NFS_OPT_NOCONN; - else if (amu_hasmntopt(mntp, MNTTAB_OPT_CONN) != NULL) + else if (hasmntopt(mntp, MNTTAB_OPT_CONN) != NULL) nap->flags &= ~MNT2_NFS_OPT_NOCONN; else { /* @@ -617,7 +554,7 @@ compute_nfs_args(nfs_args_t *nap, #ifdef MNT2_NFS_OPT_RESVPORT # ifdef MNTTAB_OPT_RESVPORT - if (amu_hasmntopt(mntp, MNTTAB_OPT_RESVPORT) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_RESVPORT) != NULL) nap->flags |= MNT2_NFS_OPT_RESVPORT; # else /* not MNTTAB_OPT_RESVPORT */ nap->flags |= MNT2_NFS_OPT_RESVPORT; @@ -651,16 +588,12 @@ compute_nfs_args(nfs_args_t *nap, if (nap->rsize) nap->flags |= MNT2_NFS_OPT_RSIZE; #endif /* MNT2_NFS_OPT_RSIZE */ - if (nfs_version == NFS_VERSION && nap->rsize > 8192) - nap->rsize = 8192; nap->wsize = hasmntval(mntp, MNTTAB_OPT_WSIZE); #ifdef MNT2_NFS_OPT_WSIZE if (nap->wsize) nap->flags |= MNT2_NFS_OPT_WSIZE; #endif /* MNT2_NFS_OPT_WSIZE */ - if (nfs_version == NFS_VERSION && nap->wsize > 8192) - nap->wsize = 8192; nap->timeo = hasmntval(mntp, MNTTAB_OPT_TIMEO); #ifdef MNT2_NFS_OPT_TIMEO @@ -679,13 +612,11 @@ compute_nfs_args(nfs_args_t *nap, nap->flags |= MNT2_NFS_OPT_BIODS; #endif /* MNT2_NFS_OPT_BIODS */ -#ifdef MNT2_NFS_OPT_SOFT - if (amu_hasmntopt(mntp, MNTTAB_OPT_SOFT) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_SOFT) != NULL) nap->flags |= MNT2_NFS_OPT_SOFT; -#endif /* MNT2_NFS_OPT_SOFT */ #ifdef MNT2_NFS_OPT_SPONGY - if (amu_hasmntopt(mntp, MNTTAB_OPT_SPONGY) != NULL) { + if (hasmntopt(mntp, MNTTAB_OPT_SPONGY) != NULL) { nap->flags |= MNT2_NFS_OPT_SPONGY; if (nap->flags & MNT2_NFS_OPT_SOFT) { plog(XLOG_USER, "Mount opts soft and spongy are incompatible - soft ignored"); @@ -701,7 +632,7 @@ compute_nfs_args(nfs_args_t *nap, #endif /* defined(MNT2_GEN_OPT_RONLY) && defined(MNT2_NFS_OPT_RONLY) */ #ifdef MNTTAB_OPT_INTR - if (amu_hasmntopt(mntp, MNTTAB_OPT_INTR) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_INTR) != NULL) /* * Either turn on the "allow interrupts" option, or * turn off the "disallow interrupts" option" @@ -721,17 +652,17 @@ compute_nfs_args(nfs_args_t *nap, #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_NODEVS - if (amu_hasmntopt(mntp, MNTTAB_OPT_NODEVS) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_NODEVS) != NULL) nap->flags |= MNT2_NFS_OPT_NODEVS; #endif /* MNTTAB_OPT_NODEVS */ #ifdef MNTTAB_OPT_COMPRESS - if (amu_hasmntopt(mntp, MNTTAB_OPT_COMPRESS) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_COMPRESS) != NULL) nap->flags |= MNT2_NFS_OPT_COMPRESS; #endif /* MNTTAB_OPT_COMPRESS */ #ifdef MNTTAB_OPT_PRIVATE /* mount private, single-client tree */ - if (amu_hasmntopt(mntp, MNTTAB_OPT_PRIVATE) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_PRIVATE) != NULL) nap->flags |= MNT2_NFS_OPT_PRIVATE; #endif /* MNTTAB_OPT_PRIVATE */ @@ -746,38 +677,33 @@ compute_nfs_args(nfs_args_t *nap, #endif /* MNT2_NFS_OPT_PGTHRESH */ #if defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO) - if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCTO) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_NOCTO) != NULL) nap->flags |= MNT2_NFS_OPT_NOCTO; #endif /* defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO) */ #if defined(MNT2_NFS_OPT_POSIX) && defined(MNTTAB_OPT_POSIX) - if (amu_hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) { + if (hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) { nap->flags |= MNT2_NFS_OPT_POSIX; nap->pathconf = NULL; } #endif /* MNT2_NFS_OPT_POSIX && MNTTAB_OPT_POSIX */ #if defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) - if (amu_hasmntopt(mntp, MNTTAB_OPT_PROPLIST) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_PROPLIST) != NULL) nap->flags |= MNT2_NFS_OPT_PROPLIST; #endif /* defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) */ #if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS); - if (nap->maxgrouplist != 0) + if (nap->maxgrouplist != NULL) nap->flags |= MNT2_NFS_OPT_MAXGRPS; #endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */ #if defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) - if (amu_hasmntopt(mntp, MNTTAB_OPT_NOLOCK) != NULL) + if (hasmntopt(mntp, MNTTAB_OPT_NOLOCK) != NULL) nap->flags |= MNT2_NFS_OPT_NONLM; #endif /* defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) */ -#if defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE) - if (amu_hasmntopt(mntp, MNTTAB_OPT_XLATECOOKIE) != NULL) - nap->flags |= MNT2_NFS_OPT_XLATECOOKIE; -#endif /* defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE) */ - #ifdef HAVE_NFS_ARGS_T_OPTSTR nap->optstr = mntp->mnt_opts; #endif /* HAVE_NFS_ARGS_T_OPTSTR */ @@ -836,9 +762,28 @@ compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp) nap->flags |= MNT2_NFS_OPT_DUMBTIMR; #endif /* MNT2_NFS_OPT_DUMBTIMR */ - /* compute all of the NFS attribute-cache flags */ - compute_nfs_attrcache_flags(nap, mntp); - +#ifdef MNT2_NFS_OPT_NOAC + /* + * Don't cache attributes - they are changing under the kernel's feet. + * For example, IRIX5.2 will dispense with nfs lookup calls and hand stale + * filehandles to getattr unless we disable attribute caching on the + * automount points. + */ + nap->flags |= MNT2_NFS_OPT_NOAC; +#else /* not MNT2_NFS_OPT_NOAC */ + /* + * Setting these to 0 results in an error on some systems, which is why + * it's better to use "noac" if possible. + */ +# if defined(MNT2_NFS_OPT_ACREGMIN) && defined(MNT2_NFS_OPT_ACREGMAX) + nap->acregmin = nap->acregmax = 0; /* XXX: was 1, but why? */ + nap->flags |= MNT2_NFS_OPT_ACREGMIN | MNT2_NFS_OPT_ACREGMAX; +# endif /* defined(MNT2_NFS_OPT_ACREGMIN) && defined(MNT2_NFS_OPT_ACREGMAX) */ +# if defined(MNT2_NFS_OPT_ACDIRMIN) && defined(MNT2_NFS_OPT_ACDIRMAX) + nap->acdirmin = nap->acdirmax = 0; /* XXX: was 1, but why? */ + nap->flags |= MNT2_NFS_OPT_ACDIRMIN | MNT2_NFS_OPT_ACDIRMAX; +# endif /* defined(MNT2_NFS_OPT_ACDIRMIN) && defined(MNT2_NFS_OPT_ACDIRMAX) */ +#endif /* not MNT2_NFS_OPT_NOAC */ /* * Provide a slight bit more security by requiring the kernel to use * reserved ports. @@ -854,7 +799,7 @@ compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp) static char * get_hex_string(u_int len, const char *fhdata) { - u_int i; + int i; static char buf[128]; /* better not go over it! */ char str[16]; short int arr[64]; @@ -864,9 +809,9 @@ get_hex_string(u_int len, const char *fhdata) buf[0] = '\0'; memset(&arr[0], 0, (64 * sizeof(short int))); memcpy(&arr[0], &fhdata[0], len); - for (i=0; i<len/sizeof(unsigned short int); i++) { - xsnprintf(str, sizeof(str), "%04x", ntohs(arr[i])); - xstrlcat(buf, str, sizeof(buf)); + for (i=0; i<len/sizeof(short int); i++) { + sprintf(str, "%04x", ntohs(arr[i])); + strcat(buf, str); } return buf; } @@ -879,7 +824,7 @@ get_hex_string(u_int len, const char *fhdata) void print_nfs_args(const nfs_args_t *nap, u_long nfs_version) { - int fhlen = 32; /* default: NFS V.2 file handle length is 32 */ + int fhlen = 32; /* default: NFS V.2 file handle length is 32 */ #ifdef HAVE_TRANSPORT_TYPE_TLI struct netbuf *nbp; struct knetconfig *kncp; @@ -906,7 +851,7 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) nbp->maxlen, nbp->len, get_hex_string(nbp->len, nbp->buf)); nbp = nap->syncaddr; - plog(XLOG_DEBUG, "NA->syncaddr {netbuf} %p", nbp); + plog(XLOG_DEBUG, "NA->syncaddr {netbuf} 0x%x", (int) nbp); kncp = nap->knconf; plog(XLOG_DEBUG, "NA->knconf->semantics %lu", (u_long) kncp->knc_semantics); plog(XLOG_DEBUG, "NA->knconf->protofmly \"%s\"", kncp->knc_protofmly); @@ -914,26 +859,18 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) plog(XLOG_DEBUG, "NA->knconf->rdev %lu", (u_long) kncp->knc_rdev); /* don't print knconf->unused field */ #else /* not HAVE_TRANSPORT_TYPE_TLI */ -# ifdef NFS_ARGS_T_ADDR_IS_POINTER - sap = (struct sockaddr_in *) nap->addr; -# else /* not NFS_ARGS_T_ADDR_IS_POINTER */ - sap = (struct sockaddr_in *) &nap->addr; -# endif /* not NFS_ARGS_T_ADDR_IS_POINTER */ + 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_STRUCT_SOCKADDR_SA_LEN - /* as per POSIX, sin_len need not be set (used internally by kernel) */ - plog(XLOG_DEBUG, "NA->addr.sin_len = %d", sap->sin_len); + plog(XLOG_DEBUG, "NA->addr.sin_len = \"%d\"", sap->sin_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_family = \"%d\"", sap->sin_family); + plog(XLOG_DEBUG, "NA->addr.sin_port = \"%d\"", sap->sin_port); plog(XLOG_DEBUG, "NA->addr.sin_addr = \"%s\"", get_hex_string(sizeof(struct in_addr), (const char *) &sap->sin_addr)); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ -#ifdef HAVE_NFS_ARGS_T_ADDRLEN - plog(XLOG_DEBUG, "NA->addrlen = %d", nap->addrlen); -#endif /* ifdef HAVE_NFS_ARGS_T_ADDRLEN */ plog(XLOG_DEBUG, "NA->hostname = \"%s\"", nap->hostname ? nap->hostname : "null"); #ifdef HAVE_NFS_ARGS_T_NAMLEN diff --git a/contrib/amd/mk-amd-map/mk-amd-map.8 b/contrib/amd/mk-amd-map/mk-amd-map.8 index f5cef60..fef0e74 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-2006 Erez Zadok +.\" Copyright (c) 1997-2004 Erez Zadok .\" Copyright (c) 1993 Jan-Simon Pendry .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,50 +33,33 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)mk-amd-map.8 8.1 (Berkeley) 6/28/93 -.\" $Id: mk-amd-map.8,v 1.9.2.1 2006/01/02 18:48:26 ezk Exp $ +.\" $Id: mk-amd-map.8,v 1.3.2.4 2004/01/06 03:15:24 ezk Exp $ +.\" $FreeBSD$ .\" -.TH MK-AMD-MAP 8 "June 28, 1993" -.SH NAME -.B mk-amd-map -\- create database maps for Amd -.SH SYNOPSIS -.B mk-amd-map -[ -.B \-p -] -.I mapname -.SH DESCRIPTION -.B mk-amd-map +.Dd June 28, 1993 +.Dt MK-AMD-MAP 8 +.Os +.Sh NAME +.Nm mk-amd-map +.Nd create database maps for Amd +.Sh SYNOPSIS +.Nm +.Op Fl p +.Ar mapname +.Sh DESCRIPTION +.Nm creates the database maps used by the keyed map lookups in -amd(8). +.Xr amd 8 . It reads input from the named file and outputs them to a correspondingly named hashed database. -.TP -.B \-p -This +.Pp +The +.Fl p option prints the map on standard output instead of generating -a database. This is usually used to merge continuation lines +a database. +This is usually used to merge continuation lines into one physical line. -.SH SEE ALSO -.BR amd (8). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH AUTHORS -Jan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK. -.P -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.Sh SEE ALSO +.Xr amd.conf 5 , +.Xr amd 8 diff --git a/contrib/amd/mk-amd-map/mk-amd-map.c b/contrib/amd/mk-amd-map/mk-amd-map.c index 48d82b0..d72850e 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-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/mk-amd-map/mk-amd-map.c + * $Id: mk-amd-map.c,v 1.5.2.6 2004/01/06 03:15:25 ezk Exp $ + * $FreeBSD$ */ /* @@ -222,7 +224,7 @@ main(int argc, char *argv[]) char maptpag[16], maptdir[16]; char *map_name_pag = (char *) NULL, *map_name_dir = (char *) NULL; #endif /* not HAVE_DB_SUFFIX */ - size_t l = 0; + int len; char *sl; int printit = 0; int usage = 0; @@ -271,14 +273,13 @@ main(int argc, char *argv[]) #endif /* DEBUG */ if (!printit) { - /* enough space for ".db" or ".pag" or ".dir" appended */ - l = strlen(mapsrc) + 5; + len = strlen(mapsrc); #ifdef HAVE_DB_SUFFIX - map_name_db = (char *) malloc(l); + map_name_db = (char *) malloc(len + 4); error = (map_name_db == NULL); #else /* not HAVE_DB_SUFFIX */ - map_name_pag = (char *) malloc(l); - map_name_dir = (char *) malloc(l); + map_name_pag = (char *) malloc(len + 5); + map_name_dir = (char *) malloc(len + 5); error = (map_name_pag == NULL || map_name_dir == NULL); #endif /* not HAVE_DB_SUFFIX */ if (error) { @@ -305,15 +306,15 @@ main(int argc, char *argv[]) /* remove existing temps (if any) */ #ifdef HAVE_DB_SUFFIX - xsnprintf(maptdb, sizeof(maptdb), "%s.db", maptmp); + sprintf(maptdb, "%s.db", maptmp); if (remove_file(maptdb) < 0) { fprintf(stderr, "Can't remove existing temporary file; "); perror(maptdb); exit(1); } #else /* not HAVE_DB_SUFFIX */ - xsnprintf(maptpag, sizeof(maptpag), "%s.pag", maptmp); - xsnprintf(maptdir, sizeof(maptdir), "%s.dir", maptmp); + sprintf(maptpag, "%s.pag", maptmp); + sprintf(maptdir, "%s.dir", maptmp); if (remove_file(maptpag) < 0 || remove_file(maptdir) < 0) { fprintf(stderr, "Can't remove existing temporary files; %s and ", maptpag); perror(maptdir); @@ -348,8 +349,7 @@ main(int argc, char *argv[]) /* all went well */ #ifdef HAVE_DB_SUFFIX - /* sizeof(map_name_db) is malloc'ed above */ - xsnprintf(map_name_db, l, "%s.db", mapsrc); + sprintf(map_name_db, "%s.db", mapsrc); if (rename(maptdb, map_name_db) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptdb); perror(map_name_db); @@ -358,9 +358,8 @@ main(int argc, char *argv[]) exit(1); } #else /* not HAVE_DB_SUFFIX */ - /* sizeof(map_name_{pag,dir}) are malloc'ed above */ - xsnprintf(map_name_pag, l, "%s.pag", mapsrc); - xsnprintf(map_name_dir, l, "%s.dir", mapsrc); + sprintf(map_name_pag, "%s.pag", mapsrc); + sprintf(map_name_dir, "%s.dir", mapsrc); if (rename(maptpag, map_name_pag) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptpag); perror(map_name_pag); diff --git a/contrib/amd/scripts/amd.conf.5 b/contrib/amd/scripts/amd.conf.5 index 36e08cd..fe68582 100644 --- a/contrib/amd/scripts/amd.conf.5 +++ b/contrib/amd/scripts/amd.conf.5 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,687 +38,777 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: amd.conf.5,v 1.39.2.5 2006/04/21 01:12:04 ezk Exp $ +.\" $Id: amd.conf.5,v 1.7.2.10 2004/01/21 04:04:58 ib42 Exp $ +.\" $FreeBSD$ .\" -.TH AMD.CONF 5 "7 August 1997" -.SH NAME -amd.conf \- Amd configuration file -.SH SYNOPSIS -.B amd.conf -.SH DESCRIPTION +.Dd April 7, 1997 +.Dt AMD.CONF 5 +.Os +.Sh NAME +.Nm amd.conf +.Nd amd configuration file +.Sh SYNOPSIS +.Nm +.Sh DESCRIPTION The -.B amd.conf -file is the configuration file for Amd, as part of the am-utils suite. -.P -.B amd.conf +.Nm +file is the configuration file for amd, as part of the am-utils suite. +.Pp +.Nm contains runtime configuration information for the -.B Amd +.Xr amd 8 automounter program. -.\" ************************************************************************** -.SH FILE FORMAT -.P -The file consists of sections and parameters. A section begins with the +.Sh FILE FORMAT +The file consists of sections and parameters. +A section begins with the name of the section in square brackets and continues until the next section -begins or the end the file is reached. Sections contain parameters of the -form 'name = value'. -.P +begins or the end of the file is reached. +Sections contain parameters of +the form +.Sq name = value . +.Pp The file is line-based - that is, each newline-terminated line represents -either a comment, a section name or a parameter. No line-continuation +either a comment, a section name or a parameter. +No line-continuation syntax is available. -.P +.Pp Section, parameter names and their values are case sensitive. -.P -Only the first equals sign in a parameter is significant. Whitespace before -or after the first equals sign is discarded. Leading, trailing and -internal whitespace in section and parameter names is irrelevant. Leading -and trailing whitespace in a parameter value is discarded. Internal +.Pp +Only the first equals sign in a parameter is significant. +Whitespace before +or after the first equals sign is discarded. +Leading, trailing and +internal whitespace in section and parameter names is irrelevant. +Leading +and trailing whitespace in a parameter value is discarded. +Internal whitespace within a parameter value is not allowed, unless the whole -parameter value is quoted with double quotes as in 'name = "some value"'. -.P +parameter value is quoted with double quotes as in +.Sq name = Qq some\ value . +.Pp Any line beginning with a pound sign (#) is ignored, as are lines containing only whitespace. -.P +.Pp The values following the equals sign in parameters are all either a string (no quotes needed if string does not include spaces) or a boolean, which may -be given as yes/no. Case is significant in all values. Some items such as +be given as yes/no. +Case is significant in all values. +Some items such as cache timeouts are numeric. -.\" ************************************************************************** -.SH SECTIONS -.SS The [global] section -Parameters in this section either apply to Amd as a whole, or to all other -regular map sections which follow. There should be only one global section -defined in one configuration file. -.P +.Sh SECTIONS +.Ss "The [global] section" +Parameters in this section either apply to +.Nm amd +as a whole, or to all other regular map sections which follow. +There +should be only one global section defined in one configuration file. +.Pp It is highly recommended that this section be specified first in the -configuration file. If it is not, then regular map sections which precede +configuration file. +If it is not, then regular map sections which precede it will not use global values defined later. - -.SS Regular [/map] sections +.Ss "Regular [/map] sections" Parameters in regular (non-global) sections apply to a single map entry. For example, if the map section -.B [/homes] +.Bq Pa /homes is defined, then all parameters following it will be applied to the -.I /homes -Amd-managed mount point. -.\" ************************************************************************** -.SH PARAMETERS -.SS Parameters common to all sections +.Pa /homes +amd-managed mount point. +.Sh PARAMETERS +.Ss "Parameters common to all sections" These parameters can be specified either in the global or a map specific -section. Entries specified in a map-specific section override the default -value or one defined in the global section. If such a common parameter is +section. +Entries specified in a map-specific section override the default +value or one defined in the global section. +If such a common parameter is specified only in the global section, it is applicable to all regular map sections that follow. -.\" ************************************************************************** -.TP -.BR browsable_dirs " (string, default=no)" -If "yes," then Amd's top-level mount points will be browsable to -.BR readdir (3) -calls. This means you could run for example -.BR ls (1) -and see what keys are available to mount in that directory. Not all entries -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. +.Bl -tag -width 4n +.It Ic browsable_dirs Xo +(string, default=no) +.Xc +If +.Qq yes , +then amd's top-level mount points will be browsable to +.Xr readdir 3 +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, wildcard entries, 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 -.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_defaults " (string, default to empty)" -This option sets a string to be used as the map's /defaults entry, -overriding any /defaults specified in the map. This allows local users to -override map defaults without modifying maps globally. - -.TP -.BR map_options " (string, default no options)" +.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 +.Dq 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 -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 -\fBexec\fR executable maps -\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 default to 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 be an autofs server for those mount points. - -.TP -.BR autofs_use_lofs " (string, default=yes)" -When set to "yes" and using Autofs, Amd will use lofs-type (loopback) mounts -for type:=link mounts. This has the advantage of mounting in place, and -users get to the see the same pathname that they chdir'ed into. If this -option is set to "no," then Amd will use symlinks instead: that code is more -tested, but negates autofs's big advantage of in-place mounts. - -.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. - -.TP -.BR selectors_in_defaults " (boolean, default=no)" -If "yes," then the /defaults entry of maps will search for and process any -selectors before setting defaults for all other keys in that map. Useful -when you want to set different options for a complete map based on some -parameters. For example, you may want to better the NFS performance over -slow slip-based networks as follows: - -.nf -/defaults \\ - wire==slip-net;opts:=intr,rsize=1024,wsize=1024 \\ - wire!=slip-net;opts:=intr,rsize=8192,wsize=8192 -.fi - -Deprecated form: selectors_on_default - -.\" ************************************************************************** -.SS Parameters applicable to the global section only - -.TP -.BR arch " (string, default to compiled in value)" -Same as the -.B \-A -option to Amd. Allows you to override the value of the -.I arch -Amd variable. - -.TP -.BR auto_attrcache " (numeric, default=0)" -Specify in seconds (or units of 0.1 seconds, depending on the OS), what is -the (kernel-side) NFS attribute cache timeout for @i{Amd}'s own automount -points. A value of 0 is supposed to turn off attribute caching, meaning -that @i{Amd} will be consulted via a kernel-RPC each time someone stat()'s -the mount point (which could be abused as a denial-of-service attack). -Warning: some OSs are incapable of turning off the NFS attribute cache -reliably. On such systems, Amd may not work reliably under heavy load. See -the README.attrcache document in the Am-utils distribution for more details. - -.TP -.BR auto_dir " (string, default=/a)" +.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 +.Nm amd +which takes longer and can have undesired side-effects such as initializing +.Tn 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 must be +.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 log an error and convert it to +.Tn NFS . +.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 query 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 +Allows you to override the value of the +.Va arch +.Nm amd +variable. +.It Ic auto_dir Xo (string, default= Ns Pa /a ) +.Xc Same as the -.B \-a -option to Amd. This sets the private directory where Amd will create -sub-directories for its real mount points. - -.TP -.BR cache_duration " (numeric, default=300)" +.Fl a +option to +.Nm amd . +This sets the private directory where amd will create sub-directories for its +real mount points. +.It Ic cache_duration Xo +(numeric, default=300) +.Xc Same as the -.B \-c -option to Amd. Sets the duration in seconds that looked-up or mounted map -entries remain in the cache. - -.TP -.BR cluster " (string, default no cluster)" +.Fl c +option to +.Nm amd . +Sets the duration in seconds that looked up map entries remain in the cache. +.It Ic cluster Xo +(string, default no cluster) +.Xc Same as the -.B \-C -option to Amd. Specifies the alternate HP-UX cluster to use. - -.TP -.BR debug_mtab_file " (string, default=/tmp/mnttab)" -Path to mtab file that is used by Amd to store a list of mounted -file systems during debug-mtab mode. This option only applies -to systems that store mtab information on disk. -.TP - -.TP -.BR debug_options " (string, default no debug options)" +.Fl C +option to +.Nm amd . +Specifies the alternate +.Tn HP-UX +cluster to use. +.It Ic debug_options Xo +(string, default no debug options) +.Xc Same as the -.B \-D -option to Amd. Specify any debugging options for Amd. Works only if -am-utils was configured for debugging using the --enable-debug option. The -"mem" option, as well as all other options, can be turned on via ---enable-debug=mem. Otherwise debugging options are ignored. Options are -comma delimited, and can be preceded by the string "no" to negate their -meaning. You can get the list of supported debugging options by running Amd -\-H. Possible values are: - -.nf -\fBall\fR all options -\fBamq\fR register for amq -\fBdaemon\fR enter daemon mode -\fBfork\fR fork server -\fBfull\fR program trace -\fBhrtime\fR print high resolution time stamps (only if syslog(3) is not used) -\fBinfo\fR info service specific debugging (hesiod, nis, etc.) -\fBmem\fR trace memory allocations -\fBmtab\fR use local "./mtab" file -\fBreaddir\fR show browsable_dirs progress -\fBstr\fR debug string munging -\fBtest\fR full debug but no daemon -\fBtrace\fR trace protocol and NFS mount arguments -\fBxdrtrace\fR trace XDR routines -.fi - -.TP -.BR dismount_interval " (numeric, default=120)" +.Fl D +option to +.Nm amd . +Specify any debugging options for +.Nm amd . +Works only if am-utils was configured for debugging using the +.Fl -enable-debug +option. +The +.Qq mem +option alone can be turned on via +.Fl -enable-debug Ns = Ns Ic mem . +Otherwise debugging options are ignored. +Options are comma delimited, and can +be preceded by the string +.Qq no +to negate their meaning. +You can get the list of supported debugging options +by running +.Nm amd Fl v . +Possible values are: +.Pp +.Bl -tag -width "daemon" -compact +.It Ic all +all options +.It Ic amq +register for +.Xr amq 8 +.It Ic daemon +enter daemon mode +.It Ic fork +fork server +.It Ic full +program trace +.It Ic info +info service specific debugging +(hesiod, nis, etc.) +.It Ic mem +trace memory allocations +.It Ic mtab +use local +.Pa ./mtab +file +.It Ic str +debug string munging +.It Ic test +full debug but no daemon +.It Ic trace +protocol trace +.El +.It Ic dismount_interval Xo +(numeric, default=120) +.Xc Same as the -.B \-w -option to Amd. Specify in seconds, the time between attempts to dismount -file systems that have exceeded their cached times. - -.TP -.BR domain_strip " (boolean, default=yes)" -If "yes," then the domain -name part referred to by ${rhost} is stripped off. This is -useful to keep logs and smaller. If "no," then the domain name -part is left changed. This is useful when using multiple domains with -the same maps (as you may have hosts whose domain-stripped name is -identical). - -.TP -.BR exec_map_timeout " (numeric, default=10)" -The timeout in seconds that -.I Amd -will wait for an executable map program before an answer is returned from -that program (or script). This value should be set to as small as possible -while still allowing normal replies to be returned before the timer expires, -because during the time that the executable map program is queried, -.I Amd -is essentially waiting and is thus not responding to any other queries. - -.TP -.BR forced_unmounts " (boolean, default=no)" -If set to "yes," and the client OS supports forced or lazy unmounts, then -.I Amd -will attempt to use them if it gets any of three serious error conditions -when trying to unmount an existing mount point or mount on top of one: EIO, -ESTALE, or EBUSY. - -This could be useful to recover from serious conditions such as hardware -failure of mounted disks, or NFS servers which are down permanently, were -migrated, or changed their IP address. Only "type:=toplvl" mounts hung with -EBUSY are forcibly unmounted using this option, which is useful to recover -from a hung -.IR Amd ). - -.TP -.BR full_os " (string, default to compiled in value)" -The full name of the operating system, along with its version. Allows you -to override the compiled-in full name and version of the operating system. -Useful when the compiled-in name is not desired. For example, the full -operating system name on linux comes up as ``linux'', but you can override -it to ``linux-2.2.5.'' - -.TP -.BR fully_qualified_hosts " (string, default=no)" -If "yes," -.I Amd -will perform RPC authentication using fully-qualified host names. This is +.Fl w +option to +.Nm amd . +Specify, in seconds, the time between attempts to dismount file systems that +have exceeded their cached times. +.It Ic fully_qualified_hosts Xo +(string, default=no) +.Xc +If +.Qq yes , +.Nm amd +will perform RPC authentication using fully-qualified host names. +This is necessary for some systems, and especially when performing cross-domain -mounting. For this function to work, the -.I Amd -variable ${hostd} is used, requiring that ${domain} not be null. - -.TP -.BR hesiod_base " (string, default=automount)" +mounting. +For this function to work, the +.Nm amd +variable +.Va ${hostd} +is used, requiring that +.Va ${domain} +not be null. +.It Ic hesiod_base Xo +(string, default=automount) +.Xc Specify the base name for hesiod maps. - -.TP -.BR karch " (string, default to karch of the system)" +.It Ic karch Xo +(string, default to karch of the system) +.Xc Same as the -.B \-k -option to Amd. Allows you to override the kernel-architecture of your -system. Useful for example on Sun (Sparc) machines, where you can build one -Amd binary, and run it on multiple machines, yet you want each one to get -the correct -.I karch -variable set (for example, sun4c, sun4m, sun4u, etc.) Note that if not -specified, Amd will use uname(3) to figure out the kernel architecture of -the machine. - -.TP -.BR ldap_base " (string, default not set)" -Specify the base name for LDAP. This often includes LDAP-specific -values such as country and organization. - -.TP -.BR ldap_cache_maxmem " (numeric, default=131072)" -Specify the maximum memory Amd should use to cache LDAP entries. - -.TP -.BR ldap_cache_seconds " (numeric, default=0)" +.Fl k +option to +.Nm amd . +Allows you to override the kernel-architecture of your system. +Useful for +example on Sun +(Sparc) +machines, where you can build one +.Nm amd +binary and run it on multiple machines, yet you want each one to get the +correct +.Va karch +variable set +(for example, sun4c, sun4m, sun4u, etc.) +Note that if not +specified, +.Nm amd +will use +.Xr uname 3 +to figure out the kernel architecture of the machine. +.It Ic ldap_base Xo +(string, default not set) +.Xc +Specify the base name for LDAP. +.It Ic ldap_cache_maxmem Xo +(numeric, default=131072) +.Xc +Specify the maximum memory amd should use to cache LDAP entries. +.It Ic ldap_cache_seconds Xo +(numeric, default=0) +.Xc Specify the number of seconds to keep entries in the cache. - -.TP -.BR ldap_hostports " (string, default not set)" -Specify the LDAP host and port values. - -.TP -.BR ldap_proto_version " (numeric, default=2)" -Specify the version of the LDAP protocol to use. - -.TP -.BR local_domain " (string, default no sub-domain)" +.It Ic ldap_hostports Xo +(string, default not set) +.Xc +Specify LDAP-specific values such as country and organization. +.It Ic local_domain Xo +(string, default no sub-domain) +.Xc Same as the -.B \-d -option to Amd. Specify the local domain name. If this option is not given -the domain name is determined from the hostname, by removing the first -component of the fully-qualified host name. - -.TP -.BR localhost_address " (string, default to localhost or 127.0.0.1)" -Specify the name or IP address for Amd to use when connecting the sockets -for the local NFS server and the RPC server. This defaults to 127.0.0.1 or -whatever the host reports as its local address. This parameter is useful on -hosts with multiple addresses where you want to force Amd to connect to a -specific address. - -.TP -.BR log_file " (string, default=/dev/stderr)" +.Fl d +option to +.Nm amd . +Specify the local domain name. +If this option is not given the domain name is +determined from the hostname by removing the first component of the +fully-qualified host name. +.It Ic log_file Xo (string, default= Ns Pa /dev/stderr ) +.Xc Same as the -.B \-l -option to Amd. Specify a file name to log Amd events to. -If the string -.B /dev/stderr -is specified, Amd will send its events to the standard error file descriptor. +.Fl l +option to +.Nm amd . +Specify a file name to log +.Nm amd +events to. If the string -.B syslog -is given, Amd will record its events with the system logger -.BR syslogd (8). -The default syslog facility used is LOG_DAEMON. If you -wish to change it, append its name to the log file name, delimited by a -single colon. For example, if -.I logfile +.Pa /dev/stderr +is specified, +.Nm amd +will send its events to the standard error file descriptor. +IF the string +.Pa syslog +is given, +.Nm amd +will record its events with the system logger +.Xr syslogd 8 . +The default syslog facility used is +.Ev LOG_DAEMON . +If you wish to change it, append its name to the log file name, delimited by a +single colon. +For example, if +.Pa logfile is the string -.B syslog:local7 -then Amd will log messages via -.IR syslog (3) -using the LOG_LOCAL7 facility (if it exists on the system). - -.TP -.BR log_options " (string, default no logging options)" +.Qq syslog:local7 +then +.Nm amd +will log messages via +.Xr syslog 3 +using the +.Ev LOG_LOCAL7 +facility +(if it exists on the system). +.It Ic log_options Xo +(string, default no logging options) +.Xc Same as the -.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 -.B amd -.BR \-H . +.Fl x +option to +.Nm amd . +Specify any logging options for +.Nm amd . +Options are comma delimited, and can be preceded by the string +.Dq no +to negate their meaning. +The +.Dq debug +logging option is only available if am-utils was configured with +.Fl -enable-debug . +You can get the list of supported debugging and logging options by running +.Nm amd Fl 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 map_reload_interval " (numeric, default=3600)" -The number of seconds that Amd will wait before it checks to see if any maps -have changed at their source (NIS servers, LDAP servers, files, etc.). Amd -will reload only those maps that have changed. - -.TP -.BR nfs_allow_any_interface " (string, default=no)" -Normally Amd accepts local NFS packets only from 127.0.0.1. If this -parameter is set to "yes" then Amd will accept local NFS packets from any -local interface; this is useful on hosts that may have multiple interfaces -where the system is forced to send all outgoing packets (even those bound to -the same host) via an address other than 127.0.0.1. - -.TP -.BR nfs_allow_insecure_port " (string, default=no)" -Normally Amd will refuse requests coming from unprivileged ports (i.e. -ports >= 1024 on Unix systems), so that only privileged users and the kernel -can send NFS requests to it. However, some kernels (certain versions of -Darwin, MacOS X, and Linux) have bugs that cause them to use unprivileged -ports in certain situations, which causes Amd to stop dead in its tracks. -This parameter allows Amd to operate normally even on such systems, at the -expense of a slight decrease in the security of its operations. If you see -messages like "ignoring request from foo:1234, port not reserved" in your -Amd log, try enabling this parameter and give it another go. - -.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 +.Pp +.Bl -tag -width "warning" -compact +.It Ic all +all messages +.It Ic debug +debug messages +.It Ic error +non-fatal system errors +.It Ic fatal +fatal errors +.It Ic info +information +.It Ic map +map errors +.It Ic stats +additional statistical information +.It Ic user +non-fatal user errors +.It Ic warn +warnings +.It Ic warning +warnings +.El +.It Ic nfs_proto Xo +(string, default to trying version tcp then udp) +.Xc +By default, amd tries TCP and then UDP. +This option forces the overall +.Tn 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 +(without having to recompile amd) until such time as NFSv3 support is desired again. - -.TP -.BR nfs_retransmit_counter " (numeric, default=11)" +.It Ic nfs_retransmit_counter Xo +(numeric, default=110) +.Xc Same as the -.I retransmit +.Ic counter 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_retransmit_counter_udp " (numeric, default=11)" -Same as the -.B nfs_retransmit_counter -option, but for all UDP mounts only. - -.TP -.BR nfs_retransmit_counter_tcp " (numeric, default=11)" -Same as the -.B nfs_retransmit_counter -option, but for all TCP mounts only. - -.TP -.BR nfs_retransmit_counter_toplvl " (numeric, default=11)" -Same as the -.B nfs_retransmit_counter -option, but only for Amd's top-level UDP mounts. - -.TP -.BR nfs_retry_interval " (numeric, default=8)" +.Fl t Ar interval.counter +option to +.Nm amd . +Specifies the retransmit counter's value in tenths of seconds. +.It Ic nfs_retry_interval Xo +(numeric, default=8) +.Xc Same as the -.I timeout +.Ic interval 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 and TCP). +.Fl t Ar interval.counter +option to +.Nm amd . +Specifies the +.Tn NFS +timeout interval, in 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. +communicate with amd. +.Pp +.Nm Amd +relies on the kernel RPC retransmit mechanism to trigger mount retries. The values of the -.B nfs_retransmit_counter +.Ic nfs_retransmit_counter and the -.B nfs_retry_interval -parameters change the overall retry interval. Too long an interval gives +.Ic 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_retry_interval_udp " (numeric, default=8)" -Same as the -.B nfs_retry_interval -option, but for all UDP mounts only. - -.TP -.BR nfs_retry_interval_tcp " (numeric, default=8)" -Same as the -.B nfs_retry_interval -option, but for all TCP mounts only. - -.TP -.BR nfs_retry_interval_toplvl " (numeric, default=8)" -Same as the -.B nfs_retry_interval -option, but only for Amd's top-level UDP mounts. - -.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 +.It Ic nfs_allow_insecure_port Xo +(string, default=no). +.Xc +Normally amd will refuse requests coming from unprivileged ports (i.e. +ports >= 1024 on Unix systems), so that only privileged users and the kernel +can send NFS requests to it. +However, some kernels (certain versions of +Darwin, MacOS X, and Linux) have bugs that cause them to use unprivileged +ports in certain situations, which causes amd to stop dead in its +tracks. +This parameter allows amd to operate normally even on such systems, +at the expense of a slight decrease in the security of its operations. +If +you see messages like "ignoring request from foo:1234, port not reserved" +in your amd log, try enabling this parameter and give it another go. +.It Ic nfs_vers Xo +(numeric, default to trying version 3 then 2) +.Xc +By default, amd tries version 3 and then version 2. +This option forces the +overall +.Tn 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 nis_domain " (string, default to local NIS domain name)" +.It Ic nis_domain Xo +(string, default to local +.Tn NIS +domain name) +.Xc Same as the -.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)" +.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 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 normalize_slashes " (boolean, default=yes)" - -If "yes," then Amd will condense all multiple ``/'' (slash) characters into -one and remove all trailing slashes. If "no," then Amd will not touch -strings that may contain repeated or trailing slashes. The latter is -sometimes useful with SMB mounts, which often require multiple slash -characters in pathnames. - -.TP -.BR os " (string, default to compiled in value)" +.Fl n +option to +.Nm amd . +If +.Dq yes , +then the name referred 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 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 ``sunos5'', you -can override it to ``sos5'', and use older maps which were written with the -latter in mind. - -.TP -.BR osver " (string, default to compiled in value)" +.Fl O +option to +.Nm 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 , +you can override it to +.Dq sos5 , +and use older maps which were written with the latter in mind. +.It Ic osver Xo +(string, default to compiled in value) +.Xc Same as the -.B \-o -option to Amd. Overrides the compiled-in version number of the operating -system. Useful when the built in version is not desired for backward -compatibility reasons. For example, if the build in version is ``2.5.1'', -you can override it to ``5.5.1'', and use older maps that were written with -the latter in mind. - -.TP -.BR pid_file " (string, default=/dev/stdout)" -Specify a file to store the process ID of the running daemon into. If not -specified, Amd will print its process id onto the standard output. Useful -for killing Amd after it had run. Note that the PID of a running Amd can -also be retrieved via -.B amq -.BR \-p . -This file is used only if the print_pid option is on. - -.TP -.BR plock " (boolean, default=yes)" +.Fl o +option to +.Nm amd . +Override the compiled-in version number of the operating +system. +Useful when the built in version is not desired for backward +compatibility reasons. +For example, if the build in version is +.Dq 2.5.1 , +you can override it to +.Dq 5.5.1 , +and use older maps that were written with the latter in mind. +.It Ic pid_file Xo (string, default= Ns Pa /dev/stdout ) +.Xc +Specify a file to store the process ID of the running daemon into. +If not +specified, +.Nm amd +will print its process id only the standard output. +Useful for killing +.Nm amd +after it had run. +Note that the PID of a running +.Nm amd +can also be retrieved via +.Nm amq Fl p . +This file is used only if the +.Ar print_pid +option is on. +.It Ic plock Xo +(boolean, default=yes) +.Xc Same as the -.B \-S -option to Amd. -If "yes," lock the running executable pages of Amd into memory. To improve -Amd's performance, systems that support the -.BR plock (3) -or -.BR mlockall (2) -call can lock the Amd process into memory. This way there is less chance it -the operating system will schedule, page out, and swap the Amd process as -needed. This improves Amd's performance, at the cost of reserving the -memory used by the Amd process (making it unavailable for other processes). - -.TP -.BR portmap_program " (numeric, default=300019)" +.Fl S +option to +.Nm amd . +If +.Dq yes , +lock the running executable pages of +.Nm amd +into memory. +To improve +.Nm amd Ns 's +performance, systems that support the +.Xr plock 3 +call can lock the +.Nm amd +process into memory. +This way there is less chance it that the operating +system will schedule, page out, and swap the +.Nm amd +process as needed. +This improves +.Nm amd Ns 's +performance, at the cost of reserving the memory used by the +.Nm amd +process +(making it unavailable for other processes). +.It Ic portmap_program Xo +(numeric, default=300019) +.Xc Specify an alternate Port-mapper RPC program number, other than the official -number. This is useful when running multiple Amd processes. For example, -you can run another Amd in "test" mode, without affecting the primary Amd -process in any way. For safety reasons, the alternate program numbers that +number. +This is useful when running multiple +.Nm amd +processes. +For example, you can run another +.Nm amd +in +.Dq test +mode, without affecting the primary +.Nm amd +process in any way. +For safety reasons, the alternate program numbers that can be specified must be in the range 300019-300029, inclusive. -Amq +.Nm amq has an option -.B -P -which can be used to specify an alternate program number of an Amd to -contact. In this way, amq can fully control any number of Amd processes -running on the same host. - -.TP -.BR preferred_amq_port " (numeric, default=0)" -Specify an alternate Port-mapper RPC port number for Amd's -Amq -service. This is used for both UDP and TCP. Setting this value to 0 (or -not defining it) will cause -Amd -to select an arbitrary port number. Setting the -Amq -RPC service port to a specific number is useful in firewalled or NAT'ed -environments, where you need to know which port -Amd -will listen on. - -.TP -.BR print_pid " (boolean, default=no)" +.Fl P +which can be used to specify an alternate program number of an +.Nm amd +to contact. +In this way, +.Nm amq +can fully control any number of +.Nm amd +processes running on the same host. +.It Ic print_pid Xo +(boolean, default=no) +.Xc Same as the -.B \-p -option to Amd. If "yes," Amd will print its process ID upon starting. - -.TP -.BR print_version " (boolean, default=no)" +.Fl p +option to +.Nm amd . +If +.Dq yes , +.Nm amd +will print its process ID upon starting. +.It Ic print_version Xo +(boolean, default=no) +.Xc Same as the -.B \-v -option to Amd, but the version prints and Amd continues to run. If "yes," -Amd will print its version information string, which includes some -configuration and compilation values. - -.TP -.BR restart_mounts " (boolean, default=no)" +.Fl v +option to +.Nm amd , +but the version prints and +.Nm amd +continues to run. +If +.Dq yes , +.Nm amd +will print its version information string, which includes some configuration +and compilation values. +.It Ic restart_mounts Xo +(boolean, default=no) +.Xc Same as the -.B \-r -option to Amd. If "yes" -Amd +.Fl r +option to +.Nm amd . +If +.Dq yes , +.Nm amd will scan the mount table to determine which file systems are currently -mounted. Whenever one of these would have been auto-mounted, -Amd +mounted. +Whenever one of these would have been auto-mounted, +.Nm amd inherits it. - -.TP -.BR show_statfs_entries " (boolean), default=no)" -If "yes," then all maps which are browsable will also show the number of -entries (keys) they have when "df" runs. (This is accomplished by returning -non-zero values to the statfs(2) system call). - -.TP -.BR truncate_log " (boolean), default=no)" -If "yes," then the log file (if it is a regular file), will be truncated -upon startup. - -.TP -.BR unmount_on_exit " (boolean), default=no)" -If "yes," then Amd will attempt to unmount all file systems which it knows -about. Normally Amd leaves all (esp. NFS) mounted file systems intact. -Note that Amd does not know about file systems mounted before it starts up, -unless the restart_mounts option or -.B \-r +.It Ic selectors_on_default Xo +(boolean, default=no) +.Xc +If +.Dq yes , +then the +.Pa /default +entry of maps will be looked for and process any selectors before setting +defaults for all other keys in that map. +Useful when you want to set +different options for a complete map based on some parameters. +For example, +you may want to better the +.Tn NFS +performance over slow slip-based networks as +follows: +.Pp +.Bd -literal +/defaults \\ + wire==slip-net;opts:=intr,rsize=1024,wsize=1024 \\ + wire!=slip-net;opts:=intr,rsize=8192,wsize=8192 +.Ed +.It Ic show_statfs_entries Xo +(boolean, default=no) +.Xc +If +.Dq yes , +then all maps which are browsable will also show the number of entries +(keys) +they have when +.Qq df +runs. +(This is accomplished by returning non-zero values to the +.Xr statfs 2 +system call.) +.It Ic unmount_on_exit Xo +(boolean, default=no) +.Xc +If +.Dq yes , +then +.Nm amd +will attempt to unmount all file systems which it knows about. +Normally +.Nm amd +leaves all +(esp.\&) +.Tn NFS +mounted file systems intact. +Note that +.Nm amd +does not know about file systems mounted before it starts up, unless the +.Ar restart_mounts +option or +.Fl r flag are used. - -.TP -.BR use_tcpwrappers " (boolean), default=yes)" -If "yes," then Amd will use the tcpd/librwap tcpwrappers library -(if available) to control -access to Amd via the /etc/hosts.allow and /etc/hosts.deny files. - -.TP -.BR vendor " (string, default to compiled in value)" -The name of the vendor of the operating system. Overrides the compiled-in -vendor name. Useful when the compiled-in name is not desired. For example, -most Intel based systems set the vendor name to ``unknown'', but you can set -it to ``redhat.'' - -.\" ************************************************************************** -.SS Parameters applicable to regular map sections - -.TP -.BR map_name " (string, must be specified)" +.El +.Ss "Parameters applicable to regular map sections" +.Bl -tag -width 4n +.It Ic map_name Xo +(string, must be specified) +.Xc Name of the map where the keys are located. - -.TP -.BR tag " (string, default no tag)" -Each map entry in the configuration file can be tagged. If no tag is -specified, that map section will always be processed by Amd. If it is -specified, then Amd will process the map if the -.B -T -option was given to Amd, and the value given to that command-line option -matches that in the map section. - -.\" ************************************************************************** -.SH EXAMPLES -Here is a real Amd configuration file I use daily. -.P -.nf +.It Ic tag Xo +(string, default no tag) +.Xc +Each map entry in the configuration file can be tagged. +If no tag is +specified, that map section will always be processed by +.Nm amd . +If it is specified, then +.Nm amd +will process the map if the +.Fl T +option was given to +.Nm amd , +and the value given to that command-line option matches that in the map +section. +.El +.Sh EXAMPLES +Here is a real +.Nm amd +configuration I use daily. +.Bd -literal # GLOBAL OPTIONS SECTION [ global ] normalize_hostnames = no @@ -729,10 +819,10 @@ log_file = /var/log/amd log_options = all #debug_options = all plock = no -selectors_in_defaults = yes +selectors_on_default = yes # config.guess picks up "sunos5" and I don't want to edit my maps yet os = sos5 -# if you print_version after setting up "os," it will show it. +# if you print_version after setting up "os", it will show it. print_version = no map_type = file search_path = /etc/amdmaps:/usr/lib/amd:/usr/local/AMD/lib @@ -757,28 +847,22 @@ map_name = amd.import [ /tftpboot/.amd ] tag = tftpboot map_name = amd.tftpboot -.fi -.\" ************************************************************************** -.SH "SEE ALSO" -.BR amd (8), -.BR amq (8), -.BR ctl-amd (8), -.BR hosts_access (5). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH AUTHORS -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS +.Ed +.Sh SEE ALSO +.Xr amd 8 , +.Xr amq 8 +.Sh HISTORY +The +.Nm amd +utility first appeared in +.Bx 4.4 . +.Sh AUTHORS +.An Erez Zadok Aq ezk@cs.columbia.edu , +Department of Computer Science, Columbia University, New York, USA. +.Pp +.An Jan-Simon Pendry Aq jsp@doc.ic.ac.uk , +Department of Computing, Imperial College, London, UK. +.Pp +Other authors and contributers to am-utils are listed in the +.Pa AUTHORS file distributed with am-utils. diff --git a/contrib/amd/scripts/fixrmtab b/contrib/amd/scripts/fixrmtab deleted file mode 100755 index 33b7bcf..0000000 --- a/contrib/amd/scripts/fixrmtab +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# Invalidate /etc/rmtab entries for hosts named. -# Restart mountd for changes to take effect. -# -# usage: fixrmtab host1 host2 ... -# -# Package: am-utils-6.0 -# Author: Andreas Stolcke <stolcke@icsi.berkeley.edu> - -#set -x - -RMTAB=/etc/rmtab -TMP=/tmp/rmtab.$$ - -if [ ! -f /etc/rmtab ]; then - exit 0 -fi - -for host in $* -do - sed -e '/^'$host':/s/^./#/' $RMTAB > $TMP && cp $TMP $RMTAB -done -rm -f $TMP diff --git a/contrib/amd/scripts/lostaltmail.conf-sample b/contrib/amd/scripts/lostaltmail.conf-sample deleted file mode 100644 index a20158c..0000000 --- a/contrib/amd/scripts/lostaltmail.conf-sample +++ /dev/null @@ -1,84 +0,0 @@ -# -*- perl -*- -############################################################################## -# # -# CONFIGURABLE VALUES # -# # -############################################################################## - -$MAILGRUNT="postmaster"; # To whom to send log mail if mail is prefered. - -$TMPDIR="/tmp/"; # Place lostmail can do its dirty work. - -$LOCAL_LOCK_EXT=".lock"; # Name of file local mailer uses to lock - # spool file. This the correct setting for - # /bin/mail - -$SYSTEM_FROM_ADDRESS="Mailer-Daemon"; - -$MAILDIR="/var/alt_mail"; # What directory should I run out of. -$MAILER='/usr/lib/sendmail -t'; # Which mailer should I use. - -$LOCALMAILJUNK='.*~|\#.*|core'; # Files name patterns that might appear in - # alt_mail and should be ignored. This REGEXP - # gets or'ed with $MAILJUNK below. - -$SMTPHOST='localhost'; # The name of a local host which speaks SMTP - # and knows *all* your aliases. You probably - # don't want to change this. If the machine - # running lost_alt mail doesn't run an SMTP, - # daemon then something is either wrong or you - # should be setting `noverify' to prevent - # SMTP verification. - -$HOSTNAME='localhost'; # Hostname to use for SMTP HELO - -# Subject of lost log mail message. Must define $MAILGRUNT. -# I overwrite this variable in the subroutine Clean_up. Please make sure I -# haven't noodle-headdly forgotten to remove that hack in the distribution! -# No newline here please. The script will insert it for you. -$LOG_SUBJECT="Log of lostmail resends"; - -############################################################################## -# # -# DEFAULTED CONFIGURATIONS # -# # -############################################################################## - -$LOGFILE="$TMPDIR" . "lostlog"; - - -# MAILJUNK is a pattern of ignorable alt_mail files which are either common -# to most platforms or actually produced by this script. You should customize -# this REGEXP by hacking at $LOCALMAILJUNK above. -$MAILJUNK='[a-z]\.[0-9]*|\.\.?|lost\+found'; - -$LOCKEXT=".lostlock"; # our lock file extension. Should not need to - # modify - -$MESSAGE_DELIM="^From[^:]"; # /bin/mail message delimiter. Your milage - # may differ - -$HEADER_BODY_DELIM="\n"; # RFC 822 header-body delimiter. - -$RESENT_TO="Resent-To: "; # -$RESENT_FROM="Resent-From: "; # Resent headers (RFC 822). -$RESENT_DATE="Resent-Date: "; # You probably don't want to muck with these. -$RESENT_INFO="X-Resent-Info: "; # (special one to alert folks about mail). - - -############################################################################## -# # -# LOSTMAIL DEFINITIONS (DON'T TOUCH) # -# # -############################################################################## - -$FALSE=0; -$TRUE=(! $FALSE); - -$OK=$TRUE; -$ABORT_RESEND=2; -$LOCK_RETRIES=10; # The number of seconds/retries lost mail - # should wait before requeing or aborting a - # resend. - -TRUE; # Ansures true return from include file. diff --git a/contrib/amd/scripts/lostaltmail.in b/contrib/amd/scripts/lostaltmail.in deleted file mode 100755 index 467dedd..0000000 --- a/contrib/amd/scripts/lostaltmail.in +++ /dev/null @@ -1,658 +0,0 @@ -#!@PERL@ -sw -# -# Package: am-utils-6.0 -# Author: James Tanis <jtt@cs.columbia.edu> -# - -############################################################################ -# -# lostaltmail -- remail files files found alt_mail (or -a argument to hlfsd) to -# whomever should receive it. This version is for SMTP varient which -# support VRFY as a non-expanding verifier!!! (sendmail V8 is a an -# example). -# -# Usage: lostaltmail [-debug] [-nomail] [-noverify] -# -# GLOBAL VARIABLES (as if you care :-) ) -# Probably a very incomplete list. -# -# Everything in the config file for this program *and* ... -# -# $debug: set it from the command line with -debug. Does the obvious -# $nomail: set it from the command line with -nomail. *Not* implied by -# $debug -# $currentTO: The addresss we are currently checking on. Actually this is -# left over from an earlier version of lostaltmail and will hopefully -# go away. -# $noverify: set it from the address line. Avoid verification of $currentTO. -# This should be relatively safe as long as you are willing to -# endure bounces from mail that cannot be redelivered as opposed to -# just getting a warning. UNTESTED (but should work). -# -# $logopen: state variable indicating weather the log file (should there be -# one) is in fact open. -# -# @allentries: Array of all the directory entries in $MAILDIR -# @allnames: Array of all *likely* recipients. It is created from @allentries -# sans junk files (see $MAILJUNK and $LOCALMAILJUNK) -# @wanderers: Array of all the files associated with a *single* address -# which might need remailing. Should lostaltmail die unexpectedly, -# it might leave a temporary file containing messages it was -# currently trying to deliver. These will get picked and resent -# later. -# -# VRFY: Handle onto SMTP verification channel. Not to be confused with mail -# delivery; only verification occurs accross this handle. -# -############################################################################ - -############################################################################## -# # -# SMTP_SEND # -# # -############################################################################## -# -# Send a message to the smtp channel. Inserts the necessary NEWLINE if it -# does not exist; -# I stole this from myself. It shouldn nott be printing errors to STDERR, but -# this is a quick hack. -# -sub smtp_send { - local ($msg) = @_; - local ($length); - - $length=length($msg); - - if ( $msg !~ /^.*\n$/ ) { - $msg = $msg . "\n"; - $length++; - } - - - if ( ! syswrite (VRFY, $msg, $length)) { - print STDERR "Failing SMTP write: $msg"; - return 0; - } - - return 1; -} - -############################################################################## -# # -# SMTP_RECV # -# # -############################################################################## -# -# Read in lines from SMTP connection and return the final -# Really hideous -- please excuse. -# -sub smtp_recv { - local ($line,$rin, $win, $ein, $readbuf, $ret); - $readbuf = ""; - - $rin = $win = $ein = ''; # Null fd sets, - vec ($rin, fileno(VRFY), 1) = 1; # Stolen straight from the example; - $ein = $rin | $win; # This is probably useless - - -LINE_OF_INPUT: - while (1) { # Read in all the input - - if ((select ( $rin, $win, $ein, 600.0))[0] == 0 ) { - print "select returned -1" if ($debug); - return -1; # timeout - } - sysread (VRFY, $readbuf, 1024); - chop ($readbuf); - - foreach $line ( split('\n', $readbuf)) { - - # This loop is actually needed since V8 has a multi-line greet. - - ( $line =~ /^(\d\d\d).*/ && ($SMTP_retval=$1)) || - warn "Badly formed reply from SMTP peer: $line\n"; - - # Space after return code indicates EOT - - if ($line =~ /^\d\d\d /) { - $ret = $line; # Oddly $line is in a different context here; - # and thus we need to export it out of the - # while loop via $ret. - last LINE_OF_INPUT; - } - } # End of read. - } # End of input. - - return $ret; -} - - - - -############################################################################## -# # -# LOG_INFO # -# # -############################################################################## -# -# -# Opens appropriate logging file -- STDOUT (cron) or temp file (mail). -# -sub Log_info { - local($message) = @_; - - if ( !$logopened ) { - if ( $MAILGRUNT eq "" || $debug) { - open (LOGFILE, ">-") || die "Unable to open stdout"; - } - else { - # Snarf the log into a tmp file for final mailing to MAILGRUNT - $logfile = $LOGFILE . ".$$"; - open (LOGFILE, (">". "$logfile")) || die "Unable to create log file"; - } - } - - $logopened=1; # Note that the log is now open - - # Heart of the function. - print LOGFILE "$message"; - - print LOGFILE "\n" if ( index($message,"\n") == -1 ); -} - -############################################################################## -# # -# LOCK_FILE # -# # -############################################################################## - -# -# Tries to grab a lock on the supplied file name. -# Spins for a bit if it can't on the assumption that the lock will be released -# quickly. If it times out and it's allowed to requeue, it will defer -# until later, other wise write a message to loginfo. - -# If a recurring error or really unexpected situation arrises, return -# ABORT_RESEND -# -# PARAMETERS -# mailfile: path to the file to resend. -# should_requeue: BOOLEAN - TRUE if the mailfile should be put on the -# queue for a later retry if we can not finish -# now. - -sub Lock_file { - - local($mailfile,$should_requeue,$i,$new_lost_file) = @_; - -# We need to rename the current mailbox so that mail can loop back into it if -# the resent mail just gets looped right back to us. - $new_lost_file = $mailfile . ".$$"; - -# make a tmpfile name based on mailfile; - $lostlockfile = "$mailfile" . "$LOCKEXT"; - - if ( ! open(LOCKFILE, (">" . $lostlockfile)) ) { - printf(STDERR "Could not create lostlockfile for %s: %s\n", $mailfile,$!); - return $ABORT_RESEND; - } - close(LOCKFILE); - - $maillockfile = "$mailfile" . "$LOCAL_LOCK_EXT"; - - for ($i=0; $i < $LOCK_RETRIES && ! link ($lostlockfile, $maillockfile); - $i++) { - sleep(1); - } - - unlink($lostlockfile); # No matter what eliminate our cruft - - if ( $i == $LOCK_RETRIES ) { - &Log_info("Could not grab lock on: " . "$mailfile" . " :timed out"); - if ( $should_requeue ) { - &Log_info("Requeing " . "$mailfile" . " for later retry"); - $retry_list .= " $mailfile"; - } - else { - &Log_info("Giving up on: " . "$mailfile"); - } - - return $ABORT_RESEND; - } - - # We created the link and therefore have the lock - - if (rename ($mailfile, $new_lost_file) == 0 ){ - # Failed to rename file -- this is serious. - unlink($maillockfile); - return $ABORT_RESEND; - } - - unlink($maillockfile); - return $new_lost_file; - -} - -############################################################################## -# # -# PARSE NEXT MAIL MESSAGE # -# # -############################################################################## -# -# Parameters: -# mailfile: handle of mailfile to use. -# -# Parses the next message in the mail file and inserts it in $current_msg -# -sub Get_next_msg { - local($mailfile,$found_body_delimiter) = @_; - - # If this is the first message in the spool file, read the first line - # otherwise use the MESSAGE_DELIM line from the previous message (which we - # were forced to overread). - - $done=$FALSE; - $found_body_delimiter=$FALSE; - - # This if eats the very first "From " line and should never fire again. - if ( ! defined $current_msg ) {<$mailfile>}; - undef ($current_msg); # Erase the old message. - - - # Read the mailfile and pass through all the lines up until the next - # message delimiter. Kill any previous resend headers. - while ( <$mailfile> ) { - last if (/$MESSAGE_DELIM/); - next if ( !$found_body_delimiter && /[Rr][Ee][Ss][Ee][Nn][Tt]-.+:/); - if ( !$found_body_delimiter && /^$HEADER_BODY_DELIM/) { - &Splice_in_resent_headers(); - $found_body_delimiter=$TRUE; - } - if (defined($current_msg)) { - $current_msg .= $_; - } else { - $current_msg = $_; - } - } - - # Return TRUE when we have hit the end of the file. - if (!defined($_) || $_ eq "" ) { - return $TRUE; - } else { - return $FALSE; - } -} - -############################################################################## -# # -# SPLICE IN RESENT_HEADERS # -# # -############################################################################## -# -# Insert the Resent- headers at the *current location* of the message stream -# (In Engish, print out a few Resent-X: lines and return :-) ) -# In addition splice in the X-resent-info: header. - -# -# Paremters: None. -# Return: None -# -sub Splice_in_resent_headers { - local($date,$utctime,$weekday,$time,$month,$hostname); - - $current_msg .= "$RESENT_TO" . "$currentTO" . "\n"; - $current_msg .= "$RESENT_FROM" . "$SYSTEM_FROM_ADDRESS" . "\n"; - - # Calculate date and time. It is a bit of a shame to do this each time - # the time needs to be acurate. - - @utctime=gmtime(time); - - $weekday=(Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$utctime[6]]; - - - # If the minutes or second do not take two columns each, patch em up. - if ( $utctime[1] < 10 ) { - if ( $utctime[0] < 10 ) { - $time=sprintf("%d:0%d:0%d",$utctime[2],$utctime[1],$utctime[0]); - } - else { - $time=sprintf("%d:0%d:%d",$utctime[2],$utctime[1],$utctime[0]); - } - } - else { - if ( $utctime[0] < 10 ) { - $time=sprintf("%d:%d:0%d",$utctime[2],$utctime[1],$utctime[0]); - } - else { - $time=sprintf("%d:%2d:%2d",$utctime[2],$utctime[1],$utctime[0]); - } - } - - $month=(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$utctime[4]]; - - # Ensure Y2K format - $date=sprintf("%s, %d %s %d %s UTC", $weekday, $utctime[3], $month, $utctime[5]+1900, $time); - - $current_msg .= "$RESENT_DATE" . $date . "\n"; - - if ( defined $RESENT_INFO && $RESENT_INFO ne "") { - $hostname=`uname -n`; - $current_msg .= "$RESENT_INFO" . "Lost mail resent from ". $hostname; - } - - return; -} - -############################################################################## -# # -# DO_REMAIL # -# # -############################################################################## -# -# Actually resends the mail. Talks to the process configured as $MAILER -# We need better handling. -# -sub Do_remail { - open (MAILER, "| $MAILER $currentTO") || return $ABORT_RESEND; - print MAILER $current_msg; - close (MAILER); -} - -############################################################################## -# # -# CLEAN_UP # -# # -############################################################################## -# -# Clean up my messes. -# -sub Clean_up { - local ($hostname); - - # Ugly local hack that you should never have seen, but I forgot to - # remove. Hopefully it did not kill you (I tried as you see), but you - # should eiter remove or update it for yourself. I find the message - # subject needs to have the hostname to be useful. - # - chop ($hostname=`uname -n`); - $LOG_SUBJECT="$LOG_SUBJECT from $hostname" if ( $hostname =~ /.*\.cs\.columbia\.edu/ ); - # - # End of ugly local hack - - # Mail any log info to MAILGRUNT. - if (defined($logfile) && $logfile ne "" ) { - close (LOGFILE); # Flush logfile output. - if ( -s $logfile ) { - open (MAILER, "| $MAILER $MAILGRUNT"); - - print MAILER "To: $MAILGRUNT\n"; - print MAILER "Subject: $LOG_SUBJECT\n"; - print MAILER "$HEADER_BODY_DELIM"; - - open (LOGFILE, "< $logfile"); - - while (<LOGFILE>) { - print MAILER $_; - } - close (MAILER); - close (LOGFILE); - } - - unlink($logfile); - } - exit(0); -} - - -############################################################################## -# # -# COLLECT_WANDERERS # -# # -############################################################################## - -# -# Collects other files that appear to be mail file for the $currentTO -# but were not remailed successfully. -# -# Parameters: none (but uses $currentTO) -# Return: True if a old mail directory is found. False otherwise. -# Side effects: $wanderers set. -# -sub Collect_wanderers { - - undef (@wanderers); - - # Slurp in the directory and close. - - return ($found); -} - -############################################################################# -# # -# REMAIL ALL # -# # -############################################################################# - -# -# Takes an array of files that all seem to share a common repcipient and -# remails them if possible. -# -# Parameters: None (uses @wanderers). -# -sub Remail_all { - local($file,$i); - - $i=0; - foreach $file (@wanderers) { - if ( !open (LOSTFILE, "< $file")) { - &Log_info("Could not open " . "$file" . " for remailing"); - next; - } - - do { # Power loop! - $done = &Get_next_msg(LOSTFILE); # Retrieve the next message... - &Do_remail; # and remail it. - } until $done; - undef ($current_msg); # Erase the final remailed message. - - close(LOSTFILE); # Tidy up. - - unlink ($file); # Remove the remailed file - $i++; - } - -} - -############################################################################# -# # -# CHECK_USER # -# # -############################################################################# - -# -# Checks the password tables for the uid of $currentTO. If the user is -# uid 0 (ie *supposed* to get mail in altmail) or unknown the resend is -# aborted. -# -# -sub Check_user { - local (@passwdinfo); - undef (@passwdinfo); - - if (!$noverify && !&vrfy_user($currentTO) ) { - &Log_info("Possible non user mail file: $currentTO"); - return $ABORT_RESEND; - } - - @passwdinfo = getpwnam($currentTO); - - print "Non user mailable mail: Name: $currentTO\n" - if ( $debug && ! defined @passwdinfo ); - - return !$ABORT_RESEND if ( ! defined @passwdinfo ); # A non user but evidently mailable - - print "Check User(): Name: $currentTO -- UID: $passwdinfo[2]\n" if ($debug); - - return $ABORT_RESEND if ( $passwdinfo[2] == 0 ); - - - return !$ABORT_RESEND; -} - -############################################################################# -# # -# VRFY USER # -# # -############################################################################# -# -# Use SMTP VRFY to insure that argument is in fact a legal mail id. -# Boolean: TRUE if mailable account, FALSE if not. - -sub vrfy_user { - - local ($mailname,$repl) = @_; - - if ( !&smtp_send("vrfy $mailname") ) { - &Log_info("Failed sending to vrfy smtp command for: $mailname"); - return 0; - } - - $repl = &smtp_recv; - - print "VRFY REPLY: $repl\n" if ($debug); - - return ( $repl =~ /^2\d\d/ ); - - -} - - -############################################################################# -# # -# MAIN PROC # -# # -############################################################################# - -# dummy code to shut up perl -w -$debug = 0 if !defined($debug); -print $nomail if $debug > 1; -print $RESENT_FROM if $debug > 1; -print $logopen if $debug > 1; -print $LOCAL_LOCK_EXT if $debug > 1; -print $RESENT_TO if $debug > 1; -print $LOCKEXT if $debug > 1; -print $RESENT_DATE if $debug > 1; -print $MESSAGE_DELIM if $debug > 1; -print $SMTP_retval if $debug > 1; -print $found if $debug > 1; -print $retry_list if $debug > 1; -print $MAILJUNK if $debug > 1; -print $noverify if $debug > 1; -print $SYSTEM_FROM_ADDRESS if $debug > 1; - -# BEGIN: stuff -$prefix="@prefix@"; -$CONFIGDIR="@sysconfdir@"; # Directory where global config lives -require "$CONFIGDIR/lostaltmail.conf" if (-f "$CONFIGDIR/lostaltmail.conf"); -require "/etc/global/lostaltmail.conf" if (-f "/etc/global/lostaltmail.conf"); -require "/etc/os/lostaltmail.conf" if (-f "/etc/os/lostaltmail.conf"); -require "/etc/local/lostaltmail.conf" if (-f "/etc/local/lostaltmail.conf"); - - -require "ctime.pl"; -use Socket; -#require "sys/socket.ph"; - -# SET some initial state variales -$logopen = 0; - -# -# Change to alt_dir -# -# Important!! This directory should be local. Folks will be responsible -# for finding this out for themselves. -# -if (!defined($MAILDIR) || $MAILDIR eq "") { - die "MAILDIR must be defined\n"; -} -chdir ( $MAILDIR ) || die "Cannot change to $MAILDIR (`x' bit not set?)"; - -# -# slurp in directory -# -opendir (MAIL, ".") || die "Cannot open $MAILDIR (`r' bit not set?)"; -@allentries= readdir (MAIL); -closedir (MAIL); -@allnames = grep (!/$LOCALMAILJUNK|$MAILJUNK/, @allentries); - -# Open chanel to SMTP for verification -- unless this option is -# configured off. - -if ( ! $noverify ) { - local($addr, $port,$sockaddr); - - socket (VRFY, &AF_INET, &SOCK_STREAM, 0) || - die "Could not create TCP socket (SMTP channel)"; - - $addr = (gethostbyname($SMTPHOST))[4]; # Just use the first addr - - die "Could not obtain STMP host ($SMTPHOST) address" - if ( $addr eq "" ); - - $port = (getservbyname('smtp','tcp'))[2]; # Get smtp port. - die "Could not obtain SMTP port number" if (!defined($port)); - - printf("SMTP: address: %s port: $port\n", - join ('.',unpack('C4',$addr))) if ($debug); - - $sockaddr = sockaddr_in($port, $addr); - - printf("Sockaddr: %s\n", join (' ',unpack('C14',$sockaddr))) if ($debug); - - connect (VRFY, $sockaddr) || - die "Could not connect to SMTP daemon on $SMTPHOST"; - - print "Establshed SMTP channel\n" if ($debug); - - &smtp_recv; # Greet wait - &smtp_send("helo $SMTPHOST"); # Helo message for picky SMTPs - &smtp_recv; # Helo reply - - # Connection is up and ready to VRFY -} - -# main stuff starts here -foreach $currentTO (@allnames) { - next if ( &Check_user == $ABORT_RESEND); - - # just delete the file if too small to be real mail - if ((stat($currentTO))[7] < 5) { - print "Too small to be real mail, unlinking $currentTO" if $debug; - unlink $currentTO; - } - - undef (@wanderers); # Just reset this at each pass. - @wanderers=grep (/$currentTO\.\d+/, @allentries); - - $remail_file = &Lock_file($currentTO,$FALSE); # Need to lock the spool. - - next if ( $remail_file eq $ABORT_RESEND); # Could not get that lock - - push (@wanderers, $remail_file); # Try to resend "old" files. - print "List to remail: @wanderers\n" if ($debug); - # check if there is something to remail - &Remail_all if ( defined @wanderers && !$nomail); -} - -# this stuff should run at the end -foreach $file (grep (/$LOCALMAILJUNK/,@allentries)) { - - if ($debug) { - print "Would unlink $file\n" if ($debug); - } else { - unlink $file if (-f $file); - } - -} -&Clean_up; # Do a clean exit. diff --git a/contrib/amd/wire-test/wire-test.8 b/contrib/amd/wire-test/wire-test.8 index 539a849a..2c6a37c 100644 --- a/contrib/amd/wire-test/wire-test.8 +++ b/contrib/amd/wire-test/wire-test.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-2006 Erez Zadok +.\" Copyright (c) 1997-2004 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,51 +38,45 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: wire-test.8,v 1.10.2.1 2006/01/02 18:48:26 ezk Exp $ +.\" $Id: wire-test.8,v 1.3.2.5 2004/01/06 03:15:25 ezk Exp $ +.\" $FreeBSD$ .\" -.TH WIRE-TEST 8 "26 Feb 1993" -.SH NAME -wire-test \- test your network interfaces and local IP address -.SH SYNOPSIS -.B wire-test -[ -.I host -] -.SH DESCRIPTION -.LP -.B wire-test -is used to find out what amd thinks are the first two network -interfaces and network names/numbers used, as well as the IP address -used for amd to NFS-mount itself. - +.Dd February 26, 1993 +.Dt WIRE-TEST 8 +.Os +.Sh NAME +.Nm wire-test +.Nd test your network interfaces and local IP address +.Sh SYNOPSIS +.Nm +.Op Ar host +.Sh DESCRIPTION +.Nm +is used to find out what +.Nm Amd +thinks are the first two network interfaces and network names/numbers +used, as well as the IP address used for +.Nm Amd +to NFS-mount itself. +.Pp If -.I host +.Ar host is specified, then -.B wire-test -will test for the working combinations of NFS protocol and version from -the current client to the NFS server -.I host. +.Nm +will test for the working combinations of +.Tn NFS +protocol and version from the current client to the +.Tn NFS +server +.Ar host . If not specified, -.I host -defaults to "localhost". - -.SH "SEE ALSO" -.BR amd (8). -.LP -``am-utils'' -.BR info (1) -entry. -.LP -.I "Linux NFS and Automounter Administration" -by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). -.LP -.I http://www.am-utils.org -.LP -.I "Amd \- The 4.4 BSD Automounter" -.SH AUTHORS -Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook -University, Stony Brook, New York, USA. -.P -Other authors and contributors to am-utils are listed in the -.B AUTHORS -file distributed with am-utils. +.Ar host +defaults to +.Dq localhost . +.Sh SEE ALSO +.Xr amd 8 +.Sh HISTORY +The +.Nm +utility appeared in +.Fx 3.0 . diff --git a/contrib/amd/wire-test/wire-test.c b/contrib/amd/wire-test/wire-test.c index bcaaf5a..593cf4538 100644 --- a/contrib/amd/wire-test/wire-test.c +++ b/contrib/amd/wire-test/wire-test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2004 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. @@ -36,8 +36,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * %W% (Berkeley) %G% * - * File: am-utils/wire-test/wire-test.c + * $Id: wire-test.c,v 1.5.2.4 2004/01/06 03:15:25 ezk Exp $ + * $FreeBSD$ * */ @@ -78,7 +80,7 @@ main(int argc, char **argv) } /* also print my IP address */ - amu_get_myaddress(&myipaddr, NULL); + amu_get_myaddress(&myipaddr); fprintf(stderr, "My IP address is 0x%x.\n", (unsigned int) htonl(myipaddr.s_addr)); /* @@ -97,7 +99,6 @@ main(int argc, char **argv) } ip = (struct sockaddr_in *) xmalloc(sizeof(struct sockaddr_in)); memset((voidp) ip, 0, sizeof(*ip)); - /* as per POSIX, sin_len need not be set (used internally by kernel) */ ip->sin_family = AF_INET; memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr)); ip->sin_port = htons(NFS_PORT); |