#ifdef CYRUS_SASL
# include <sasl/sasl.h>
# include <sasl/saslutil.h>
+# 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 <h/popsbr.h>
#include <h/signals.h>
-#include <signal.h>
-#include <errno.h>
#define TRM "."
#define TRMLEN (sizeof TRM - 1)
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 },
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;
+ struct nmh_creds creds = { 0, 0, 0 };
int len;
+ NMH_UNUSED (conn);
+
if (! psecret || id != SASL_CB_PASS)
return SASL_BADPARAM;
- ruserpass(p_context->user, &(p_context->host), &pass);
+ if (creds.password == NULL) {
+ /*
+ * Pass the 0 third argument to nmh_get_credentials() so
+ * that the default password isn't used. With legacy/.netrc
+ * credentials support, we'll only get here if the -user
+ * switch to send(1)/post(8) wasn't used.
+ */
+ if (nmh_get_credentials (p_context->host, p_context->user, 0, &creds)
+ != OK) {
+ return SASL_BADPARAM;
+ }
+ }
- len = strlen(pass);
+ len = strlen (creds.password);
*psecret = (sasl_secret_t *) mh_xmalloc(sizeof(sasl_secret_t) + len);
(*psecret)->len = len;
- strcpy((char *) (*psecret)->data, pass);
+ strcpy((char *) (*psecret)->data, creds.password);
return SASL_OK;
}
{
int fd1, fd2;
char buffer[BUFSIZ];
+#ifndef CYRUS_SASL
+ NMH_UNUSED (sasl);
+ NMH_UNUSED (mech);
+#endif /* ! CYRUS_SASL */
if (proxy && *proxy) {
int pid;
int inpipe[2]; /* for reading from the server */
int outpipe[2]; /* for sending to the server */
- /* first give up any root priviledges we may have for rpop */
- setuid(getuid());
-
pipe(inpipe);
pipe(outpipe);
sasl_fgetc(FILE *f)
{
static unsigned char *buffer = NULL, *ptr;
- static int size = 0;
+ static unsigned int size = 0;
static int cnt = 0;
unsigned int retbufsize = 0;
int cc, result;