git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] imap-send: add wrapper to get server credentials if needed

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Aug 7, 2017, 16:30 UTC
Message-ID
<CAN0heSoA_Xm+14V49hjJBMT7PS_ge0wyhmuvKiw-MHD99rApYQ@mail.gmail.com>
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:

Show 61 quoted lines
> 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?

Previous: Nicolas Morey-ChaisemartinNext: Nicolas Morey-Chaisemartin
Message 2 of 8 in “imap-send: add wrapper to get server credentials if needed”
  1. 1/4 imap-send: add wrapper to get server credentials if neededNicolas Morey-Chaisemartin, Aug 7, 2017
  2. Martin ÅgrenAug 7, 2017
  3. Nicolas Morey-ChaisemartinAug 7, 2017
  4. Martin ÅgrenAug 7, 2017
  5. Jeff KingAug 7, 2017
  6. Nicolas Morey-ChaisemartinAug 7, 2017
  7. Jeff KingAug 7, 2017
  8. Junio C HamanoAug 7, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.