Blame SOURCES/memcached-sasl-config.patch

a2abc3
commit 6207330c2705fdb5f02de13b99a0d994f7c4f14a
a2abc3
Author: Zheng Gu <zhenggu@cisco.com>
a2abc3
Date:   Fri Nov 22 22:34:16 2019 +0800
a2abc3
a2abc3
    fix bug where sasl will load config the wrong path
a2abc3
    
a2abc3
    /etc/sasl2/memcached.conf/memcached.conf instead of
a2abc3
    /etc/sasl2/memcached.conf
a2abc3
a2abc3
diff --git a/sasl_defs.c b/sasl_defs.c
a2abc3
index c60d1bf..370f947 100644
a2abc3
--- a/sasl_defs.c
a2abc3
+++ b/sasl_defs.c
a2abc3
@@ -16,6 +16,23 @@ const char * const locations[] = {
a2abc3
     "/etc/sasl2/memcached.conf",
a2abc3
     NULL
a2abc3
 };
a2abc3
+
a2abc3
+/* If the element of locations is file, locations_dir_path stores the
a2abc3
+ * directory path of these elements */
a2abc3
+const char *const locations_dir_path[] = {
a2abc3
+    "/etc/sasl",
a2abc3
+    "/etc/sasl2",
a2abc3
+    NULL
a2abc3
+};
a2abc3
+
a2abc3
+/* If the element of locations is directory, locations_file_path stores
a2abc3
+ * the actual configue file which used by sasl, when GETCONFPATH is
a2abc3
+ * enabled */
a2abc3
+const char *const locations_file_path[] = {
a2abc3
+    "/etc/sasl/memcached.conf/memcached.conf",
a2abc3
+    "/etc/sasl2/memcached.conf/memcached.conf",
a2abc3
+    NULL
a2abc3
+};
a2abc3
 #endif
a2abc3
 
a2abc3
 #ifndef HAVE_SASL_CALLBACK_FT
a2abc3
@@ -88,12 +105,24 @@ static int sasl_getconf(void *context, const char **path)
a2abc3
     *path = getenv("SASL_CONF_PATH");
a2abc3
 
a2abc3
     if (*path == NULL) {
a2abc3
+#if defined(HAVE_SASL_CB_GETCONF)
a2abc3
         for (int i = 0; locations[i] != NULL; ++i) {
a2abc3
             if (access(locations[i], F_OK) == 0) {
a2abc3
                 *path = locations[i];
a2abc3
                 break;
a2abc3
             }
a2abc3
         }
a2abc3
+#elif defined(HAVE_SASL_CB_GETCONFPATH)
a2abc3
+        for (int i = 0; locations[i] != NULL; ++i) {
a2abc3
+            if (access(locations_file_path[i], F_OK) == 0) {
a2abc3
+                *path = locations[i];
a2abc3
+                break;
a2abc3
+            } else if (access(locations[i], F_OK) == 0) {
a2abc3
+                *path = locations_dir_path[i];
a2abc3
+                break;
a2abc3
+            }
a2abc3
+        }
a2abc3
+#endif
a2abc3
     }
a2abc3
 
a2abc3
     if (settings.verbose) {