--- passdb-checkpassword.c 2006-08-17 21:47:56.000000000 +0200 +++ ../../../asd/src/auth/passdb-checkpassword.c 2006-09-28 01:31:54.000000000 +0200 @@ -375,17 +375,47 @@ hash_insert(module->clients, POINTER_CAST(pid), chkpw_auth_request); } +static int +checkpassword_parse_args(struct auth_passdb *auth_passdb, struct checkpassword_passdb_module *mod, const char *args) { + const char *start; + size_t i = 1; + + if (args[0] != '/' || args[0] == ',') return -1; /* bad format */ + + /* first token always expected */ + start = args; + while (args[i] != '\0' && (args[i] != ',' || args[i-1] == '\\')) i++; + mod->checkpassword_path = p_strdup_until(auth_passdb->auth->pool, start, start+i); + if (args[i] == '\0') { + mod->checkpassword_reply_path = PKG_LIBEXECDIR"/checkpassword-reply"; + return 0; + } + + /* second token */ + i++; + start = args + i; + while (args[i] != '\0' && (args[i] != ',' || args[i-1] == '\\')) i++; + if (args[i] != '\0') return -1; /* more than 2 tokens given */ + mod->checkpassword_reply_path = p_strdup_until(auth_passdb->auth->pool, start, start+i); + + return 0; +} + static struct passdb_module * checkpassword_preinit(struct auth_passdb *auth_passdb, const char *args) { struct checkpassword_passdb_module *module; + int ret; module = p_new(auth_passdb->auth->pool, struct checkpassword_passdb_module, 1); - module->checkpassword_path = p_strdup(auth_passdb->auth->pool, args); - module->checkpassword_reply_path = - PKG_LIBEXECDIR"/checkpassword-reply"; - + ret = checkpassword_parse_args(auth_passdb, module, args); + if (ret != 0) { + i_error("Invalid format for args config opt. Fallback to defaults -- %d", ret); + module->checkpassword_path = "/usr/local/bin/checkpassword"; + module->checkpassword_reply_path = PKG_LIBEXECDIR"/checkpassword-reply"; + } + module->clients = hash_create(default_pool, default_pool, 0, NULL, NULL);