HCoop
/
hcoop
/
debian
/
courier-authlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Import Upstream version 0.69.0
[hcoop/debian/courier-authlib.git]
/
cramlib.c
diff --git
a/cramlib.c
b/cramlib.c
index
72eb426
..
a068479
100644
(file)
--- a/
cramlib.c
+++ b/
cramlib.c
@@
-1,5
+1,5
@@
/*
/*
-** Copyright 1998 -
1999
Double Precision, Inc. See COPYING for
+** Copyright 1998 -
2008
Double Precision, Inc. See COPYING for
** distribution information.
*/
** distribution information.
*/
@@
-11,13
+11,9
@@
#include <string.h>
#include <errno.h>
#include "courierauthsasl.h"
#include <string.h>
#include <errno.h>
#include "courierauthsasl.h"
-#include "c
ramlib
.h"
+#include "c
ourierauth
.h"
#include "courierauthdebug.h"
#include "courierauthdebug.h"
-
-#if HAVE_HMACLIB
-
#include "libhmac/hmac.h"
#include "libhmac/hmac.h"
-#include "cramlib.h"
static int nybble(int c)
{
static int nybble(int c)
{
@@
-82,8
+78,8
@@
int rc;
return rc;
}
return rc;
}
-
int
auth_get_cram(const char *authtype, char *authdata,
-
struct cram_callback_info *craminfo
)
+
static int do_
auth_get_cram(const char *authtype, char *authdata,
+
struct cram_callback_info *craminfo, int logerr
)
{
int i;
int challenge_l;
{
int i;
int challenge_l;
@@
-93,7
+89,10
@@
int response_l;
(craminfo->challenge=strtok(authdata, "\n")) == 0 ||
(craminfo->response=strtok(0, "\n")) == 0)
{
(craminfo->challenge=strtok(authdata, "\n")) == 0 ||
(craminfo->response=strtok(0, "\n")) == 0)
{
- DPRINTF("cram: only supports authtype=cram-*");
+ if (logerr)
+ {
+ DPRINTF("Unsupported authentication type: %s", authtype);
+ }
errno=EPERM;
return (-1);
}
errno=EPERM;
return (-1);
}
@@
-102,15
+101,21
@@
int response_l;
if (strcmp(hmac_list[i]->hh_name, authtype+5) == 0)
break;
if (strcmp(hmac_list[i]->hh_name, authtype+5) == 0)
break;
- DPRINTF("cram: challenge=%s, response=%s", craminfo->challenge,
- craminfo->response);
+ if (logerr)
+ {
+ DPRINTF("cram: challenge=%s, response=%s", craminfo->challenge,
+ craminfo->response);
+ }
if (hmac_list[i] == 0
|| (challenge_l=authsasl_frombase64(craminfo->challenge)) < 0
|| (response_l=authsasl_frombase64(craminfo->response)) < 0)
{
if (hmac_list[i] == 0
|| (challenge_l=authsasl_frombase64(craminfo->challenge)) < 0
|| (response_l=authsasl_frombase64(craminfo->response)) < 0)
{
- DPRINTF("cram: invalid base64 encoding, or unknown method: %s",
- authtype);
+ if (logerr)
+ {
+ DPRINTF("cram: invalid base64 encoding, or unknown method: %s",
+ authtype);
+ }
errno=EACCES;
return (-1);
}
errno=EACCES;
return (-1);
}
@@
-125,7
+130,10
@@
int response_l;
if (i == 0)
{
if (i == 0)
{
- DPRINTF("cram: invalid base64 encoding");
+ if (logerr)
+ {
+ DPRINTF("cram: invalid base64 encoding");
+ }
errno=EACCES;
return (-1);
}
errno=EACCES;
return (-1);
}
@@
-140,9
+148,12
@@
int response_l;
craminfo->challenge[challenge_l]=0;
craminfo->response[response_l]=0;
craminfo->challenge[challenge_l]=0;
craminfo->response[response_l]=0;
- /* we rely on DPRINTF doing a "safe" print here */
- DPRINTF("cram: decoded challenge/response, username '%s'",
- craminfo->user);
+ if (logerr)
+ {
+ /* we rely on DPRINTF doing a "safe" print here */
+ DPRINTF("cram: decoded challenge/response, username '%s'",
+ craminfo->user);
+ }
return (0);
}
return (0);
}
@@
-195,5
+206,14
@@
int rc;
return (*cci->callback_func)(a, cci->callback_arg);
}
return (*cci->callback_func)(a, cci->callback_arg);
}
+int auth_get_cram(const char *authtype, char *authdata,
+ struct cram_callback_info *craminfo)
+{
+ return do_auth_get_cram(authtype, authdata, craminfo, 1);
+}
-#endif
+int auth_get_cram_silent(const char *authtype, char *authdata,
+ struct cram_callback_info *craminfo)
+{
+ return do_auth_get_cram(authtype, authdata, craminfo, 0);
+}