Skip to content

Commit

Permalink
auth: Fix password and scheme handling in Lua db
Browse files Browse the repository at this point in the history
This was only partially fixed in c86575a
  • Loading branch information
cmouse authored and sirainen committed Dec 22, 2017
1 parent c0e0c97 commit 7b1c748
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/auth/db-lua.c
Expand Up @@ -453,8 +453,7 @@ static void auth_lua_export_table(struct dlua_script *script, struct auth_reques
value = "";
}

if (password_r != NULL && strcmp(key, "password") == 0 &&
!req->userdb_lookup) {
if (password_r != NULL && strcmp(key, "password") == 0) {
*scheme_r = password_get_scheme(&value);
*password_r = value;
} else if (req->userdb_lookup) {
Expand Down Expand Up @@ -510,7 +509,8 @@ auth_lua_call_lookup_finish(struct dlua_script *script, struct auth_request *req
const char **error_r)
{
if (lua_istable(script->L, -1)) {
return auth_lua_export_passdb_table(script, req, NULL, NULL, error_r);
return auth_lua_export_passdb_table(script, req, scheme_r,
password_r, error_r);
}

enum passdb_result ret = lua_tointeger(script->L, -2);
Expand Down
2 changes: 2 additions & 0 deletions src/auth/passdb-lua.c
Expand Up @@ -89,6 +89,8 @@ passdb_lua_verify_plain(struct auth_request *request, const char *password,
} else {
result = passdb_lua_lookup(request, &lua_scheme, &lua_password);
if (result == PASSDB_RESULT_OK) {
if (lua_scheme == NULL)
lua_scheme = "PLAIN";
if ((auth_request_password_verify(request, password, lua_password,
lua_scheme, AUTH_SUBSYS_DB)) <=0) {
result = PASSDB_RESULT_PASSWORD_MISMATCH;
Expand Down

0 comments on commit 7b1c748

Please sign in to comment.