* doc/am-utils.texi (xhost Selector Function): document new
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 26 Jan 2005 06:16:30 +0000 (06:16 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 26 Jan 2005 06:16:30 +0000 (06:16 +0000)
selector function.

* amd/opts.c (f_xhost): new function for use when matching the
(CNAMES) that gethostbyname() returns.  This function now supports
a new function selector called xhost(ARG); the old host==ARG
selector is unharmed.

ChangeLog
NEWS
amd/opts.c
doc/am-utils.texi

index 743297fe99fffa8221aebb9f76a8e71958ec0826..8950e10cb397121c62bb453659b2075431e75767 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,14 @@
-2005-01-18  Erez Zadok  <ezk@cs.sunysb.edu>
+2005-01-26  Erez Zadok  <ezk@cs.sunysb.edu>
 
-       * amd/opts.c (f_in_xhost): new function for use when matching the
+       * doc/am-utils.texi (xhost Selector Function): document new
+       selector function.
+
+       * amd/opts.c (f_xhost): new function for use when matching the
        "host" selector for the current host's name.  This function will
        now match the primary host name as well as all known aliases
-       (CNAMES) that gethostbyname() returns.
+       (CNAMES) that gethostbyname() returns.  This function now supports
+       a new function selector called xhost(ARG); the old host==ARG
+       selector is unharmed.
 
 2005-01-17  Ion Badulescu  <ionut@moisil.badula.org>
 
diff --git a/NEWS b/NEWS
index 971433ee2934f68dbf8a3ef46d481d0e07caf630..edc227bf2c6d9b11fe7a93d07e0e7b5873cc99ab 100644 (file)
--- a/NEWS
+++ b/NEWS
   value, and you get ESTALE errors on your particular OS, then set this
   value back to 0 seconds.
 
+- 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).
+
 - support restarting the automounter's own mount points (only over NFS,
   for now).
 
@@ -80,7 +84,6 @@
          daemonizing.
        * fix inconsistency between Socket and TLI RPC timeouts.
        * don't warn when couldn't rmdir a dir with a readonly ancestor.
-       * "host" selector also matches against host aliases (CNAMES)
 
 *** Notes specific to am-utils version 6.1b4
 
index 9c9f7c31e3d4c1abe37c5aca935a671761744f97..71ce416bc3e21d3a7aedee0358abcfd3ddece0bc 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: opts.c,v 1.33 2005/01/19 04:35:47 ezk Exp $
+ * $Id: opts.c,v 1.34 2005/01/26 06:16:30 ezk Exp $
  *
  */
 
