From: "Martin Ågren" <martin.agren@gmail.com>
To: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/4] imap-send: add wrapper to get server credentials if needed
Date: Mon, 7 Aug 2017 18:30:48 +0200 [thread overview]
Message-ID: <CAN0heSoA_Xm+14V49hjJBMT7PS_ge0wyhmuvKiw-MHD99rApYQ@mail.gmail.com> (raw)
In-Reply-To: <9687e182-1e23-f84d-3fad-83fdf15dba4c@morey-chaisemartin.com>
On 7 August 2017 at 16:03, Nicolas Morey-Chaisemartin
<nicolas@morey-chaisemartin.com> wrote:
> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
> ---
> imap-send.c | 38 ++++++++++++++++++++++++--------------
> 1 file changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/imap-send.c b/imap-send.c
> index b2d0b849b..38b3c817e 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -926,6 +926,29 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha
> return 0;
> }
>
> +static void server_fill_credential(struct imap_server_conf *srvc)
> +{
> + struct credential cred = CREDENTIAL_INIT;
> +
> + if (srvc->user && srvc->pass)
> + return;
> +
> + cred.protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap");
> + cred.host = xstrdup(srvc->host);
> +
> + cred.username = xstrdup_or_null(srvc->user);
> + cred.password = xstrdup_or_null(srvc->pass);
> +
> + credential_fill(&cred);
> +
> + if (!srvc->user)
> + srvc->user = xstrdup(cred.username);
> + if (!srvc->pass)
> + srvc->pass = xstrdup(cred.password);
> +
> + credential_clear(&cred);
> +}
> +
> static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *folder)
> {
> struct credential cred = CREDENTIAL_INIT;
> @@ -1078,20 +1101,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
> }
> #endif
> imap_info("Logging in...\n");
> - if (!srvc->user || !srvc->pass) {
> - cred.protocol = xstrdup(srvc->use_ssl ? "imaps" : "imap");
> - cred.host = xstrdup(srvc->host);
> -
> - cred.username = xstrdup_or_null(srvc->user);
> - cred.password = xstrdup_or_null(srvc->pass);
> -
> - credential_fill(&cred);
> -
> - if (!srvc->user)
> - srvc->user = xstrdup(cred.username);
> - if (!srvc->pass)
> - srvc->pass = xstrdup(cred.password);
> - }
> + server_fill_credential(srvc);
>
> if (srvc->auth_method) {
> struct imap_cmd_cb cb;
"cred.username" is checked further down, but now it will always be NULL,
no?
next prev parent reply other threads:[~2017-08-07 16:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 14:03 [PATCH 1/4] imap-send: add wrapper to get server credentials if needed Nicolas Morey-Chaisemartin
2017-08-07 16:30 ` Martin Ågren [this message]
2017-08-07 17:04 ` Nicolas Morey-Chaisemartin
2017-08-07 17:18 ` Martin Ågren
2017-08-07 19:42 ` Jeff King
2017-08-07 19:55 ` Nicolas Morey-Chaisemartin
2017-08-07 20:07 ` Jeff King
2017-08-07 22:21 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN0heSoA_Xm+14V49hjJBMT7PS_ge0wyhmuvKiw-MHD99rApYQ@mail.gmail.com \
--to=martin.agren@gmail.com \
--cc=git@vger.kernel.org \
--cc=nicolas@morey-chaisemartin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).