]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9656 Check we got configuration from policy
authorOndřej Kuzník <ondra@mistotebe.net>
Tue, 31 Aug 2021 14:35:33 +0000 (15:35 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Sat, 4 Sep 2021 21:19:39 +0000 (21:19 +0000)
contrib/slapd-modules/ppm/ppm.c

index 7c6a4068177b282cd815094fcca1e02c08d16ff1..6d6013214a40efd61ef08aaa1b355386ac8f3ff5 100644 (file)
@@ -433,19 +433,7 @@ check_password(char *pPasswd, struct berval *ppErrmsg, Entry *e, void *pArg)
 {
 
     Entry *pEntry = e;
-    ppm_log(LOG_NOTICE, "ppm: entry %s", pEntry->e_nname.bv_val);
-
     struct berval *pwdCheckModuleArg = pArg;
-    /* Determine if config file is to be read (DEPRECATED) */
-    #ifdef PPM_READ_FILE
-      ppm_log(LOG_NOTICE, "ppm: Not reading pwdCheckModuleArg attribute");
-      ppm_log(LOG_NOTICE, "ppm: instead, read configuration file (deprecated)");
-    #else
-      ppm_log(LOG_NOTICE, "ppm: Reading pwdCheckModuleArg attribute");
-      ppm_log(LOG_NOTICE, "ppm: RAW configuration: %s",
-                          (*(struct berval*)pwdCheckModuleArg).bv_val);
-    #endif
-
     char *origmsg = ppErrmsg->bv_val;
     char *szErrStr = origmsg;
     int mem_len = ppErrmsg->bv_len;
@@ -466,15 +454,32 @@ check_password(char *pPasswd, struct berval *ppErrmsg, Entry *e, void *pArg)
     int nbInClass[CONF_MAX_SIZE];
     int i,j;
 
-    /* Determine config file (DEPRECATED) */
-    #ifdef PPM_READ_FILE
-      char ppm_config_file[FILENAME_MAX_LEN];
-      strcpy_safe(ppm_config_file, getenv("PPM_CONFIG_FILE"), FILENAME_MAX_LEN);
-      if (ppm_config_file[0] == '\0') {
+    ppm_log(LOG_NOTICE, "ppm: entry %s", pEntry->e_nname.bv_val);
+
+#ifdef PPM_READ_FILE
+    /* Determine if config file is to be read (DEPRECATED) */
+    char ppm_config_file[FILENAME_MAX_LEN];
+
+    ppm_log(LOG_NOTICE, "ppm: Not reading pwdCheckModuleArg attribute");
+    ppm_log(LOG_NOTICE, "ppm: instead, read configuration file (deprecated)");
+
+    strcpy_safe(ppm_config_file, getenv("PPM_CONFIG_FILE"), FILENAME_MAX_LEN);
+    if (ppm_config_file[0] == '\0') {
         strcpy_safe(ppm_config_file, CONFIG_FILE, FILENAME_MAX_LEN);
-      }
-      ppm_log(LOG_NOTICE, "ppm: reading config file from %s", ppm_config_file);
-    #endif
+    }
+    ppm_log(LOG_NOTICE, "ppm: reading config file from %s", ppm_config_file);
+#else
+    if ( !pwdCheckModuleArg || !pwdCheckModuleArg->bv_val ) {
+        ppm_log(LOG_ERR, "ppm: No config provided in pwdCheckModuleArg");
+        mem_len = realloc_error_message(origmsg, &szErrStr, mem_len,
+                        strlen(GENERIC_ERROR));
+        sprintf(szErrStr, GENERIC_ERROR);
+        goto fail;
+    }
+
+    ppm_log(LOG_NOTICE, "ppm: Reading pwdCheckModuleArg attribute");
+    ppm_log(LOG_NOTICE, "ppm: RAW configuration: %s", pwdCheckModuleArg->bv_val);
+#endif
 
     for (i = 0; i < CONF_MAX_SIZE; i++)
         nbInClass[i] = 0;