* AUTHORS: add Dan Ottavio.
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 4 Mar 2005 18:42:43 +0000 (18:42 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 4 Mar 2005 18:42:43 +0000 (18:42 +0000)
* scripts/amd.conf.5: document new debug_mtab_file option.

* scripts/amd.conf-sample (debug_mtab_file): show example.

* doc/am-utils.texi (debug_mtab_file Parameter): document new
option.

* conf/mtab/mtab_{file,mach3}.c (open_locked_mtab): if mtab file
doesn't exist by the time Amd tries to exist, return a 0 rather
than hang indefinitely.

* amd/conf.c (gopt_debug_mtab_file): new function to parse
debug_mtab_file option.

* amd/amd.h: placeholder for debug_mtab_file string.
Define default debug_mtab_file to "/tmp/mtab".

* NEWS: document new debug_mtab_file option.

12 files changed:
AUTHORS
ChangeLog
NEWS
amd/amd.h
amd/conf.c
amd/get_args.c
conf/mtab/mtab_file.c
conf/mtab/mtab_mach3.c
doc/am-utils.texi
include/am_utils.h
scripts/amd.conf-sample
scripts/amd.conf.5

diff --git a/AUTHORS b/AUTHORS
index 36f176359d8a8e4eba32f78cbc2458f643ff8f60..63b1969c114db4573aa15aaa8ae507474b1509ed 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -400,3 +400,9 @@ when the mount point has an ancestor (i.e. '/') that is mounted read-only.
 
 * Kevin Layer <layer@franz.com>
 January 28, 2005: basic instructions how to setup Amd on Mac OS-X.
+
+* Dan Ottavio <dottavio@ic.sunysb.edu>
+March 2, 2005: new global amd.conf option debug_mtab_file, to set the debug
+mtab file when using debug_options=mtab.  Default has changed from "./mtab"
+to "/tmp/mtab" to avoid security problem.  Bug fixed to ensure that Amd
+terminates properly even mtab file doesn't exist.
index e4bd6db1fe2b77eaca898dd5762d61bd66473c21..65835763452a9c73546ed9420e6760bfabbbba7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-03-02  Daniel P. Ottavio  <dottavio@ic.sunysb.edu>
+
+       * AUTHORS: add Dan Ottavio.
+
+       * scripts/amd.conf.5: document new debug_mtab_file option.
+
+       * scripts/amd.conf-sample (debug_mtab_file): show example.
+
+       * doc/am-utils.texi (debug_mtab_file Parameter): document new
+       option.
+
+       * conf/mtab/mtab_{file,mach3}.c (open_locked_mtab): if mtab file
+       doesn't exist by the time Amd tries to exist, return a 0 rather
+       than hang indefinitely.
+
+       * amd/conf.c (gopt_debug_mtab_file): new function to parse
+       debug_mtab_file option.
+
+       * amd/amd.h: placeholder for debug_mtab_file string.
+       Define default debug_mtab_file to "/tmp/mtab".
+
+       * NEWS: document new debug_mtab_file option.
+
 2005-03-02  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * conf/transp/transp_{sockets,tli}.c (amu_get_myaddress): when
diff --git a/NEWS b/NEWS
index ce09a6c269149e70e92cc63d3f99fa18cfb9e255..db24c238d626f0ddd296cf524bc44ba798d2cb8d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,9 @@
   the UDP+TCP port that Amd's amq service will use with the RPC portmapper.
   Useful with firewalls and NAT'ed environments.
 
+- new amd.conf option "debug_mtab_file".  Allows user to define the mtab
+  file during debug-mtab mode.  The default path is "/tmp/mnttab".
+
 - new function selector xhost(ARG) which will match ARG against the current
   host name.  This works even if ARG is a CNAME (unlike the host==ARG
   selector).
        * don't warn when couldn't rmdir a dir with a readonly ancestor.
        * avoid hangs of amd in ctl-amd (must chdir to /)
        * workaround occasional daemonizing problems (parent won't die)
+       * don't hang on exit if debug_options=mtab was used
 
 *** Notes specific to am-utils version 6.1b4
 
index 1364f18ac251d289106c572f4b89c49b4f193761..b1b449f8bf49e8bc8c65021d15fef592f80cd3b8 100644 (file)
--- a/amd/amd.h
+++ b/amd/amd.h
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: amd.h,v 1.59 2005/03/02 03:00:09 ezk Exp $
+ * $Id: amd.h,v 1.60 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
  * MACROS:
  */
 
+/*
+ * Define a default debug mtab path for systems
+ * that support mtab on file.
+ */
+#ifdef MOUNT_TABLE_ON_FILE
+# define DEBUG_MNTTAB_FILE               "/tmp/mnttab"
+#endif
+
 /* options for amd.conf */
 #define CFM_BROWSABLE_DIRS             0x0001
 #define CFM_MOUNT_TYPE_AUTOFS          0x0002 /* use kernel autofs support */
@@ -260,6 +268,7 @@ struct amu_global_options {
   char *map_type;              /* global map type */
   char *search_path;           /* search path for maps */
   char *mount_type;            /* mount type for map */
+  char *debug_mtab_file;        /* path for the mtab file during debug mode */
   u_int flags;                 /* various CFM_* flags */
 
 #define AMU_TYPE_UDP 0         /* for amfs_auto_{retrans,timeo} */
index 23e513a52a88a77adfda245d21235d4265618b6a..d5cd76dafefb98ff0675553f6765c9aac7f8fa0b 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: conf.c,v 1.29 2005/02/23 03:59:08 ezk Exp $
+ * $Id: conf.c,v 1.30 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
@@ -81,6 +81,7 @@ static int gopt_autofs_use_lofs(const char *val);
 static int gopt_browsable_dirs(const char *val);
 static int gopt_cache_duration(const char *val);
 static int gopt_cluster(const char *val);
+static int gopt_debug_mtab_file(const char *val);
 static int gopt_debug_options(const char *val);
 static int gopt_dismount_interval(const char *val);
 static int gopt_domain_strip(const char *val);
@@ -155,6 +156,7 @@ static struct _func_map glob_functable[] = {
   {"browsable_dirs",           gopt_browsable_dirs},
   {"cache_duration",           gopt_cache_duration},
   {"cluster",                  gopt_cluster},
+  {"debug_mtab_file",           gopt_debug_mtab_file},
   {"debug_options",            gopt_debug_options},
   {"dismount_interval",                gopt_dismount_interval},
   {"domain_strip",             gopt_domain_strip},
@@ -428,6 +430,14 @@ gopt_cluster(const char *val)
 }
 
 
+static int
+gopt_debug_mtab_file(const char *val)
+{
+  gopt.debug_mtab_file = strdup((char*)val);
+  return 0;
+}
+
+
 static int
 gopt_debug_options(const char *val)
 {
index 232c396130e5c70dbfabdc453925b2f68e905ba8..a5d926fc439d584bbfbb1b50f9a7ecdab9505798 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: get_args.c,v 1.27 2005/02/17 21:32:05 ezk Exp $
+ * $Id: get_args.c,v 1.28 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
@@ -381,7 +381,10 @@ get_args(int argc, char *argv[])
 
 #ifdef MOUNT_TABLE_ON_FILE
     if (amuDebug(D_MTAB))
-      mnttab_file_name = DEBUG_MNTTAB;
+      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 */
     else
       mnttab_file_name = MNTTAB_FILE_NAME;
 #else /* not MOUNT_TABLE_ON_FILE */
index cd2cfacb416982de119388a0d250f9746d5ed17d..74e16ac896e936ac367687c68378dcda599592c4 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: mtab_file.c,v 1.14 2005/01/03 20:56:45 ezk Exp $
+ * $Id: mtab_file.c,v 1.15 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
@@ -137,7 +137,14 @@ again:
       sleep(1);
       goto again;
     }
-    return 0;
+    /*
+     * If 'mnttabname' file does not exist give setmntent() a
+     * chance to create it (depending on the mode).
+     * Otherwise, bail out.
+     */
+    else if (errno != ENOENT) {
+      return 0;
+    }
   }
 
 eacces:
index 541e9727f4380160e8b6c2120de33964dc2adb6d..1431b1b5150b5fd8936089b2a1ee5c4ab2dc9f15 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: mtab_mach3.c,v 1.12 2005/01/03 20:56:45 ezk Exp $
+ * $Id: mtab_mach3.c,v 1.13 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
@@ -135,7 +135,14 @@ again:
       sleep(1);
       goto again;
     }
-    return 0;
+    /*
+     * If 'mnttabname' file does not exist give setmntent() a
+     * chance to create it (depending on the mode).
+     * Otherwise, bail out.
+     */
+    else if (errno != ENOENT) {
+      return 0;
+    }
   }
 eacces:
   mfp = setmntent(mnttabname, mode);
