From: Alan T. DeKok Date: Tue, 7 Dec 2010 13:53:57 +0000 (+0100) Subject: Use fnmatch(), if it exists. X-Git-Tag: release_2_1_11~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff94c0a767937b88205604df107d6d4df6b7f4a4;p=thirdparty%2Ffreeradius-server.git Use fnmatch(), if it exists. The detail file reader reads a glob(), so we should check the writer filename against that glob(), rather than using a string comparison Closes bug #128 --- diff --git a/configure b/configure index 33bfc825f0b..bcec672a657 100755 --- a/configure +++ b/configure @@ -22760,6 +22760,7 @@ for ac_header in \ prot.h \ pwd.h \ grp.h \ + fnmatch.h \ sia.h \ siad.h diff --git a/configure.in b/configure.in index 3dd42f70bf6..073b52de24d 100644 --- a/configure.in +++ b/configure.in @@ -619,6 +619,7 @@ AC_CHECK_HEADERS( \ prot.h \ pwd.h \ grp.h \ + fnmatch.h \ sia.h \ siad.h ) diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index fba5e9d4385..df054e95f68 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -32,6 +32,10 @@ RCSID("$Id$") #include #include +#ifdef HAVE_FNMATCH_H +#include +#endif + #define DIRLEN 8192 struct detail_instance { @@ -231,7 +235,14 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet, * so we've got to create a new one. */ if ((inst->last_made_directory == NULL) || - (strcmp(inst->last_made_directory, buffer) != 0)) { +#ifndef HAVE_FNMATCH_H + (strcmp(inst->last_made_directory, buffer) != 0) +#else + (fnmatch(((listen_detail_t *)request->listener->data)->filename, + ((struct detail_instance *)instance)->detailfile, + FNM_FILE_NAME | FNM_PERIOD ) == 0) +#endif + ) { free((char *) inst->last_made_directory); inst->last_made_directory = strdup(buffer); }