]> granicus.if.org Git - sudo/commitdiff
Make hostname_matches() return TRUE for a match, else FALSE like the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 15 Nov 2004 19:38:31 +0000 (19:38 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 15 Nov 2004 19:38:31 +0000 (19:38 +0000)
caller expects.

match.c

diff --git a/match.c b/match.c
index c3ddc0fd882f38149b013715bce10f916a2fab73..93849b18ef4ec1a2561a17ee40327b403278d1c9 100644 (file)
--- a/match.c
+++ b/match.c
@@ -195,7 +195,7 @@ host_matches(shost, lhost, list)
        switch (m->type) {
            case ALIAS:
                rval = alias_matches(m->name, HOSTALIAS, shost, lhost);
-               if (rval != UNSPEC || hostname_matches(shost, lhost, m->name))
+               if (rval != UNSPEC || (rval = hostname_matches(shost, lhost, m->name)))
                    matched = rval;
                break;
            case ALL:
@@ -483,7 +483,7 @@ addr_matches(n)
 }
 
 /*
- * Returns 0 if the hostname matches the pattern and non-zero otherwise.
+ * Returns TRUE if the hostname matches the pattern, else FALSE
  */
 int
 hostname_matches(shost, lhost, pattern)
@@ -493,14 +493,14 @@ hostname_matches(shost, lhost, pattern)
 {
     if (has_meta(pattern)) {
        if (strchr(pattern, '.'))
-           return(fnmatch(pattern, lhost, FNM_CASEFOLD));
+           return(!fnmatch(pattern, lhost, FNM_CASEFOLD));
        else
-           return(fnmatch(pattern, shost, FNM_CASEFOLD));
+           return(!fnmatch(pattern, shost, FNM_CASEFOLD));
     } else {
        if (strchr(pattern, '.'))
-           return(strcasecmp(lhost, pattern));
+           return(!strcasecmp(lhost, pattern));
        else
-           return(strcasecmp(shost, pattern));
+           return(!strcasecmp(shost, pattern));
     }
 }