X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c4d932d08940f689b39b654a714f9ef3657690a9..167e542b:/uip/popsbr.c?ds=inline diff --git a/uip/popsbr.c b/uip/popsbr.c index c566264d..714a8da7 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -12,12 +12,17 @@ #ifdef CYRUS_SASL # include # include +# if SASL_VERSION_FULL < 0x020125 + /* Cyrus SASL 2.1.25 introduced the sasl_callback_ft prototype, + which has an explicit void parameter list, according to best + practice. So we need to cast to avoid compile warnings. + Provide this prototype for earlier versions. */ + typedef int (*sasl_callback_ft)(); +# endif /* SASL_VERSION_FULL < 0x020125 */ #endif /* CYRUS_SASL */ #include #include -#include -#include #define TRM "." #define TRMLEN (sizeof TRM - 1) @@ -39,13 +44,14 @@ static int sasl_get_user(void *, int, const char **, unsigned *); static int sasl_get_pass(sasl_conn_t *, void *, int, sasl_secret_t **); struct pass_context { char *user; + char *password; char *host; }; static sasl_callback_t callbacks[] = { - { SASL_CB_USER, sasl_get_user, NULL }, + { SASL_CB_USER, (sasl_callback_ft) sasl_get_user, NULL }, #define POP_SASL_CB_N_USER 0 - { SASL_CB_PASS, sasl_get_pass, NULL }, + { SASL_CB_PASS, (sasl_callback_ft) sasl_get_pass, NULL }, #define POP_SASL_CB_N_PASS 1 { SASL_CB_LOG, NULL, NULL }, { SASL_CB_LIST_END, NULL, NULL }, @@ -64,7 +70,7 @@ static int command(const char *, ...); static int multiline(void); #ifdef CYRUS_SASL -static int pop_auth_sasl(char *, char *, char *); +static int pop_auth_sasl(char *, char *, char *, char *); static int sasl_fgetc(FILE *); #endif /* CYRUS_SASL */ @@ -84,7 +90,7 @@ static int putline (char *, FILE *); */ int -pop_auth_sasl(char *user, char *host, char *mech) +pop_auth_sasl(char *user, char *password, char *host, char *mech) { int result, status, sasl_capability = 0; unsigned int buflen, outlen; @@ -152,6 +158,7 @@ pop_auth_sasl(char *user, char *host, char *mech) callbacks[POP_SASL_CB_N_USER].context = user; p_context.user = user; p_context.host = host; + p_context.password = password; callbacks[POP_SASL_CB_N_PASS].context = &p_context; result = sasl_client_init(callbacks); @@ -344,7 +351,7 @@ static int sasl_get_pass(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) { struct pass_context *p_context = (struct pass_context *) context; - char *pass = NULL; + char *pass = p_context->password; int len; NMH_UNUSED (conn); @@ -352,8 +359,6 @@ sasl_get_pass(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret) if (! psecret || id != SASL_CB_PASS) return SASL_BADPARAM; - ruserpass(p_context->user, &(p_context->host), &pass); - len = strlen(pass); *psecret = (sasl_secret_t *) mh_xmalloc(sizeof(sasl_secret_t) + len); @@ -503,7 +508,7 @@ pop_init (char *host, char *port, char *user, char *pass, char *proxy, if (*response == '+') { # ifdef CYRUS_SASL if (sasl) { - if (pop_auth_sasl(user, host, mech) != NOTOK) + if (pop_auth_sasl(user, pass, host, mech) != NOTOK) return OK; } else # endif /* CYRUS_SASL */