index 688af5ca979108dacab51be03a384f33c86f1b96..a658cdbed15ca96d4064c62d7577d57b02bf5bca 100644 (file)
@@ -38,7 +38,7 @@
 @c
 @c      %W% (Berkeley) %G%
 @c
-@c $Id: am-utils.texi,v 1.96 2005/03/02 03:00:09 ezk Exp $
+@c $Id: am-utils.texi,v 1.97 2005/03/04 18:42:43 ezk Exp $
 @c
 @setfilename am-utils.info
 
@@ -4222,6 +4222,7 @@ The following parameters are applicable to the @samp{[global]} section only.
 * auto_dir Parameter::
 * cache_duration Parameter::
 * cluster Parameter::
+* debug_mtab_file Parameter::
 * debug_options Parameter::
 * dismount_interval Parameter::
 * domain_strip Parameter::
@@ -4312,7 +4313,7 @@ sub-directories for its real mount points.
 in the cache.
 
 @c ----------------------------------------------------------------
-@node cluster Parameter, debug_options Parameter, cache_duration Parameter, Global Parameters
+@node cluster Parameter, debug_mtab_file Parameter, cache_duration Parameter, Global Parameters
 @comment  node-name,  next,  previous,  up
 @subsection @t{cluster} Parameter
 @cindex cluster Parameter
