Просмотр исходного кода

Ticket #538 - hardcoded sasl2 plugin path in ldaputil.c, saslbind.c

Bug description: The hardcoded sasl2 path is Fedora/RHEL specific.
It needs to support other architectures with other filesystem
format.

Fix description: This patch supports ARM architectures with GNU
triplet format.

https://fedorahosted.org/389/ticket/538

Reviewed by rmeggins (Thank you, Rich!)
Noriko Hosoi 12 лет назад
Родитель
Сommit
4c1dfafd91
6 измененных файлов с 63 добавлено и 17 удалено
  1. 3 0
      config.h.in
  2. 10 0
      configure
  3. 6 0
      configure.ac
  4. 40 10
      ldap/servers/slapd/ldaputil.c
  5. 1 7
      ldap/servers/slapd/saslbind.c
  6. 3 0
      ldap/servers/slapd/slapi-private.h

+ 3 - 0
config.h.in

@@ -6,6 +6,9 @@
 /* Define to 1 if the `closedir' function returns void instead of `int'. */
 #undef CLOSEDIR_VOID
 
+/* cpu type arm */
+#undef CPU_arm
+
 /* cpu type pa-risc */
 #undef CPU_hppa
 

+ 10 - 0
configure

@@ -18414,6 +18414,16 @@ $as_echo "#define CPU_x86_64 /**/" >>confdefs.h
 
 $as_echo "#define ATOMIC_64BIT_OPERATIONS 1" >>confdefs.h
 
+        ;;
+      aarch64-*-linux*)
+
+$as_echo "#define CPU_arm /**/" >>confdefs.h
+
+        ;;
+      arm*-linux*)
+
+$as_echo "#define CPU_arm /**/" >>confdefs.h
+
         ;;
     esac
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC provided 64-bit atomic bool cas function ..." >&5

+ 6 - 0
configure.ac

@@ -512,6 +512,12 @@ case $host in
         AC_DEFINE([CPU_x86_64], [], [cpu type x86_64])
         AC_DEFINE([ATOMIC_64BIT_OPERATIONS], [1], [enabling atomic counter])
         ;;
+      aarch64-*-linux*)
+        AC_DEFINE([CPU_arm], [], [cpu type arm])
+        ;;
+      arm*-linux*)
+        AC_DEFINE([CPU_arm], [], [cpu type arm])
+        ;;
     esac
     AC_MSG_CHECKING([for GCC provided 64-bit atomic bool cas function ...])
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],

+ 40 - 10
ldap/servers/slapd/ldaputil.c

@@ -707,22 +707,16 @@ slapi_ldap_init_ext(
     char *pp = NULL;
 
     if (NULL == pluginpath || (*pluginpath == '\0')) {
-	    slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_init_ext",
-			"configpluginpath == NULL\n");
-        if (!(pluginpath = getenv("SASL_PATH"))) {
-#if defined(LINUX) && defined(__LP64__)
-            pluginpath = "/usr/lib64/sasl2";
-#else
-            pluginpath = "/usr/lib/sasl2";
-#endif
-        }
+        slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_init_ext",
+                        "config_get_saslpath returns NULL\n");
+        pluginpath = ldaputil_get_saslpath();
     }
     if ('\0' == util_sasl_path[0] || /* first time */
         NULL == (pp = strchr(util_sasl_path, '=')) || /* invalid arg for putenv */
         (0 != strcmp(++pp, pluginpath)) /* sasl_path has been updated */ )
     {
         PR_snprintf(util_sasl_path, sizeof(util_sasl_path), "SASL_PATH=%s", pluginpath);
-	    slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_init_ext", "putenv(%s)\n", util_sasl_path);
+        slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_init_ext", "putenv(%s)\n", util_sasl_path);
         putenv(util_sasl_path);
     }
     slapi_ch_free_string(&configpluginpath);
@@ -990,6 +984,42 @@ done:
     return( ld );
 }
 
+char *
+ldaputil_get_saslpath()
+{
+    char *saslpath = getenv("SASL_PATH");
+    if (NULL == saslpath) {
+#if defined(LINUX) && defined(__LP64__)
+        saslpath = "/usr/lib64/sasl2";
+        if (PR_SUCCESS != PR_Access(saslpath, PR_ACCESS_EXISTS)) {
+#ifdef CPU_arm
+            /* the 64-bit ARMv8 architecture. */
+            saslpath = "/usr/lib/aarch64-linux-gnu";
+#else
+            /* Try x86_64 gnu triplet */
+            saslpath = "/usr/lib/x86_64-linux-gnu";
+#endif
+        }
+#else
+        saslpath = "/usr/lib/sasl2";
+        if (PR_SUCCESS != PR_Access(saslpath, PR_ACCESS_EXISTS)) {
+#ifdef CPU_arm
+            /* the latest 32 bit ARM architecture using the hard-float version of EABI. */
+            saslpath = "/usr/lib/arm-linux-gnueabihf";
+            if (PR_SUCCESS != PR_Access(saslpath, PR_ACCESS_EXISTS)) {
+                /* the 32 bit ARM architecture of EABI. */
+                saslpath = "/usr/lib/arm-linux-gnueabi";
+            }
+#else
+            /* Try i386 gnu triplet */
+            saslpath = "/usr/lib/i386-linux-gnu";
+#endif
+        }
+#endif
+    }
+    return saslpath;
+}
+
 /*
  * Function: slapi_ldap_init()
  * Description: just like ldap_ssl_init() but also arranges for the LDAP

+ 1 - 7
ldap/servers/slapd/saslbind.c

@@ -550,13 +550,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
      */
     char *pluginpath = config_get_saslpath();
     if ((!pluginpath) || (*pluginpath == '\0')) {
-        if (!(pluginpath = getenv("SASL_PATH"))) {
-#if defined(LINUX) && defined(__LP64__)
-            pluginpath = "/usr/lib64/sasl2";
-#else
-            pluginpath = "/usr/lib/sasl2";
-#endif
-        }
+        pluginpath = ldaputil_get_saslpath();
     }
     *path = pluginpath;
     return SASL_OK;

+ 3 - 0
ldap/servers/slapd/slapi-private.h

@@ -1276,6 +1276,9 @@ void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);
 /* add.c */
 void add_internal_modifiersname(Slapi_PBlock *pb, Slapi_Entry *e);
 
+/* ldaputil.c */
+char *ldaputil_get_saslpath();
+
 #ifdef __cplusplus
 }
 #endif