Use fnmatch(), if it exists.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 7 Dec 2010 13:53:57 +0000 (14:53 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 7 Dec 2010 13:53:57 +0000 (14:53 +0100)
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

configure
configure.in
src/modules/rlm_detail/rlm_detail.c

index 33bfc82..bcec672 100755 (executable)
--- a/configure
+++ b/configure
@@ -22760,6 +22760,7 @@ for ac_header in \
        prot.h \
        pwd.h \
        grp.h \
+        fnmatch.h \
        sia.h \
        siad.h
 
index 3dd42f7..073b52d 100644 (file)
@@ -619,6 +619,7 @@ AC_CHECK_HEADERS( \
        prot.h \
        pwd.h \
        grp.h \
+        fnmatch.h \
        sia.h \
        siad.h
 )
index fba5e9d..df054e9 100644 (file)
@@ -32,6 +32,10 @@ RCSID("$Id$")
 #include       <ctype.h>
 #include       <fcntl.h>
 
+#ifdef HAVE_FNMATCH_H
+#include       <fnmatch.h>
+#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);
                }