@@ -4320,8 +4321,18 @@ in the cache.
 (type=string, default no cluster).  Same as the @code{-C} option to
 @i{Amd}.  Specifies the alternate HP-UX cluster to use.
 
+@c ---------------------------------------------------------------- 
+@node debug_mtab_file Parameter, debug_options Parameter, cluster Parameter, Global Parameters 
+@comment  node-name,  next,  previous,  up 
+@subsection @t{debug_mtab_file} Parameter 
+@cindex debug_mtab_file Parameter 
+
+(type=string, default="/tmp/mnttab").  Path to mtab file that is used 
+by @i{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.
+
 @c ----------------------------------------------------------------
-@node debug_options Parameter, dismount_interval Parameter, cluster Parameter, Global Parameters
+@node debug_options Parameter, dismount_interval Parameter, debug_mtab_file Parameter, Global Parameters
 @comment  node-name,  next,  previous,  up
 @subsection @t{debug_options} Parameter
 @cindex debug_options Parameter
@@ -4346,7 +4357,6 @@ values those listed for the -D option.  @xref{-D Option}.
 @i{Amd}.  Specify in seconds, the time between attempts to dismount file
 systems that have exceeded their cached times.
 
-
 @c ----------------------------------------------------------------
 @node domain_strip Parameter, full_os Parameter, dismount_interval Parameter, Global Parameters
 @comment  node-name,  next,  previous,  up
index 08699b61dc4a8300a9776c4925c23c29bb3a45e3..ce3ffa69a2d79c553857c8d9cbc0376be04e7e1e 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: am_utils.h,v 1.61 2005/03/02 03:00:09 ezk Exp $
+ * $Id: am_utils.h,v 1.62 2005/03/04 18:42:43 ezk Exp $
  *
  */
 
@@ -378,11 +378,6 @@ extern int unregister_autofs_service(char *autofs_conftype);
  * DEBUGGING:
  */
 
-/* debugging mount-table file to use */
-#ifndef DEBUG_MNTTAB
-# define DEBUG_MNTTAB  "./mnttab"
-#endif /* not DEBUG_MNTTAB */
-
 #ifdef DEBUG
 
 # define       D_ALL           (~(D_MTAB|D_HRTIME|D_XDRTRACE|D_DAEMON|D_FORK|D_AMQ))
index b12fa1e7da8115f3193c77f04a0ec3c3ffc2405f..5a75532d81535d1fa0d151ed24ba78c8a12a0366 100644 (file)
@@ -57,6 +57,8 @@ log_options =                 fatal,error,user,warn,info,map,stats,all
 # (amd -D)
 debug_options =                        all,amq,daemon,fork,full,hrtime,info,mem,mtab,\
                                str,readdir,test,trace,xdrtrace
+# path for mtab file during mtab debug mode
+debug_mtab_file =               /tmp/mnttab
 # (amd -S)
 plock =                                yes | no
 # selectors are not recognized by default in the /defaults entry
index 097261e78549736e54bf1cba53be398ecda1d51a..15c586c8d11326e576d63be1eda08710351b4135 100644 (file)
@@ -38,7 +38,7 @@
 .\"
 .\"    %W% (Berkeley) %G%
 .\"
-.\" $Id: amd.conf.5,v 1.33 2005/02/23 03:59:09 ezk Exp $
+.\" $Id: amd.conf.5,v 1.34 2005/03/04 18:42:43 ezk Exp $
 .\"
 .TH AMD.CONF 5 "7 August 1997"
 .SH NAME
@@ -216,6 +216,13 @@ 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)"
 Same as the