From c6e3533e1e31cbf25e04688d244a8fc2af2e1972 Mon Sep 17 00:00:00 2001 From: obrien Date: Sat, 14 Nov 1998 03:11:37 +0000 Subject: Virgin import of AMD (am-utils) v6.0b1 --- contrib/amd/AUTHORS | 15 ++ contrib/amd/BUGS | 16 +++ contrib/amd/ChangeLog | 155 ++++++++++++++++++++ contrib/amd/INSTALL | 5 + contrib/amd/MIRRORS | 9 +- contrib/amd/NEWS | 16 +++ contrib/amd/README.y2k | 18 +++ contrib/amd/amd/amd.c | 5 +- contrib/amd/amd/amfs_auto.c | 1 + contrib/amd/amd/amfs_host.c | 6 +- contrib/amd/amd/conf.c | 10 ++ contrib/amd/amd/info_nis.c | 30 ++-- contrib/amd/amd/mapc.c | 24 +++- contrib/amd/amd/ops_autofs.c | 3 +- contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h | 9 +- contrib/amd/doc/am-utils.texi | 27 +++- contrib/amd/doc/stamp-vti | 6 +- contrib/amd/doc/version.texi | 6 +- contrib/amd/fixmount/fixmount.c | 3 +- contrib/amd/hlfsd/hlfsd.c | 5 +- contrib/amd/hlfsd/stubs.c | 2 +- contrib/amd/include/am_defs.h | 12 ++ contrib/amd/include/am_utils.h | 1 + contrib/amd/libamu/clnt_sperrno.c | 147 +++++++++++++++++++ contrib/amd/libamu/xutil.c | 1 + contrib/amd/mk-amd-map/mk-amd-map.c | 197 +++++++++++++++----------- contrib/amd/scripts/Makefile.am | 2 +- contrib/amd/scripts/Makefile.in | 10 +- contrib/amd/scripts/amd.conf.5 | 2 +- contrib/amd/scripts/fixrmtab.in | 24 ++++ contrib/amd/tasks | 6 + contrib/amd/wire-test/wire-test.c | 5 +- 32 files changed, 648 insertions(+), 130 deletions(-) create mode 100644 contrib/amd/README.y2k create mode 100644 contrib/amd/libamu/clnt_sperrno.c create mode 100755 contrib/amd/scripts/fixrmtab.in (limited to 'contrib/amd') diff --git a/contrib/amd/AUTHORS b/contrib/amd/AUTHORS index e555a74..300b290 100644 --- a/contrib/amd/AUTHORS +++ b/contrib/amd/AUTHORS @@ -30,6 +30,8 @@ files. January 27, 1998: support pid files in the amd.conf file. Provide base name for hesiod zone files. Always use /etc/amd.conf if exists. +August 8, 1998: add detection support for NFS V.3 for NetBSD 1.3F. + * Hannes Reinecke Back in 1995, contributed code for linux. A new parser for file system @@ -89,6 +91,9 @@ options. Minor type wrt "ro" option in libamu/mount_fs.c. Added more fillers of mnttab options, for acdirmax, acdirmin, acregmax, acregmin, noac, grpid, nosuid, and actimo. +August 15, 1998: fix memory leak in processing of /defaults, and avoid +accessing uninitialized memory in osf1. + * Roman Hodek July 23, 1997: Got lots of patches from the Debian Linux folks, who fixed @@ -171,6 +176,9 @@ January 12, 1998: minor bug in output of amd -H. January 13, 1998: use case insensitive comparisons for variables that need it (such as all hostname related ones, and more). +July 20, 1998: don't leak memory in the private version of yp_all (when +vendor yp_all is bad). + * Fred Korz January 30, 1998: minor typo fixed to tftp example in am-utils.texi. @@ -186,5 +194,12 @@ allow startup script to redirect it. Set a temporary secure umask(0022) before writing log file and restore it afterwards. * Matthew Crosby + April 20, 1998: allow arbitrary number of interfaces in wire listing. +* David O'Brien + +September 4, 1998: bug fix to avoid overrunning hostname buffer, and minor +amd.conf man page typo correction. + + diff --git a/contrib/amd/BUGS b/contrib/amd/BUGS index 125714d..f05e49b 100644 --- a/contrib/amd/BUGS +++ b/contrib/amd/BUGS @@ -71,3 +71,19 @@ that nfsd is running. Normally these are not required. [4B] "Stefan Vogel" reports that if your amq executable dump core unexpectedly, then it may be a bug in gcc 2.7.x. Upgrade to gcc 2.8.x or use IBM's xlC compiler. + + +(5) *-linux-gnu (RedHat Linux 5.1) + +There's a UDP file descriptor leak in libnsl in RedHat Linux 5.1. This +library part of glibc2. Am-utils currently declares redhat 5.1 systems as +having a "broken yp_all" and using an internal, slower, leak-free version. +The leak is known to the glibc maintainers and a fix from them is due soon, +but it is not yet in the glibc-2.0.7-19 RPM. + + +(6) rs6000-ibm-aix4.1.x + +A bug in libc results in an amq binary that doesn't work; amq -v dumps core +in xdr_string. There is no known fix (source code or vendor patch) at this +time. (Please let amd-dev know if you know of a fix.) diff --git a/contrib/amd/ChangeLog b/contrib/amd/ChangeLog index 3a05928..2c224e5 100644 --- a/contrib/amd/ChangeLog +++ b/contrib/amd/ChangeLog @@ -1,3 +1,158 @@ +1998-10-20 Erez Zadok + + ******************************************************************* + *** Released am-utils-6.0b1 *** + ******************************************************************* + +1998-10-18 Erez Zadok + + * mk-amd-map/mk-amd-map.c (main): use perror not strerror. + (main): set return type to int if no ndbm maps. + + * include/am_defs.h: avoid conflicts with in 2.1 + kernels. + +1998-10-18 Erez Zadok + + * A.i386-unknown-netbsd1.3.2/amu_nfs_prot.h: trim down and cleanup + for netbsd 1.3.2. + +1998-10-17 Erez Zadok + + * aux/configure.in: check for yp_all in libnsl, b/c redhat 5.1 + systems put NIS functions there. + + * mk-amd-map/mk-amd-map.c: patch from "David O'Brien" + merged in. Use POSIX -1 return code from + getopt(), not EOF. Use .db extentions for systems that use it, + instead of .{pag,dir}. + +1998-10-15 Erez Zadok + + * wire-test/wire-test.c, hlfsd/hlfsd.c, fixmount/fixmount.c, + amd/amd.c (main): avoid overrunning hostname buffer. Bug fix from + "David O'Brien" . + + * scripts/amd.conf.5: minor typo reported by "David O'Brien" + in .TH section of man page. + + * amd/info_nis.c (am_yp_all): don't leak key-val entries. Patch + from Thomas Richter . + +1998-10-12 Erez Zadok + + * doc/am-utils.texi (Program Filesystem): minor typo fixed as per + Andreas Stolcke . + + * minor new ports: sparc64-unknown-linux-gnu, i386-pc-solaris2.7, + and sparc-sun-solaris2.7. + + * conf/mount/mount_freebsd3.c (mount_freebsd3): freebsd 3.0 is now + a 4.4lite kernel, and somethings were removed, such as + INITMOUNTNAMES. + + * amd/ops_autofs.c (autofs_lookuppn): don't leak memory while + processing /defaults. Free temporary opts. Patch from + dsr@mail.lns.cornell.edu (Daniel S. Riley) + + * amd/amfs_auto.c (amfs_auto_lookuppn): don't leak memory while + processing /defaults. Free temporary opts. Patch from + dsr@mail.lns.cornell.edu (Daniel S. Riley) + + * conf/mtab/mtab_osf.c (read_mtab): patch from + dsr@mail.lns.cornell.edu (Daniel S. Riley) not to access + uninitialized memory on Digital Unix. + +1998-10-09 Erez Zadok + + * aux/macros/{check_mtype_type,check_mtype_printf_type}.m4: most + systems now use "char *" as their mount type. + +1998-10-08 Erez Zadok + + * amd/conf.c (gopt_map_type, ropt_map_type): check if map type + exists. + + * amd/mapc.c (mapc_type_exists): function to test if a map of + certain type exists. + +1998-10-08 Erez Zadok + + * aux/macros/{mount_headers,try_compile_anyfs,try_compile_nfs}.m4, + include/am_defs.h: Avoid a conflict in definitions of ntohl/htonl + in RH-5.1 sparc64 between and + (2.1 kernels). + +1998-09-28 Erez Zadok + + * aux/macros/func_bad_yp_all.m4 (ac_cv_func_yp_all_clean): RedHat + 5.1 systems with glibc glibc-2.0.7-19 or below leak a UDP socket + from yp_all(). + +1998-09-25 Erez Zadok + + * conf/mount/mount_linux.c (parse_opts): check for pcfs support + only if autoconfigured. + +1998-09-18 Erez Zadok + + * Makefile.am (EXTRA_DIST): distribute README.yk2 file. + + * README.y2k: explain y2k compliance status of am-utils. + +1998-09-16 Erez Zadok + + * amd/amfs_host.c (fetch_fhandle, amfs_host_fmount, + amfs_host_umounted): clnt_sperrno() may return a const. + +Sat Aug 8 23:28:32 1998 Erez Zadok + + * aux/configure.in: check for , as per Christos + Zoulas. Turned on checking for mount options: async, synchronous, + deadthresh, leasterm, nqnfs, and readahead. + + * amd/info_nis.c: patch from christos@zoulas.com (Christos Zoulas) + to include prototype definition for nis_isup(). + +Sun Jul 19 18:50:10 1998 Erez Zadok + + * hlfsd/stubs.c (getcreds): force sscanf arg to u_long. + +Tue Jul 14 20:34:25 1998 Erez Zadok + + * released snapshot am-utils-6.0a17s1 + +Wed Jul 8 21:49:15 1998 Erez Zadok + + * aux/macros/host_macros.m4: all x86 hosts should have $arch be + i386, not i[456]86. + +Tue Jul 7 18:55:09 1998 Erez Zadok + + * aux/macros/{mount_headers,try_compile_anyfs,try_compile_nfs}.m4, + include/am_defs.h: include before + because on redhat 5.1, there is a bug (misuse) of + headers in (it defines _LINUX_TYPES_H instead of + __KERNEL_STRICT_NAMES). + + * aux/configure.in: check for because it is + need for RedHat 5.1. + +Wed Jun 17 00:05:33 1998 Erez Zadok + + * scripts/Makefile.am (EXTRA_DIST): have fixrmtab generated from + .in as well, so it doesn't get removed by make clean. + +Tue Jun 16 22:00:15 1998 Erez Zadok + + * aux/macros/{check_fs_mntent.m4, check_mnttab_type.m4, + check_mount_type.m4}: redhat 5.1 puts some modules in + /lib/modules/preferred/. + +Wed May 13 16:33:57 1998 Erez Zadok + + * amd/ops_autofs.c (mount_autofs): cast pid to long. + Thu Apr 23 00:22:17 1998 Erez Zadok ******************************************************************* diff --git a/contrib/amd/INSTALL b/contrib/amd/INSTALL index 7df423b..0907096 100644 --- a/contrib/amd/INSTALL +++ b/contrib/amd/INSTALL @@ -21,6 +21,7 @@ i386-pc-bsdi3.0 ezk ezk ezk i386-pc-bsdi3.1 ezk ezk ezk i386-pc-solaris2.5.1 ezk ezk ezk ezk i386-pc-solaris2.6 ezk ezk ezk ezk +i386-pc-solaris2.7 ezk ezk ezk ezk i386-unknown-freebsd2.1.0 ezk ezk ezk i386-unknown-freebsd2.2.1 ezk ezk ezk ezk i386-unknown-freebsd3.0 ezk ezk ezk ezk @@ -30,8 +31,10 @@ i386-unknown-netbsd1.3.1 ezk ezk ezk ezk i386-unknown-openbsd2.1 ezk ezk ezk ezk i486-ncr-sysv4.3.03 ezk ezk i486-pc-linux-gnulibc1 ezk ezk ezk ezk +i586-pc-linux-gnu ezk ezk ezk ezk i586-pc-linux-gnulibc1 ezk ezk ezk ezk i686-pc-linux-gnu ezk ezk ezk ezk +i686-pc-linux-gnulibc ezk ezk ezk ezk m68k-hp-hpux9.00 ezk[4] ezk[4] nrh/ezk m68k-next-nextstep3 ezk ezk ezk m68k-sun-sunos4.1.1 ezk ezk @@ -50,6 +53,7 @@ sparc-sun-solaris2.4 ezk ezk ezk ezk sparc-sun-solaris2.5 ezk ezk ezk ezk sparc-sun-solaris2.5.1 ezk ezk ezk ezk sparc-sun-solaris2.6 ezk ezk[2] ezk ezk +sparc-sun-solaris2.7 ezk ezk[2] ezk ezk sparc-sun-sunos4.1.1 ezk ezk ezk ezk sparc-sun-sunos4.1.3 ezk ezk ezk ezk sparc-sun-sunos4.1.3C ezk ezk ezk ezk @@ -57,6 +61,7 @@ sparc-sun-sunos4.1.3_U1 ezk ezk ezk ezk sparc-sun-sunos4.1.4 ezk ezk ezk ezk sparc-unknown-linux-gnulibc1 ezk ezk ezk ezk sparc-unknown-netbsd1.2E ezk ezk ezk +sparc64-unknown-linux-gnu ezk ezk ezk ezk EMAIL ID LEGEND: diff --git a/contrib/amd/MIRRORS b/contrib/amd/MIRRORS index 6ea3dbf..dba537f 100644 --- a/contrib/amd/MIRRORS +++ b/contrib/amd/MIRRORS @@ -11,12 +11,15 @@ U.S.A: New York (Primary Site): ftp://shekel.mcl.cs.columbia.edu/pub/am-utils Maintainer: ezk@cs.columbia.edu - Maryland: + Minnesota: ftp://ftp.cs.umn.edu/pub/AMD Maintainer: dokas@cs.umn.edu Virginia (Newport News): -* ftp://www.ferginc.com/pub/unix/am-utils + ftp://www.ferginc.com/pub/unix/am-utils Maintainer: Branson.Matheson@FergInc.com + Ohio (Kent State University): + ftp://info.mcs.kent.edu/pub/am-utils + Maintainer: root@mcs.kent.edu Europe: Germany: @@ -27,7 +30,7 @@ Europe: Maintainer: archive@ftp.sunet.se Sweden: ftp://ftp.matematik.su.se/pub/mirrors/shekel.mcl.cs.columbia.edu/pub/am-utils - Maintainer: lifj@matematik.su.se + Maintainer: leifj@matematik.su.se UK: ftp://sunsite.org.uk/packages/am-utils Maintainer: lmjm@icparc.ic.ac.uk diff --git a/contrib/amd/NEWS b/contrib/amd/NEWS index f1df1e0..e56d47d 100644 --- a/contrib/amd/NEWS +++ b/contrib/amd/NEWS @@ -1,3 +1,19 @@ +*** Notes specific to am-utils version 6.0b1: + +- updated or minor new ports: + - *-pc-linux-gnu (glibc2 systems such as RedHat 5.1) + - sparc-sun-solaris2.7 + - i386-pc-solaris2.7 + - i386-unknown-freebsd3.0 (official release, post 4.4lite port) + - sparc64-unknown-linux-gnu (RH 5.1 on Sun Sparc Ultra) + +- bugs fixed: + - major memory leak in processing of /defaults + - core dump if map_type given in amd.conf doesn't exist + - memory leak in replacement yp_all + - don't access uninitialized memory in DU 4.0 + - other smaller bugs, see ChangeLog + *** Notes specific to am-utils version 6.0a16: - new ports: diff --git a/contrib/amd/README.y2k b/contrib/amd/README.y2k new file mode 100644 index 0000000..27ed553 --- /dev/null +++ b/contrib/amd/README.y2k @@ -0,0 +1,18 @@ +# -*- text -*- + AM-UTILS YEAR-2000 COMPLIANCE + +Most likely am-utils is y2k compliant. + +I do not know for sure because I have not certified am-utils myself, nor do +I have the time for it. I do not think that amd will be affected by y2k at +all, because it does not do anything with dates other than print the date on +the log file, in whatever format is provided by your os/libc --- especially +the ctime(3) call. + +However, on Friday, September 18th 1998, Matthew Crosby +reported that they evaluated 6.0a16 and found it to be compliant. + +Erez Zadok. +Maintainer, am-utils package and AMD-DEV list. +Email: amd-dev-owner@majordomo.cs.columbia.edu +WWW: http://www.cs.columbia.edu/~ezk/am-utils/ diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c index 7ef2ce7..bc750e5 100644 --- a/contrib/amd/amd/amd.c +++ b/contrib/amd/amd/amd.c @@ -57,8 +57,8 @@ struct amu_global_options gopt; /* where global options are stored */ char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */ char *progname; /* "amd" */ char *hostdomain = "unknown.domain"; -char hostname[MAXHOSTNAMELEN] = "localhost"; /* Hostname */ -char hostd[2 * MAXHOSTNAMELEN]; /* Host+domain */ +char hostname[MAXHOSTNAMELEN + 1] = "localhost"; /* Hostname */ +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 */ @@ -349,6 +349,7 @@ main(int argc, char *argv[]) plog(XLOG_FATAL, "gethostname: %m"); going_down(1); } + hostname[sizeof(hostname) - 1] = '\0'; /* * Check it makes sense diff --git a/contrib/amd/amd/amfs_auto.c b/contrib/amd/amd/amfs_auto.c index 0530142..e7f8589 100644 --- a/contrib/amd/amd/amfs_auto.c +++ b/contrib/amd/amd/amfs_auto.c @@ -1128,6 +1128,7 @@ amfs_auto_lookuppn(am_node *mp, char *fname, int *error_return, int op) 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, "failed to match defaults for \"%s\"", *sp); } else { diff --git a/contrib/amd/amd/amfs_host.c b/contrib/amd/amd/amfs_host.c index 6be259d..731c661 100644 --- a/contrib/amd/amd/amfs_host.c +++ b/contrib/amd/amd/amfs_host.c @@ -256,7 +256,7 @@ fetch_fhandle(CLIENT * client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versi (SVC_IN_ARG_TYPE) &fhp->v2, tv); if (clnt_stat != RPC_SUCCESS) { - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "mountd rpc failed: %s", msg); return EIO; } @@ -392,7 +392,7 @@ amfs_host_fmount(mntfs *mf) (SVC_IN_ARG_TYPE) & exlist, tv2); if (clnt_stat != RPC_SUCCESS) { - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "host_fmount rpc failed: %s", msg); /* clnt_perror(client, "rpc"); */ error = EIO; @@ -673,7 +673,7 @@ amfs_host_umounted(am_node *mp) tv); if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_SYSTEMERROR) { /* RPC_SYSTEMERROR seems to be returned for no good reason ... */ - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "unmount all from %s rpc failed: %s", host, msg, clnt_stat); goto out; } diff --git a/contrib/amd/amd/conf.c b/contrib/amd/amd/conf.c index a97b1b1..0ec3259 100644 --- a/contrib/amd/amd/conf.c +++ b/contrib/amd/amd/conf.c @@ -534,6 +534,11 @@ gopt_map_options(const char *val) static int gopt_map_type(const char *val) { + /* check if map type exist */ + if (!mapc_type_exists(val)) { + fprintf(stderr, "conf: no such map type \"%s\"\n", val); + return 1; + } gopt.map_type = strdup((char *)val); return 0; } @@ -846,6 +851,11 @@ ropt_map_options(const char *val, cf_map_t *cfm) static int ropt_map_type(const char *val, cf_map_t *cfm) { + /* check if map type exist */ + if (!mapc_type_exists(val)) { + fprintf(stderr, "conf: no such map type \"%s\"\n", val); + return 1; + } cfm->cfm_type = strdup((char *)val); return 0; } diff --git a/contrib/amd/amd/info_nis.c b/contrib/amd/amd/info_nis.c index eceb73a..237f6f5 100644 --- a/contrib/amd/amd/info_nis.c +++ b/contrib/amd/amd/info_nis.c @@ -52,6 +52,7 @@ #include #include + /* * NIS+ servers in NIS compat mode don't have yp_order() */ @@ -61,6 +62,7 @@ static int has_yp_order = FALSE; int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp); int nis_init(mnt_map *m, char *map, time_t *tp); +int nis_isup(mnt_map *m, char *map); int nis_mtime(mnt_map *m, char *map, time_t *tp); /* typedefs */ @@ -120,27 +122,20 @@ callback(int status, char *key, int kl, char *val, int vl, char *data) if (status == YP_TRUE) { - /* - * Add to list of maps - */ + /* add to list of maps */ char *kp = strnsave(key, kl); char *vp = strnsave(val, vl); + (*ncdp->ncd_fn) (ncdp->ncd_m, kp, vp); - /* - * We want more ... - */ + /* we want more ... */ return FALSE; } else { - /* - * NOMORE means end of map - otherwise log error - */ + /* NOMORE means end of map - otherwise log error */ if (status != YP_NOMORE) { - /* - * Check what went wrong - */ + /* check what went wrong */ int e = ypprot_err(status); #ifdef DEBUG @@ -378,16 +373,25 @@ am_yp_all(char *indomain, char *inmap, struct ypall_callback *incallback) incallback->data); if (j != FALSE) /* terminate loop */ break; + + /* + * We have to manually free all char ** arguments to yp_first/yp_next + * outval must be freed *before* calling yp_next again, outkey can be + * freed as outkey_old *after* the call (this saves one call to + * strnsave). + */ + XFREE(outval); outkey_old = outkey; outkeylen_old = outkeylen; i = yp_next(indomain, inmap, outkey_old, outkeylen_old, - &outkey, + &outkey, &outkeylen, &outval, &outvallen); + XFREE(outkey_old); } while (!i); #ifdef DEBUG if (i) { diff --git a/contrib/amd/amd/mapc.c b/contrib/amd/amd/mapc.c index de95e13..51ec7e1 100644 --- a/contrib/amd/amd/mapc.c +++ b/contrib/amd/amd/mapc.c @@ -350,10 +350,32 @@ mapc_showtypes(char *buf) /* + * Check if a map of a certain type exists. + * Return 1 (true) if exists, 0 (false) if not. + */ +int +mapc_type_exists(const char *type) +{ + map_type *mt; + + if (!type) + return 0; + for (mt = maptypes; + mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); + mt++) { + if (STREQ(type, mt->name)) + return 1; + } + return 0; /* not found anywhere */ +} + + +/* * Add key and val to the map m. * key and val are assumed to be safe copies */ -void mapc_add_kv(mnt_map *m, char *key, char *val) +void +mapc_add_kv(mnt_map *m, char *key, char *val) { kv **h; kv *n; diff --git a/contrib/amd/amd/ops_autofs.c b/contrib/amd/amd/ops_autofs.c index a566fc4..14ab415 100644 --- a/contrib/amd/amd/ops_autofs.c +++ b/contrib/amd/amd/ops_autofs.c @@ -284,7 +284,7 @@ mount_autofs(char *dir, char *opts) /* * Make a ``hostname'' string for the kernel */ - sprintf(fs_hostname, "pid%ld@%s:%s", foreground ? mypid : getppid(), + sprintf(fs_hostname, "pid%ld@%s:%s", (long) (foreground ? mypid : getppid()), hostname, dir); /* @@ -1131,6 +1131,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) 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, "failed to match defaults for \"%s\"", *sp); } else { diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h index 915f014..44b0216 100644 --- a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h +++ b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h @@ -141,15 +141,16 @@ typedef writeargs nfswriteargs; /* * - * FreeBSD 3.0 has NFS V3, but you need to regenrate the rpcsc header files - * as follows: + * FreeBSD 3.0 snapshots have NFS V3, but you need to regenrate the rpcsc + * header files as follows: * cd /usr/local/rpcsvc * rpcgen -DWANT_NFS3 mount.x * rpcgen -DWANT_NFS3 nfs_prot.x * But that's not expected of everyone, plus there are additional things - * needed so I define everything that's neede for NFS V3 here. + * needed so I define everything that's needed for NFS V3 here. + * The problem is fixed in FreeBSD-3.0-19981006-BETA hence this code is off. */ -#ifdef NFSMNT_NFSV3 +#ifdef NFSMNT_NFSV3_off # define MOUNT_NFS3 MOUNT_NFS # define MNTOPT_NFS3 "nfs" diff --git a/contrib/amd/doc/am-utils.texi b/contrib/amd/doc/am-utils.texi index ca54503..7047d06 100644 --- a/contrib/amd/doc/am-utils.texi +++ b/contrib/amd/doc/am-utils.texi @@ -745,6 +745,10 @@ features. @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab yes @tab yes @tab yes +@item @b{i386-pc-solaris2.7} +@c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} +@tab yes @tab yes @tab yes @tab yes @tab yes @tab yes + @item @b{i386-unknown-freebsd2.1.0} @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab @tab @@ -781,7 +785,11 @@ features. @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab yes @tab -@item @b{i586-pc-linux-gnulinc1} +@item @b{i586-pc-linux-gnu} +@c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} +@tab yes @tab yes @tab yes @tab n/a @tab yes @tab + +@item @b{i586-pc-linux-gnulibc1} @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab yes @tab @@ -789,6 +797,10 @@ features. @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab yes @tab +@item @b{i686-pc-linux-gnulibc1} +@c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} +@tab yes @tab yes @tab yes @tab n/a @tab yes @tab + @item @b{m68k-hp-hpux9.00} @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab @tab @@ -865,6 +877,10 @@ features. @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab yes @tab yes @tab yes +@item @b{sparc-sun-solaris2.7} +@c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} +@tab yes @tab yes @tab yes @tab yes @tab yes @tab yes + @item @b{sparc-sun-sunos4.1.1} @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab n/a @tab yes @tab @@ -893,6 +909,10 @@ features. @c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} @tab yes @tab yes @tab yes @tab @tab @tab +@item @b{sparc64-unknown-linux-gnu} +@c {Config} {Compile} {Amd} {NFS V.3} {Shlib} {Hlfsd} +@tab yes @tab yes @tab yes @tab n/a @tab yes @tab + @end multitable See the @file{INSTALL} in the distribution for more specific details on @@ -3396,8 +3416,9 @@ if that is required in an argument. There is no way to escape or change the quote character. To run the program @samp{rvdmount} with a host name and filesystem as -arguments would be specified by @samp{mount:="/etc/rvdmount rvdmount -fserver $@{path@}"}. +arguments would be specified by +@samp{fs:=$@{autodir@}$@{path@};mount:="/etc/rvdmount rvdmount fserver +$@{fs@}"}. The first element in the array is taken as the pathname of the program to execute. The other members of the array form the argument vector to diff --git a/contrib/amd/doc/stamp-vti b/contrib/amd/doc/stamp-vti index 225ecdb..3240433 100644 --- a/contrib/amd/doc/stamp-vti +++ b/contrib/amd/doc/stamp-vti @@ -1,3 +1,3 @@ -@set UPDATED 22 April 1998 -@set EDITION 6.0a16 -@set VERSION 6.0a16 +@set UPDATED 19 October 1998 +@set EDITION 6.0b1 +@set VERSION 6.0b1 diff --git a/contrib/amd/doc/version.texi b/contrib/amd/doc/version.texi index 225ecdb..3240433 100644 --- a/contrib/amd/doc/version.texi +++ b/contrib/amd/doc/version.texi @@ -1,3 +1,3 @@ -@set UPDATED 22 April 1998 -@set EDITION 6.0a16 -@set VERSION 6.0a16 +@set UPDATED 19 October 1998 +@set EDITION 6.0b1 +@set VERSION 6.0b1 diff --git a/contrib/amd/fixmount/fixmount.c b/contrib/amd/fixmount/fixmount.c index 9769a41..0bb51f9 100644 --- a/contrib/amd/fixmount/fixmount.c +++ b/contrib/amd/fixmount/fixmount.c @@ -68,7 +68,7 @@ extern int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) static char dir_path[NFS_MAXPATHLEN]; static char localhost[] = "localhost"; -static char thishost[MAXHOSTNAMELEN] = ""; +static char thishost[MAXHOSTNAMELEN + 1] = ""; static exports mntexports; static int quiet = 0; static int type = 0; @@ -354,6 +354,7 @@ main(int argc, char *argv[]) perror("gethostname"); exit(1); } + thishost[sizeof(thishost) - 1] = '\0'; /* * We need the hostname as it appears to the other side's diff --git a/contrib/amd/hlfsd/hlfsd.c b/contrib/amd/hlfsd/hlfsd.c index 388c65b..ba88237 100644 --- a/contrib/amd/hlfsd/hlfsd.c +++ b/contrib/amd/hlfsd/hlfsd.c @@ -85,7 +85,7 @@ char *logfile = DEFAULT_LOGFILE; char *passwdfile = NULL; /* alternate passwd file to use */ char *progname; char *slinkname = 0; -char hostname[MAXHOSTNAMELEN] = "localhost"; +char hostname[MAXHOSTNAMELEN + 1] = "localhost"; int cache_interval = DEFAULT_CACHE_INTERVAL; int foreground = 1; /* This is the top-level server */ gid_t hlfs_gid = (gid_t) INVALIDID; @@ -308,7 +308,8 @@ main(int argc, char *argv[]) } /* get hostname for logging and open log before we reset umask */ - gethostname(hostname, MAXHOSTNAMELEN); + gethostname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = '\0'; if ((dot = strchr(hostname, '.')) != NULL) *dot = '\0'; if (logfile) diff --git a/contrib/amd/hlfsd/stubs.c b/contrib/amd/hlfsd/stubs.c index 2ead112..ac97c0b 100644 --- a/contrib/amd/hlfsd/stubs.c +++ b/contrib/amd/hlfsd/stubs.c @@ -279,7 +279,7 @@ getcreds(struct svc_req *rp, uid_t *u, gid_t *g) case AUTH_DES: adp = (struct authdes_cred *) rp->rq_clntcred; *g = INVALIDID; /* some unknown group id */ - if (sscanf(adp->adc_fullname.name, "unix.%lu@", u) == 1) + if (sscanf(adp->adc_fullname.name, "unix.%lu@", (u_long *) u) == 1) break; /* fall through */ #endif /* HAVE_RPC_AUTH_DES_H */ diff --git a/contrib/amd/include/am_defs.h b/contrib/amd/include/am_defs.h index 690d033..badb4ec 100644 --- a/contrib/amd/include/am_defs.h +++ b/contrib/amd/include/am_defs.h @@ -487,6 +487,18 @@ extern int errno; /* conflicts with */ # define _SYS_STATFS_H # endif /* HAVE_SOCKETBITS_H */ +# ifdef HAVE_LINUX_POSIX_TYPES_H +# include +# endif /* HAVE_LINUX_POSIX_TYPES_H */ +# ifndef _LINUX_BYTEORDER_GENERIC_H +# define _LINUX_BYTEORDER_GENERIC_H +# endif /* _LINUX_BYTEORDER_GENERIC_H */ +/* conflicts with in 2.1 kernels */ +# ifdef _SYS_MOUNT_H +# ifdef BLOCK_SIZE +# undef BLOCK_SIZE +# endif /* BLOCK_SIZE */ +# endif /* _SYS_MOUNT_H */ # include #endif /* HAVE_LINUX_FS_H */ diff --git a/contrib/amd/include/am_utils.h b/contrib/amd/include/am_utils.h index f4e0ccf..f088a4e 100644 --- a/contrib/amd/include/am_utils.h +++ b/contrib/amd/include/am_utils.h @@ -565,6 +565,7 @@ extern int make_nfs_auth(void); extern int make_rpc_packet(char *, int, u_long, struct rpc_msg *, voidp, XDRPROC_T_TYPE, AUTH *); extern int mapc_keyiter(mnt_map *, void(*)(char *, voidp), voidp); extern int mapc_search(mnt_map *, char *, char **); +extern int mapc_type_exists(const char *type); extern int mkdirs(char *, int); extern int mount_auto_node(char *, voidp); extern int mount_automounter(int); diff --git a/contrib/amd/libamu/clnt_sperrno.c b/contrib/amd/libamu/clnt_sperrno.c new file mode 100644 index 0000000..d3b48d1 --- /dev/null +++ b/contrib/amd/libamu/clnt_sperrno.c @@ -0,0 +1,147 @@ +/* + * 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 +#endif /* HAVE_CONFIG_H */ +#include +#include + + +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/xutil.c b/contrib/amd/libamu/xutil.c index 15d2cee..35e7f91 100644 --- a/contrib/amd/libamu/xutil.c +++ b/contrib/amd/libamu/xutil.c @@ -797,6 +797,7 @@ amu_release_controlling_tty(void) #endif /* TIOCNOTTY */ #ifdef HAVE_SETSID + /* XXX: one day maybe use vhangup(2) */ if (setsid() < 0) { plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m"); } else { diff --git a/contrib/amd/mk-amd-map/mk-amd-map.c b/contrib/amd/mk-amd-map/mk-amd-map.c index 2b41540..1ce4c3a 100644 --- a/contrib/amd/mk-amd-map/mk-amd-map.c +++ b/contrib/amd/mk-amd-map/mk-amd-map.c @@ -57,6 +57,11 @@ int orig_umask, foreground, debug_flags; pid_t mypid; serv_state amd_state; +/* (libdb version 2) uses .db extensions but an old dbm API */ +/* check for libgdbm to distinguish it from linux systems */ +#if defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM) +# define HAVE_DB_SUFFIX +#endif /* not defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM) */ #ifdef HAVE_MAP_NDBM @@ -119,7 +124,7 @@ read_file(FILE *fp, char *map, voidp db) int line_no = 0; int errs = 0; - while (read_line(key_val, sizeof(key_val), fp)) { + while (read_line(key_val, 2048, fp)) { char *kp; char *cp; char *hash; @@ -213,14 +218,18 @@ remove_file(char *f) int main(int argc, char *argv[]) { - FILE *mapf; - int mapfd = -1; - char *map; - int rc = 0; - DBM *mapd = NULL; + FILE *mapf; /* the input file to read from */ + int error; + char *mapsrc; + DBM *db = NULL; static char maptmp[] = "dbmXXXXXX"; +#ifdef HAVE_DB_SUFFIX + char maptdb[16]; + char *map_name_db = (char *) NULL; +#else /* not HAVE_DB_SUFFIX */ char maptpag[16], maptdir[16]; - char *mappag = (char *) NULL, *mapdir = (char *) NULL; + char *map_name_pag = (char *) NULL, *map_name_dir = (char *) NULL; +#endif /* not HAVE_DB_SUFFIX */ int len; char *sl; int printit = 0; @@ -229,7 +238,7 @@ main(int argc, char *argv[]) extern int optind; /* test options */ - while ((ch = getopt(argc, argv, "p")) != EOF) + while ((ch = getopt(argc, argv, "p")) != -1) switch (ch) { case 'p': printit = 1; @@ -243,110 +252,134 @@ main(int argc, char *argv[]) fputs("Usage: mk-amd-map [-p] file-map\n", stderr); exit(1); } - map = argv[optind]; + mapsrc = argv[optind]; /* test if can get to the map directory */ - sl = strrchr(map, '/'); + sl = strrchr(mapsrc, '/'); if (sl) { *sl = '\0'; - if (chdir(map) < 0) { + if (chdir(mapsrc) < 0) { fputs("Can't chdir to ", stderr); - perror(map); + perror(mapsrc); exit(1); } - map = sl + 1; + mapsrc = sl + 1; } + /* open source file */ + mapf = fopen(mapsrc, "r"); + if (!mapf) { + fprintf(stderr, "cannot open source file "); + perror(mapsrc); + exit(1); + } + +#ifndef DEBUG + signal(SIGINT, SIG_IGN); +#endif /* DEBUG */ + if (!printit) { - len = strlen(map); - mappag = (char *) malloc(len + 5); - mapdir = (char *) malloc(len + 5); - if (!mappag || !mapdir) { + len = strlen(mapsrc); +#ifdef HAVE_DB_SUFFIX + map_name_db = (char *) malloc(len + 4); + error = (map_name_db == NULL); +#else /* not HAVE_DB_SUFFIX */ + 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) { perror("mk-amd-map: malloc"); exit(1); } -#ifdef HAVE_MKSTEMP - mapfd = mkstemp(maptmp); -#else /* not HAVE_MKSTEMP */ - map = mktemp(maptmp); - if (!maptmp) { - fprintf(stderr, "cannot create temporary file\n"); + + mktemp(maptmp); + + /* remove existing temps (if any) */ +#ifdef HAVE_DB_SUFFIX + sprintf(maptdb, "%s.db", maptmp); + if (remove_file(maptdb) < 0) { + fprintf(stderr, "Can't remove existing temporary file; "); + perror(maptdb); exit(1); } - mapfd = open(map, O_RDONLY); -#endif /* not HAVE_MKSTEMP */ - - /* open DBM files */ +#else /* not HAVE_DB_SUFFIX */ 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); + fprintf(stderr, "Can't remove existing temporary files; %s and ", maptpag); perror(maptdir); exit(1); } +#endif /* not HAVE_DB_SUFFIX */ + + db = dbm_open(maptmp, O_RDWR|O_CREAT, 0444); + if (!db) { + fprintf(stderr, "cannot initialize temporary database: %s", maptmp); + exit(1); + } } - /* open and check if map file was opened OK */ - mapf = fdopen(mapfd, "r"); - if (mapf && !printit) - mapd = dbm_open(maptmp, O_RDWR|O_CREAT, 0444); - else - mapd = 0; -#ifndef DEBUG - /* ignore ^C if debuggung is on (but why?) */ - signal(SIGINT, SIG_IGN); -#endif /* not DEBUG */ - - if (mapd || printit) { - int error = read_file(mapf, map, mapd); - (void) close(mapfd); - (void) fclose(mapf); - if (printit) { - if (error) { - fprintf(stderr, "Error creating ndbm map for %s\n", map); - rc = 1; - } - } else { + /* print db to stdout or to temp database */ + error = read_file(mapf, mapsrc, db); + fclose(mapf); + if (error) { + if (printit) + fprintf(stderr, "Error reading source file %s\n", mapsrc); + else + fprintf(stderr, "Error creating database map for %s\n", mapsrc); + exit(1); + } - if (error) { - fprintf(stderr, "Error reading source file %s\n", map); - rc = 1; - } else { - sprintf(mappag, "%s.pag", map); - sprintf(mapdir, "%s.dir", map); - if (rename(maptpag, mappag) < 0) { - fprintf(stderr, "Couldn't rename %s to ", maptpag); - perror(mappag); - /* Throw away the temporary map */ - unlink(maptpag); - unlink(maptdir); - rc = 1; - - } else if (rename(maptdir, mapdir) < 0) { - fprintf(stderr, "Couldn't rename %s to ", maptdir); - perror(mapdir); - /* Put the .pag file back */ - rename(mappag, maptpag); - /* Throw away remaining part of original map */ - unlink(mapdir); - fprintf(stderr, - "WARNING: existing map \"%s.{dir,pag}\" destroyed\n", - map); - rc = 1; - } - } - } + if (printit) + exit(0); /* nothing more to do */ + + /* if gets here, we wrote to a database */ + + dbm_close(db); + /* all went well */ - } else { - fprintf(stderr, "Can't open \"%s.{dir,pag}\" for ", map); - perror("writing"); - rc = 1; +#ifdef HAVE_DB_SUFFIX + 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); + /* Throw away the temporary map */ + unlink(maptdb); + exit(1); + } +#else /* not HAVE_DB_SUFFIX */ + 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); + /* Throw away the temporary map */ + unlink(maptpag); + unlink(maptdir); + exit(1); } - exit(rc); + if (rename(maptdir, map_name_dir) < 0) { + fprintf(stderr, "Couldn't rename %s to ", maptdir); + perror(map_name_dir); + /* remove the (presumably bad) .pag file */ + unlink(map_name_pag); + /* throw away remaining part of original map */ + unlink(map_name_dir); + /* throw away the temporary map */ + unlink(maptdir); + fprintf(stderr, "WARNING: existing map \"%s.{dir,pag}\" destroyed\n", + mapsrc); + exit(1); + } +#endif /* not HAVE_DB_SUFFIX */ + + exit(0); } #else /* not HAVE_MAP_NDBM */ +int main() { fputs("mk-amd-map: This system does not support hashed database files\n", stderr); diff --git a/contrib/amd/scripts/Makefile.am b/contrib/amd/scripts/Makefile.am index 9ebd691..c438058 100644 --- a/contrib/amd/scripts/Makefile.am +++ b/contrib/amd/scripts/Makefile.am @@ -34,7 +34,7 @@ EXTRA_DIST = \ amd2sun.in \ ctl-amd.in \ ctl-hlfsd.in \ - fixrmtab \ + fixrmtab.in \ fix-amd-map.in \ lostaltmail.in \ wait4amd.in \ diff --git a/contrib/amd/scripts/Makefile.in b/contrib/amd/scripts/Makefile.in index 1c69cec..a20d846 100644 --- a/contrib/amd/scripts/Makefile.in +++ b/contrib/amd/scripts/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.3.1 from Makefile.am +# Makefile.in generated automatically by automake 1.3.2 from Makefile.am # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -106,7 +106,7 @@ EXTRA_DIST = \ amd2sun.in \ ctl-amd.in \ ctl-hlfsd.in \ - fixrmtab \ + fixrmtab.in \ fix-amd-map.in \ lostaltmail.in \ wait4amd.in \ @@ -122,7 +122,7 @@ CLEANFILES = $(sbin_SCRIPTS) $(bin_SCRIPTS) mkinstalldirs = $(SHELL) $(top_srcdir)/aux/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = am-eject amd2ldif amd2sun ctl-amd ctl-hlfsd expn \ -fix-amd-map lostaltmail wait4amd wait4amd2die +fixrmtab fix-amd-map lostaltmail wait4amd wait4amd2die SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) man1dir = $(mandir)/man1 @@ -133,7 +133,7 @@ NROFF = nroff DATA = $(sysconf_DATA) DIST_COMMON = Makefile.am Makefile.in am-eject.in amd2ldif.in \ -amd2sun.in ctl-amd.in ctl-hlfsd.in expn.in fix-amd-map.in \ +amd2sun.in ctl-amd.in ctl-hlfsd.in expn.in fix-amd-map.in fixrmtab.in \ lostaltmail.in wait4amd.in wait4amd2die.in @@ -163,6 +163,8 @@ ctl-hlfsd: $(top_builddir)/config.status ctl-hlfsd.in cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status expn: $(top_builddir)/config.status expn.in cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status +fixrmtab: $(top_builddir)/config.status fixrmtab.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status fix-amd-map: $(top_builddir)/config.status fix-amd-map.in cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status lostaltmail: $(top_builddir)/config.status lostaltmail.in diff --git a/contrib/amd/scripts/amd.conf.5 b/contrib/amd/scripts/amd.conf.5 index 2022fad..cf9e15e 100644 --- a/contrib/amd/scripts/amd.conf.5 +++ b/contrib/amd/scripts/amd.conf.5 @@ -40,7 +40,7 @@ .\" .\" $Id: amd.conf.5,v 5.2.2.1 1997/02/09 15:11:15 ezk beta $ .\" -.TH AMQ.CONF 8 "7 August 1997" +.TH AMD.CONF 8 "7 August 1997" .SH NAME amd.conf \- amd configuration file .SH SYNOPSIS diff --git a/contrib/amd/scripts/fixrmtab.in b/contrib/amd/scripts/fixrmtab.in new file mode 100755 index 0000000..33b7bcf --- /dev/null +++ b/contrib/amd/scripts/fixrmtab.in @@ -0,0 +1,24 @@ +#!/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 + +#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/tasks b/contrib/amd/tasks index a29b554..0b44340 100644 --- a/contrib/amd/tasks +++ b/contrib/amd/tasks @@ -62,3 +62,9 @@ through. amd.conf file (right now amd.conf overrides cmd-line options). - y2k compliance. + +- an un/install script for binaries + +- update README +add am-utils URL and COPYRIGHT to all distributed scripts and +sources and programs etc. diff --git a/contrib/amd/wire-test/wire-test.c b/contrib/amd/wire-test/wire-test.c index c53094b..11e3e99 100644 --- a/contrib/amd/wire-test/wire-test.c +++ b/contrib/amd/wire-test/wire-test.c @@ -50,7 +50,7 @@ #define STRMAX 100 /* dummy variables */ -char *progname, hostname[MAXHOSTNAMELEN]; +char *progname, hostname[MAXHOSTNAMELEN + 1]; int orig_umask, foreground, debug_flags; pid_t mypid; serv_state amd_state; @@ -69,10 +69,11 @@ main(int argc, char **argv) mypid = getpid(); orig_umask = umask(0); - if (gethostname(hostname, MAXHOSTNAMELEN) < 0) { + if (gethostname(hostname, sizeof(hostname)) < 0) { perror(argv[0]); exit(1); } + hostname[sizeof(hostname) - 1] = '\0'; /* get list of networks */ getwire(&networkName1, &networkNumber1); -- cgit v1.1