[Pkg-wmaker-commits] [wmbiff] 09/32: minor reorganization of gcrypt-needing authentication schemes
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:00:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to tag wmbiff_0_3_8
in repository wmbiff.
commit 74d4a1ab0fae05d9a2e8a62e37f97d23056d6075
Author: bluehal <bluehal>
Date: Sat Mar 2 06:41:55 2002 +0000
minor reorganization of gcrypt-needing authentication schemes
---
wmbiff/Imap4Client.c | 11 +++----
wmbiff/Pop3Client.c | 85 ++++++++++++++++++++++++++--------------------------
2 files changed, 49 insertions(+), 47 deletions(-)
diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c
index cb7bbc6..2fcb80f 100644
--- a/wmbiff/Imap4Client.c
+++ b/wmbiff/Imap4Client.c
@@ -44,8 +44,10 @@ static struct fdmap_struct {
/* authentication callbacks */
+#ifdef WITH_GCRYPT
static int authenticate_md5(Pop3 pc, struct connection_state *scs,
const char *capabilities);
+#endif
static int authenticate_plaintext(Pop3 pc, struct connection_state *scs,
const char *capabilities);
@@ -58,7 +60,9 @@ static struct imap_authentication_method {
const char *capabilities);
} auth_methods[] = {
{
+#ifdef WITH_GCRYPT
"cram-md5", authenticate_md5}, {
+#endif
"plaintext", authenticate_plaintext}, {
NULL, NULL}
};
@@ -392,11 +396,11 @@ static int authenticate_plaintext(Pop3 pc,
return (0);
}
+#ifdef WITH_GCRYPT
static int authenticate_md5(Pop3 pc,
struct connection_state *scs,
const char *capabilities)
{
-#ifdef WITH_GCRYPT
char buf[BUF_SIZE];
char buf2[BUF_SIZE];
unsigned char *md5;
@@ -446,8 +450,5 @@ static int authenticate_md5(Pop3 pc,
"tlscomm_expect failed during cram-md5 auth: %s", buf);
IMAP_DM(pc, DEBUG_ERROR, "failed to authenticate using cram-md5.");
return 0;
-#else
- /* not compiled with gcrypt. */
- return 0;
-#endif
}
+#endif
diff --git a/wmbiff/Pop3Client.c b/wmbiff/Pop3Client.c
index b606b8d..81b38bd 100644
--- a/wmbiff/Pop3Client.c
+++ b/wmbiff/Pop3Client.c
@@ -1,4 +1,4 @@
-/* $Id: Pop3Client.c,v 1.7 2002/03/01 08:41:29 bluehal Exp $ */
+/* $Id: Pop3Client.c,v 1.8 2002/03/02 06:41:55 bluehal Exp $ */
/* Author : Scott Holden ( scotth at thezone.net )
Modified : Yong-iL Joh ( tolkien at mizi.com )
Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
@@ -19,13 +19,14 @@
#endif
#define PCU (pc->u).pop
+#define POP_DM(pc, lvl, args...) DM(pc, lvl, "pop3: " ##args)
+#ifdef WITH_GCRYPT
static FILE *authenticate_md5(Pop3 pc, FILE * fp, char *unused);
static FILE *authenticate_apop(Pop3 pc, FILE * fp, char *apop_str);
+#endif
static FILE *authenticate_plaintext(Pop3 pc, FILE * fp, char *unused);
-#define POP_DM(pc, lvl, args...) DM(pc, lvl, "pop3: " ##args)
-
static struct authentication_method {
const char *name;
/* callback returns the filehandle if successful,
@@ -33,8 +34,10 @@ static struct authentication_method {
FILE *(*auth_callback) (Pop3 pc, FILE * fp, char *apop_str);
} auth_methods[] = {
{
+#ifdef WITH_GCRYPT
"cram-md5", authenticate_md5}, {
"apop", authenticate_apop}, {
+#endif
"plaintext", authenticate_plaintext}, {
NULL, NULL}
};
@@ -52,7 +55,7 @@ FILE *pop3Login(Pop3 pc)
if ((fd = sock_connect(PCU.serverName, PCU.serverPort)) == -1) {
POP_DM(pc, DEBUG_ERROR, "Not Connected To Server '%s:%d'\n",
- PCU.serverName, PCU.serverPort);
+ PCU.serverName, PCU.serverPort);
return NULL;
}
@@ -85,8 +88,8 @@ FILE *pop3Login(Pop3 pc)
/* if authentication worked, we won't get here */
POP_DM(pc, DEBUG_ERROR,
- "All Pop3 authentication methods failed for '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "All Pop3 authentication methods failed for '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
fprintf(fp, "QUIT\r\n");
fclose(fp);
return NULL;
@@ -102,14 +105,13 @@ int pop3CheckMail(Pop3 pc)
if (f == NULL)
return -1;
- fflush(f);
fprintf(f, "STAT\r\n");
fflush(f);
fgets(buf, 256, f);
if (buf[0] != '+') {
POP_DM(pc, DEBUG_ERROR,
- "Error Receiving Stats '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "Error Receiving Stats '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
POP_DM(pc, DEBUG_INFO, "It said: %s\n", buf);
return -1;
} else {
@@ -124,7 +126,6 @@ int pop3CheckMail(Pop3 pc)
* We will leave it here for those servers which haven't
* caught up with the spec.
*/
- fflush(f);
fprintf(f, "LAST\r\n");
fflush(f);
fgets(buf, 256, f);
@@ -174,7 +175,7 @@ int pop3Create(Pop3 pc, const char *str)
if (matchedchars <= 0) {
pc->label[0] = '\0';
POP_DM(pc, DEBUG_ERROR, "Couldn't parse line %s (%d)\n", str,
- matchedchars);
+ matchedchars);
return -1;
}
@@ -189,13 +190,14 @@ int pop3Create(Pop3 pc, const char *str)
grab_authList(str + regs.end[0], PCU.authList);
- POP_DM(pc, DEBUG_INFO, "pop3: userName= '%s'\n", PCU.userName);
- POP_DM(pc, DEBUG_INFO, "pop3: password= is %d characters long\n",
- strlen(PCU.password));
- POP_DM(pc, DEBUG_INFO, "pop3: password= '%s'\n", PCU.password);
- POP_DM(pc, DEBUG_INFO, "pop3: serverName= '%s'\n", PCU.serverName);
- POP_DM(pc, DEBUG_INFO, "pop3: serverPort= '%d'\n", PCU.serverPort);
- POP_DM(pc, DEBUG_INFO, "pop3: authList= '%s'\n", PCU.authList);
+ POP_DM(pc, DEBUG_INFO, "userName= '%s'\n", PCU.userName);
+ POP_DM(pc, DEBUG_INFO, "password= is %d characters long\n",
+ strlen(PCU.password));
+ POP_DM(pc, DEBUG_INFO, "password is %d chars long\n",
+ strlen(PCU.password));
+ POP_DM(pc, DEBUG_INFO, "serverName= '%s'\n", PCU.serverName);
+ POP_DM(pc, DEBUG_INFO, "serverPort= '%d'\n", PCU.serverPort);
+ POP_DM(pc, DEBUG_INFO, "authList= '%s'\n", PCU.authList);
pc->open = pop3Login;
pc->checkMail = pop3CheckMail;
@@ -207,9 +209,11 @@ int pop3Create(Pop3 pc, const char *str)
}
-static FILE *authenticate_md5(Pop3 pc, FILE * fp, char *apop_str)
-{
#ifdef WITH_GCRYPT
+static FILE *authenticate_md5(Pop3 pc,
+ FILE * fp,
+ char *apop_str __attribute__ ((unused)))
+{
char buf[BUF_SIZE];
char buf2[BUF_SIZE];
unsigned char *md5;
@@ -255,19 +259,15 @@ static FILE *authenticate_md5(Pop3 pc, FILE * fp, char *apop_str)
return fp; /* AUTH successful */
else {
POP_DM(pc, DEBUG_ERROR,
- "CRAM-MD5 AUTH failed for user '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "CRAM-MD5 AUTH failed for user '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
fprintf(stderr, "It said %s", buf);
return NULL;
}
-#else
- return NULL;
-#endif
}
static FILE *authenticate_apop(Pop3 pc, FILE * fp, char *apop_str)
{
-#ifdef WITH_GCRYPT
GCRY_MD_HD gmh;
char buf[BUF_SIZE];
unsigned char *md5;
@@ -295,17 +295,16 @@ static FILE *authenticate_apop(Pop3 pc, FILE * fp, char *apop_str)
return fp; /* AUTH successful */
else {
POP_DM(pc, DEBUG_ERROR,
- "APOP AUTH failed for user '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "APOP AUTH failed for user '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
POP_DM(pc, DEBUG_INFO, "It said %s", buf);
return NULL;
}
-#else
- return NULL;
-#endif /* WITH_GCRYPT */
}
+#endif /* WITH_GCRYPT */
-static FILE *authenticate_plaintext(Pop3 pc, FILE * fp, char *apop_str)
+static FILE *authenticate_plaintext(Pop3 pc, FILE * fp, char *apop_str
+ __attribute__ ((unused)))
{
char buf[BUF_SIZE];
@@ -313,16 +312,17 @@ static FILE *authenticate_plaintext(Pop3 pc, FILE * fp, char *apop_str)
fflush(fp);
if (fgets(buf, BUF_SIZE, fp) == NULL) {
POP_DM(pc, DEBUG_ERROR,
- "Error reading from server authenticating '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "Error reading from server authenticating '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
return NULL;
}
if (buf[0] != '+') {
POP_DM(pc, DEBUG_ERROR,
- "Failed user name when authenticating '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "Failed user name when authenticating '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
/* deb #128863 might be easier if we printed: */
- POP_DM(pc, DEBUG_ERROR, "The server's error message was: %s\n", buf);
+ POP_DM(pc, DEBUG_ERROR, "The server's error message was: %s\n",
+ buf);
return NULL;
};
@@ -330,15 +330,16 @@ static FILE *authenticate_plaintext(Pop3 pc, FILE * fp, char *apop_str)
fflush(fp);
if (fgets(buf, BUF_SIZE, fp) == NULL) {
POP_DM(pc, DEBUG_ERROR,
- "Error reading from server (2) authenticating '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
+ "Error reading from server (2) authenticating '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
return NULL;
}
if (buf[0] != '+') {
POP_DM(pc, DEBUG_ERROR,
- "Failed password when authenticating '%s@%s:%d'\n",
- PCU.userName, PCU.serverName, PCU.serverPort);
- POP_DM(pc, DEBUG_ERROR, "The server's error message was: %s\n", buf);
+ "Failed password when authenticating '%s@%s:%d'\n",
+ PCU.userName, PCU.serverName, PCU.serverPort);
+ POP_DM(pc, DEBUG_ERROR, "The server's error message was: %s\n",
+ buf);
return NULL;
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git
More information about the Pkg-wmaker-commits
mailing list