2
* This file is part of libESMTP, a library for submission of RFC 2822
3
* formatted electronic mail messages using the SMTP protocol described
6
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
#include "auth-client.h"
33
#include "auth-plugin.h"
35
#define NELT(x) (sizeof x / sizeof x[0])
37
static int plain_init (void *pctx);
38
static void plain_destroy (void *ctx);
39
static const char *plain_response (void *ctx, const char *challenge, int *len,
40
auth_interact_t interact, void *arg);
42
const struct auth_client_plugin sasl_client =
44
/* Plugin information */
46
"PLAIN mechanism (RFC 2595 section 6)",
59
static const struct auth_client_request client_request[] =
61
{ "user", AUTH_CLEARTEXT | AUTH_USER, "User Name", 255, },
62
{ "passphrase", AUTH_CLEARTEXT | AUTH_PASS, "Pass Phrase", 255, },
68
char buf[2 * 255 + 3];
72
plain_init (void *pctx)
74
struct plain_context *plain;
76
plain = malloc (sizeof (struct plain_context));
77
memset (plain, 0, sizeof (struct plain_context));
79
*(void **) pctx = plain;
84
plain_destroy (void *ctx)
86
struct plain_context *plain = ctx;
88
memset (plain->buf, '\0', sizeof plain->buf);
93
plain_response (void *ctx, const char *challenge __attribute__ ((unused)),
94
int *len, auth_interact_t interact, void *arg)
96
struct plain_context *plain = ctx;
97
char *result[NELT (client_request)];
102
if (!(*interact) (client_request, result, NELT (client_request), arg))
104
strcpy (plain->buf + 1, result[0]);
105
strcpy (plain->buf + strlen (result[0]) + 2, result[1]);
106
*len = strlen (result[0]) + strlen (result[1]) + 2;