X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8e79ce1919d9cf54f101a812e0fd70a33286b9f3..b539bd46de3f83ffaa486e8f58090f04beda44f7:/uip/popsbr.c diff --git a/uip/popsbr.c b/uip/popsbr.c old mode 100755 new mode 100644 index fb66a93b..2eb823cf --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -23,8 +23,6 @@ #include #include -#include -#include #define TRM "." #define TRMLEN (sizeof TRM - 1) @@ -46,6 +44,7 @@ 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; }; @@ -351,7 +350,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; + struct nmh_creds creds = { 0, 0, 0 }; int len; NMH_UNUSED (conn); @@ -359,14 +358,25 @@ 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); + 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; } @@ -437,9 +447,6 @@ pop_init (char *host, char *port, char *user, char *pass, char *proxy, 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);