changeset 21866:f23b6f713a50

var-expand-crypt: Add error handling for initialization
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 27 Mar 2017 09:39:03 +0300
parents c30cfcc6a195
children a5de42736743
files src/plugins/var-expand-crypt/var-expand-crypt-plugin.c
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c	Mon Mar 27 09:34:50 2017 +0300
+++ b/src/plugins/var-expand-crypt/var-expand-crypt-plugin.c	Mon Mar 27 09:39:03 2017 +0300
@@ -28,7 +28,7 @@
 	bool enc_result_only:1;
 };
 
-static void var_expand_crypt_initialize(void);
+static bool var_expand_crypt_initialize(const char **error_r);
 
 void var_expand_crypt_init(struct module *module);
 void var_expand_crypt_deinit(void);
@@ -144,8 +144,8 @@
 		   const char *key, const char *field,
 		   const char **result_r, const char **error_r)
 {
-	if (!has_been_init)
-		var_expand_crypt_initialize();
+	if (!has_been_init && !var_expand_crypt_initialize(error_r))
+		return -1;
 
 	const char *p = strchr(key, ';');
 	const char *const *args = NULL;
@@ -225,8 +225,8 @@
 		   const char *key, const char *field,
 		   const char **result_r, const char **error_r)
 {
-	if (!has_been_init)
-		var_expand_crypt_initialize();
+	if (!has_been_init && !var_expand_crypt_initialize(error_r))
+		return -1;
 
 	const char *p = strchr(key, ';');
 	const char *const *args = NULL;
@@ -313,9 +313,9 @@
 	{ NULL, NULL, }
 };
 
-static void var_expand_crypt_initialize(void)
+static bool var_expand_crypt_initialize(const char **error_r)
 {
-	dcrypt_initialize(NULL, NULL, NULL);
+	return dcrypt_initialize(NULL, NULL, error_r);
 }
 
 void var_expand_crypt_init(struct module *module ATTR_UNUSED)