Commit dfbcd782 dfbcd78217cb4fc60b89594ecaecdcebb3679cc3 by Sergey Poznyakoff

Reflect changes to mu_auth_fp

1 parent 3e97e6d7
......@@ -29,7 +29,7 @@
int
mysql_auth_sql_by_name (void *return_data, void *key,
mysql_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -104,7 +104,7 @@ mysql_auth_sql_by_name (void *return_data, void *key,
}
if (mailbox_name)
rc = mu_auth_data_alloc ((struct mu_auth_data **) return_data,
rc = mu_auth_data_alloc (return_data,
row[0],
row[1],
atoi (row[2]),
......@@ -125,7 +125,7 @@ mysql_auth_sql_by_name (void *return_data, void *key,
}
int
mysql_auth_sql_by_uid (void *return_data, void *key,
mysql_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -202,7 +202,7 @@ mysql_auth_sql_by_uid (void *return_data, void *key,
}
if (mailbox_name)
rc = mu_auth_data_alloc ((struct mu_auth_data **) return_data,
rc = mu_auth_data_alloc (return_data,
row[0],
row[1],
atoi (row[2]),
......@@ -223,7 +223,8 @@ mysql_auth_sql_by_uid (void *return_data, void *key,
}
int
mysql_sql_authenticate (void *return_data ARG_UNUSED, void *key,
mysql_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
void *func_data ARG_UNUSED, void *call_data)
{
struct mu_auth_data *auth_data = key;
......
......@@ -101,9 +101,9 @@ mu_pam_conv (int num_msg, const struct pam_message **msg,
static struct pam_conv PAM_conversation = { &mu_pam_conv, NULL };
int
mu_authenticate_pam (void *ignored_return_data,
mu_authenticate_pam (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
void *ignored_func_data,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
......@@ -163,10 +163,10 @@ struct argp mu_pam_argp = {
#else
int
mu_authenticate_pam (void *ignored_return_data,
void *key,
void *ignored_func_data,
void *call_data)
mu_authenticate_pam (struct mu_auth_data **return_data ARG_UNUSED,
void *key ARG_UNUSED,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
errno = ENOSYS;
return 1;
......
......@@ -22,6 +22,7 @@
#ifdef HAVE_PGSQL
#include <sql.h>
#include <libpq-fe.h>
#include <ctype.h>
static PGconn *
pg_connect ()
......@@ -81,12 +82,14 @@ pg_auth_common (PGresult *res, char *query_str, struct mu_auth_data **auth)
ntuples = PQntuples (res);
nfields = PQnfields (res);
if (ntuples > 1 && nfields)
if ((ntuples > 1 && nfields) || ntuples == 0)
{
mu_error (ngettext("query returned %d tuple: %s",
"query returned %d tuples: %s",
ntuples),
ntuples, query_str);
if (ntuples == 0)
return 1;
}
if (nfields < 6)
......@@ -105,7 +108,7 @@ pg_auth_common (PGresult *res, char *query_str, struct mu_auth_data **auth)
homedir = chop (PQgetvalue (res, 0, 4));
shell = chop (PQgetvalue (res, 0, 5));
if (ntuples == 7)
if (nfields == 7)
{
mailbox_name = strdup (chop (PQgetvalue (res, 0, 6)));
}
......@@ -133,7 +136,7 @@ pg_auth_common (PGresult *res, char *query_str, struct mu_auth_data **auth)
}
int
pg_auth_sql_by_name (void *return_data, void *key,
pg_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -171,8 +174,7 @@ pg_auth_sql_by_name (void *return_data, void *key,
}
else
{
rc = pg_auth_common (res, query_str,
(struct mu_auth_data **)return_data);
rc = pg_auth_common (res, query_str, return_data);
PQclear(res);
}
......@@ -183,7 +185,7 @@ pg_auth_sql_by_name (void *return_data, void *key,
}
int
pg_auth_sql_by_uid (void *return_data, void *key,
pg_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
......@@ -222,8 +224,7 @@ pg_auth_sql_by_uid (void *return_data, void *key,
}
else
{
rc = pg_auth_common (res, query_str,
(struct mu_auth_data **)return_data);
rc = pg_auth_common (res, query_str, return_data);
PQclear(res);
}
......@@ -234,7 +235,7 @@ pg_auth_sql_by_uid (void *return_data, void *key,
}
int
pg_sql_authenticate (void *return_data ARG_UNUSED, void *key,
pg_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED, void *key,
void *func_data ARG_UNUSED, void *call_data)
{
PGconn *conn;
......@@ -278,12 +279,14 @@ pg_sql_authenticate (void *return_data ARG_UNUSED, void *key,
char *p;
int ntuples = PQntuples (res);
int nfields = PQnfields (res);
if (ntuples > 1 && nfields)
if ((ntuples > 1 && nfields) || ntuples == 0)
{
mu_error (ngettext("query returned %d tuple: %s",
"query returned %d tuples: %s",
ntuples),
ntuples, query_str);
if (ntuples == 0)
return 1;
}
if (nfields > 1)
......
......@@ -214,11 +214,11 @@ struct argp mu_sql_argp = {
# ifdef HAVE_MYSQL
int mysql_auth_sql_by_name __P((void *return_data, void *key,
int mysql_auth_sql_by_name __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
int mysql_auth_sql_by_uid __P((void *return_data, void *key,
int mysql_auth_sql_by_uid __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
int mysql_sql_authenticate __P((void *return_data, void *key,
int mysql_sql_authenticate __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
# define mu_sql_authenticate mysql_sql_authenticate
......@@ -228,11 +228,11 @@ int mysql_sql_authenticate __P((void *return_data, void *key,
# endif
# ifdef HAVE_PGSQL
int pg_auth_sql_by_name __P((void *return_data, void *key,
int pg_auth_sql_by_name __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
int pg_auth_sql_by_uid __P((void *return_data, void *key,
int pg_auth_sql_by_uid __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
int pg_sql_authenticate __P((void *return_data, void *key,
int pg_sql_authenticate __P((struct mu_auth_data **return_data, void *key,
void *func_data, void *call_data));
# define mu_sql_authenticate pg_sql_authenticate
......
......@@ -345,7 +345,8 @@ _tls_open (stream_t stream)
gnutls_certificate_set_dh_params (x509_cred, dh_params);
s->session = initialize_tls_session ();
gnutls_transport_set_ptr2 (s->session, s->ifd, s->ofd);
gnutls_transport_set_ptr2 (s->session, (gnutls_transport_ptr) s->ifd,
(gnutls_transport_ptr) s->ofd);
rc = gnutls_handshake (s->session);
if (rc < 0)
......
......@@ -133,7 +133,7 @@ getpwnam_ip_virtual (const char *u)
/* Virtual domains */
static int
mu_auth_virt_domain_by_name (void *return_data, void *key,
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, void *key,
void *unused_func_data, void *unused_call_data)
{
int rc;
......@@ -157,7 +157,7 @@ mu_auth_virt_domain_by_name (void *return_data, void *key,
mailbox_name = calloc (strlen (pw->pw_dir) + strlen ("/INBOX") + 1, 1);
sprintf (mailbox_name, "%s/INBOX", pw->pw_dir);
rc = mu_auth_data_alloc ((struct mu_auth_data **) return_data,
rc = mu_auth_data_alloc (return_data,
pw->pw_name,
pw->pw_passwd,
pw->pw_uid,
......@@ -201,8 +201,10 @@ struct argp mu_virt_argp = {
#else
static int
mu_auth_virt_domain_by_name (void *return_data, void *key,
void *unused_func_data, void *unused_call_data)
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data ARG_UNUSED,
void *key ARG_UNUSED,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
errno = ENOSYS;
return 1;
......
......@@ -44,7 +44,7 @@
/* System database */
static int
mu_auth_system (void *return_data, struct passwd *pw)
mu_auth_system (struct mu_auth_data **return_data, struct passwd *pw)
{
char *mailbox_name;
int rc;
......@@ -59,7 +59,7 @@ mu_auth_system (void *return_data, struct passwd *pw)
sprintf (mailbox_name, "%s%s", mu_path_maildir, pw->pw_name);
rc = mu_auth_data_alloc ((struct mu_auth_data **) return_data,
rc = mu_auth_data_alloc (return_data,
pw->pw_name,
pw->pw_passwd,
pw->pw_uid,
......@@ -74,8 +74,9 @@ mu_auth_system (void *return_data, struct passwd *pw)
}
int
mu_auth_system_by_name (void *return_data, void *key,
void *unused_func_data, void *unused_call_data)
mu_auth_system_by_name (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
if (!key)
{
......@@ -86,8 +87,9 @@ mu_auth_system_by_name (void *return_data, void *key,
}
static int
mu_auth_system_by_uid (void *return_data, void *key,
void *unused_func_data, void *unused_call_data)
mu_auth_system_by_uid (struct mu_auth_data **return_data, void *key,
void *func_data ARG_UNUSED,
void *call_data ARG_UNUSED)
{
if (!key)
{
......@@ -98,9 +100,9 @@ mu_auth_system_by_uid (void *return_data, void *key,
}
static int
mu_authenticate_generic (void *ignored_return_data,
mu_authenticate_generic (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
void *ignored_func_data,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
......@@ -113,9 +115,9 @@ mu_authenticate_generic (void *ignored_return_data,
/* Called only if generic fails */
static int
mu_authenticate_system (void *ignored_return_data,
mu_authenticate_system (struct mu_auth_data **return_data ARG_UNUSED,
void *key,
void *ignored_func_data,
void *func_data ARG_UNUSED,
void *call_data)
{
struct mu_auth_data *auth_data = key;
......