@@ -93,7 +93,7 @@ struct functable {
  * FORWARD DEFINITION:
  */
 static int f_in_network(char *);
-static int f_in_xhost(char *);
+static int f_xhost(char *);
 static int f_netgrp(char *);
 static int f_netgrpd(char *);
 static int f_exists(char *);
@@ -134,13 +134,8 @@ static struct opt opt_fields[] = {
        Option str.             Selector str.   boolean fxn.    case sensitive */
   { S("opts"),
        &fs_static.opt_opts,    0,              0,              FALSE   },
-#if 0
-  /* old way of matching host selector without cnames */
   { S("host"),
        0,                      &opt_host,      0,              TRUE    },
-#endif
-  { S("host"),
-       0,                      0,              f_in_xhost,     TRUE    },
   { S("hostd"),
        0,                      &opt_hostd,     0,              TRUE    },
   { S("type"),
@@ -244,7 +239,7 @@ static struct opt opt_fields[] = {
 
 static struct functable functable[] = {
   { "in_network",      f_in_network },
-  { "in_xhost",                f_in_xhost },
+  { "xhost",           f_xhost },
   { "netgrp",          f_netgrp },
   { "netgrpd",         f_netgrpd },
   { "exists",          f_exists },
@@ -841,9 +836,13 @@ f_in_network(char *arg)
 }
 
 
-/* test if arg is any of this host's names or aliases (CNAMES) */
+/*
+ * Test if arg is any of this host's names or aliases (CNAMES).
+ * Note: this function compares against the fully expanded host name (hostd).
+ * XXX: maybe we also need to compare against the stripped host name?
+ */
 static int
-f_in_xhost(char *arg)
+f_xhost(char *arg)
 {
   struct hostent *hp;
   char **cp;
@@ -852,19 +851,22 @@ f_in_xhost(char *arg)
     return 0;
 
   /* simple test: does it match main host name? */
-  if (STREQ(arg, opt_host))
+  if (STREQ(arg, opt_hostd))
     return 1;
 
-  /* now find all of the names of "arg" and compare against opt_host */
+  /* now find all of the names of "arg" and compare against opt_hostd */
   hp = gethostbyname(arg);
   if (hp == NULL) {
-    plog(XLOG_ERROR, "xhost(%s): %s", arg, hstrerror(h_errno));
+    plog(XLOG_ERROR, "gethostbyname xhost(%s): %s", arg, hstrerror(h_errno));
     return 0;
   }
   /* check primary name */
-  if (hp->h_name && STREQ(hp->h_name, opt_host)) {
-    plog(XLOG_INFO, "xhost(%s): matched h_name %s", arg, hp->h_name);
-    return 1;
+  if (hp->h_name) {
+    dlog("xhost: compare %s==%s", hp->h_name, opt_hostd);
+    if (STREQ(hp->h_name, opt_hostd)) {
+      plog(XLOG_INFO, "xhost(%s): matched h_name %s", arg, hp->h_name);
+      return 1;
+    }
   }
   /* check all aliases, if any */
   if (hp->h_aliases == NULL) {
@@ -873,8 +875,8 @@ f_in_xhost(char *arg)
   }
   cp = hp->h_aliases;
   while (*cp) {
-    dlog("xhost: compare alias %s==%s", *cp, opt_host);
-    if (STREQ(*cp, opt_host)) {
+    dlog("xhost: compare alias %s==%s", *cp, opt_hostd);
+    if (STREQ(*cp, opt_hostd)) {
       plog(XLOG_INFO, "xhost(%s): matched alias %s", arg, *cp);
       return 1;
     }
@@ -998,7 +1000,7 @@ normalize_slash(char *p)
 /*
  * Macro-expand an option.  Note that this does not
  * handle recursive expansions.  They will go badly wrong.
- * If sel is true then old expand selectors, otherwise
+ * If sel_p is true then old expand selectors, otherwise
  * don't expand selectors.
  */
 static char *
index 41bb624a6c10cb8962e05de5b98ba34a215aadf2..9803550f953dd203801cd2ace1cacea19dc963e4 100644 (file)
@@ -38,7 +38,7 @@
 @c
 @c      %W% (Berkeley) %G%
 @c
-@c $Id: am-utils.texi,v 1.91 2005/01/17 06:00:41 ezk Exp $
+@c $Id: am-utils.texi,v 1.92 2005/01/26 06:16:30 ezk Exp $
 @c
 @setfilename am-utils.info
 
@@ -1380,6 +1380,7 @@ The following selectors are currently implemented.
 * netgrpd Selector Function::
 * in_network Selector Function::
 * true Selector Function::
+* xhost Selector Function::
 @end menu
 
 @c ----------------------------------------------------------------
@@ -1816,7 +1817,7 @@ opt in_network(foo-net.site.com);rhost:=serv1;rfs:=/opt \
 @end example
 
 @c ----------------------------------------------------------------
-@node true Selector Function, , in_network Selector Function, Selectors
+@node true Selector Function, xhost Selector Function, in_network Selector Function, Selectors
 @comment  node-name,  next,  previous,  up
 @subsubsection true Selector Function
 @cindex true Selector Function
@@ -1827,6 +1828,22 @@ opt in_network(foo-net.site.com);rhost:=serv1;rfs:=/opt \
 
 Always evaluates to true.  @i{ARG} is ignored.
 
+@c ----------------------------------------------------------------
+@node xhost Selector Function, , true Selector Function, Selectors
+@comment  node-name,  next,  previous,  up
+@subsubsection xhost Selector Function
+@cindex xhost Selector Function
+@cindex xhost, boolean mount selector
+@cindex !xhost, boolean mount selector
+@cindex Mount selector; xhost
+@cindex Selector; xhost
+@cindex CNAMEs
+
+This function compares @i{ARG} against the current hostname, similarly
+to the @ref{host Selector Variable}.  However, this function will
+also match if @i{ARG} is a CNAME (DNS Canonical Name, or alias) for
+the current host's name.
+
 @c ================================================================
 @node Map Options,  , Selectors, Location Format
 @comment  node-name,  next,  previous,  up