sasl2 patch
Here is the patch I promised for sasl2
--
Barry deFreese
Debian 3.0r1 "Woody"
GNU/Hurd
Registered Linux "Newbie" #302256 - Hurd H4XX0r wannabe
"Programming today is a race between software engineers striving
to build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots. So far, the Universe is
winning." Rich Cook.
--- auth_sasldb.h 2003-02-13 14:38:28.000000000 -0500
+++ auth_sasldb.new 2005-02-02 18:39:22.000000000 -0500
@@ -1,5 +1,7 @@
+/* MODULE: auth_sasldb */
+
/* COPYRIGHT
- * Copyright (c) 1997 Messaging Direct Ltd.
+ * Copyright (c) 1997-2000 Messaging Direct Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,4 +27,150 @@
* DAMAGE.
* END COPYRIGHT */
-char *auth_sasldb(const char *, const char *, const char *, const char *);
+/* SYNOPSIS
+ * crypt(3) based passwd file validation
+ * END SYNOPSIS */
+
+#ifdef __GNUC__
+#ident "$Id: auth_sasldb.c,v 1.5 2002/07/27 18:44:46 rjs3 Exp $"
+#endif
+
+/* PUBLIC DEPENDENCIES */
+#include "mechanisms.h"
+#include "../include/xgethostname.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <pwd.h>
+/* END PUBLIC DEPENDENCIES */
+
+#define RETURN(x) return strdup(x)
+
+
+#ifdef AUTH_SASLDB
+#include "../include/sasl.h"
+#include "../include/saslplug.h"
+#include "../sasldb/sasldb.h"
+
+static int
+vf(void *context __attribute__((unused)),
+ char *file __attribute__((unused)),
+ int type __attribute__((unused)))
+{
+ /* always say ok */
+ return SASL_OK;
+}
+
+static int lame_getcallback(sasl_conn_t *conn __attribute__((unused)),
+ unsigned long callbackid,
+ int (**pproc)(),
+ void **pcontext)
+{
+ if(callbackid == SASL_CB_VERIFYFILE) {
+ *pproc = vf;
+ *pcontext = NULL;
+ return SASL_OK;
+ }
+
+ return SASL_FAIL;
+}
+
+static void lame_log(sasl_conn_t *conn, int level, const char *fmt, ...)
+{
+ return;
+}
+
+static void lame_seterror(sasl_conn_t *conn, unsigned flags,
+ const char *fmt, ...)
+{
+ return;
+}
+
+/* FUNCTION: init_lame_utils */
+/* This sets up a very minimal sasl_utils_t for use only with the
+ * database functions */
+static void init_lame_utils(sasl_utils_t *utils)
+{
+ memset(utils, 0, sizeof(sasl_utils_t));
+
+ utils->malloc=(sasl_malloc_t *)malloc;
+ utils->calloc=(sasl_calloc_t *)calloc;
+ utils->realloc=(sasl_realloc_t *)realloc;
+ utils->free=(sasl_free_t *)free;
+
+ utils->getcallback=lame_getcallback;
+ utils->log=lame_log;
+ utils->seterror=lame_seterror;
+
+ return;
+}
+
+/* END FUNCTION: init_lame_utils */
+
+#endif /* AUTH_SASLDB */
+
+/* FUNCTION: auth_sasldb */
+
+char * /* R: allocated response string */
+auth_sasldb (
+ /* PARAMETERS */
+#ifdef AUTH_SASLDB
+ const char *login, /* I: plaintext authenticator */
+ const char *password, /* I: plaintext password */
+ const char *service __attribute__((unused)),
+ const char *realm
+#else
+ const char *login __attribute__((unused)),/* I: plaintext authenticator */
+ const char *password __attribute__((unused)), /* I: plaintext password */
+ const char *service __attribute__((unused)),
+ const char *realm __attribute__((unused))
+#endif
+ /* END PARAMETERS */
+ )
+{
+#ifdef AUTH_SASLDB
+ /* VARIABLES */
+ char pw[1024]; /* pointer to passwd file entry */
+ sasl_utils_t utils;
+ int ret, outsize;
+ const char *use_realm;
+ char *realm_buf;
+ realm_buf = xgethostname ();
+
+ /* END VARIABLES */
+
+ init_lame_utils(&utils);
+
+ _sasl_check_db(&utils, (void *)0x1);
+
+ if(!realm || !strlen(realm)) {
+ ret = realm_buf;
+ if(ret) RETURN("NO");
+ use_realm = realm_buf;
+ } else {
+ use_realm = realm;
+ }
+
+ if (realm_buf)
+ free (realm_buf);
+
+ ret = _sasldb_getdata(&utils, (void *)0x1, login, use_realm,
+ "userPassword", pw, 1024, &outsize);
+
+ if (ret != SASL_OK) {
+ RETURN("NO");
+ }
+
+ if (strcmp(pw, password)) {
+ RETURN("NO");
+ }
+
+ RETURN("OK");
+#else
+ RETURN("NO");
+#endif
+}
+
+/* END FUNCTION: auth_sasldb */
+
+/* END MODULE: auth_sasldb */
Reply to: