=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/testsudoers.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/sudo/Attic/testsudoers.c 2000/01/24 04:22:53 1.3 --- src/usr.bin/sudo/Attic/testsudoers.c 2000/03/27 03:44:39 1.4 *************** *** 77,83 **** #endif /* HAVE_FNMATCH */ #ifndef lint ! static const char rcsid[] = "$Sudo: testsudoers.c,v 1.68 2000/01/17 23:46:26 millert Exp $"; #endif /* lint */ /* --- 77,83 ---- #endif /* HAVE_FNMATCH */ #ifndef lint ! static const char rcsid[] = "$Sudo: testsudoers.c,v 1.71 2000/03/23 04:38:22 millert Exp $"; #endif /* lint */ /* *************** *** 106,112 **** has_meta(s) char *s; { ! register char *t; for (t = s; *t; t++) { if (*t == '\\' || *t == '?' || *t == '*' || *t == '[' || *t == ']') --- 106,112 ---- has_meta(s) char *s; { ! char *t; for (t = s; *t; t++) { if (*t == '\\' || *t == '?' || *t == '*' || *t == '[' || *t == ']') *************** *** 208,213 **** --- 208,232 ---- } return(FALSE); + } + + int + hostname_matches(shost, lhost, pattern) + char *shost; + char *lhost; + char *pattern; + { + if (has_meta(pattern)) { + if (strchr(pattern, '.')) + return(fnmatch(pattern, lhost, FNM_CASEFOLD)); + else + return(fnmatch(pattern, shost, FNM_CASEFOLD)); + } else { + if (strchr(pattern, '.')) + return(strcasecmp(lhost, pattern)); + else + return(strcasecmp(shost, pattern)); + } } int