]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
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 33bfc825f0b0d8a2aa0fc775e38aa698c0669712..bcec672a657ef355c15d86f258e63c3190f8baf4 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 3dd42f70bf67b71f0619b1a00132c651760a4603..073b52de24d67d06456e52e38c7185a5cf25b63d 100644 (file)
@@ -619,6 +619,7 @@ AC_CHECK_HEADERS( \
        prot.h \
        pwd.h \
        grp.h \
+        fnmatch.h \
        sia.h \
        siad.h
 )
index fba5e9d438501ad8177070a435768b2a4bb488da..df054e95f683dc8744035461e176028aee85b7be 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);
                }