* 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 $
*
*/
* 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 *);
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"),
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 },
}
-/* 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;
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) {
}
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;
}
/*
* 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 *
@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
* netgrpd Selector Function::
* in_network Selector Function::
* true Selector Function::
+* xhost Selector Function::
@end menu
@c ----------------------------------------------------------------
@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
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