userdb-checkpassword.c revision 51821162b1df9a8a9398b8b64ceca410b9cc3092
/* Copyright (c) 2004-2010 Dovecot authors, see the included COPYING file */
#include "auth-common.h"
#include "execv-const.h"
#include "userdb.h"
#ifdef USERDB_CHECKPASSWORD
#include "db-checkpassword.h"
struct checkpassword_userdb_module {
struct userdb_module module;
const char *checkpassword_path, *checkpassword_reply_path;
struct hash_table *clients;
};
enum userdb_result result)
{
struct checkpassword_userdb_module *module =
(struct checkpassword_userdb_module *)_module;
if (result == USERDB_RESULT_OK) {
"userdb-checkpassword",
"LF characters in checkpassword reply");
} else {
NULL);
}
}
}
static void
{
return;
switch (request->exit_status) {
case 3:
/* User does not exist. */
"User unknown");
break;
case 2:
/* This is intentionally not 0. checkpassword-reply exits with
2 on success when AUTHORIZED is set. */
break;
}
/* missing input - fall through */
default:
/* whatever error... */
"Child %s exited with status %d",
break;
}
}
struct checkpassword_userdb_module *module)
{
struct chkpw_auth_request *request =
break;
break;
case SIGCHLD_RESULT_OK:
break;
}
}
static void ATTR_NORETURN
struct checkpassword_userdb_module *module,
{
"dup2() failed: %m");
} else {
/* We want to retrieve user data and don't do
authorization, so we need to signalize the
checkpassword program that the password shall be
ignored by setting AUTHORIZED. This needs a
special checkpassword program which knows how to
handle this. */
env_put("AUTHORIZED=1");
"execute: %s", cmd);
/* very simple argument splitting. */
}
exit(2);
}
static void
{
struct checkpassword_userdb_module *module =
(struct checkpassword_userdb_module *)_module;
struct chkpw_auth_request *chkpw_auth_request;
fd_in[0] = -1;
"pipe() failed: %m");
if (fd_in[0] != -1) {
}
return;
}
if (pid == -1) {
"fork() failed: %m");
return;
}
if (pid == 0) {
/* not reached */
}
"close(fd_in[1]) failed: %m");
}
"close(fd_out[0]) failed: %m");
}
if (checkpassword_userdb_children != NULL)
else {
}
}
static struct userdb_module *
{
struct checkpassword_userdb_module *module;
PKG_LIBEXECDIR"/checkpassword-reply";
}
{
struct checkpassword_userdb_module *module =
(struct checkpassword_userdb_module *)_module;
struct hash_iterate_context *iter;
}
if (checkpassword_userdb_children != NULL)
}
struct userdb_module_interface userdb_checkpassword = {
"checkpassword",
NULL,
NULL,
NULL,
};
#else
struct userdb_module_interface userdb_checkpassword = {
.name = "checkpassword"
};
#endif