db_berkeley.c | db_berkeley.c | |||
---|---|---|---|---|
/* db_berkeley.c--SASL berkeley db interface | /* db_berkeley.c--SASL berkeley db interface | |||
* Rob Siemborski | * Rob Siemborski | |||
* Tim Martin | * Tim Martin | |||
* $Id: db_berkeley.c,v 1.8 2006/04/03 10:58:19 mel Exp $ | * $Id: db_berkeley.c,v 1.10 2011/09/01 14:12:18 mel Exp $ | |||
*/ | */ | |||
/* | /* | |||
* Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved . | * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved . | |||
* | * | |||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | |||
* are met: | * are met: | |||
* | * | |||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | |||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | |||
skipping to change at line 53 | skipping to change at line 53 | |||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
*/ | */ | |||
#include <config.h> | #include <config.h> | |||
#include <db.h> | #include <db.h> | |||
#include <sys/stat.h> | #include <sys/stat.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <assert.h> | #include <assert.h> | |||
#include <errno.h> | ||||
#include "sasldb.h" | #include "sasldb.h" | |||
static int db_ok = 0; | static int db_ok = 0; | |||
#if defined(KEEP_DB_OPEN) | #if defined(KEEP_DB_OPEN) | |||
static DB * g_db = NULL; | static DB * g_db = NULL; | |||
#endif | #endif | |||
/* | /* | |||
* Open the database | * Open the database | |||
*/ | */ | |||
skipping to change at line 117 | skipping to change at line 118 | |||
#endif | #endif | |||
if (ret != 0) | if (ret != 0) | |||
{ | { | |||
(void) (*mbdb)->close(*mbdb, 0); | (void) (*mbdb)->close(*mbdb, 0); | |||
*mbdb = NULL; | *mbdb = NULL; | |||
} | } | |||
} | } | |||
#endif /* DB_VERSION_MAJOR < 3 */ | #endif /* DB_VERSION_MAJOR < 3 */ | |||
if (ret != 0) { | if (ret != 0) { | |||
if (rdwr == 0 && ret == ENOENT) { | ||||
/* File not found and we are only reading the data. | ||||
Treat as SASL_NOUSER. */ | ||||
return SASL_NOUSER; | ||||
} | ||||
utils->log(conn, SASL_LOG_ERR, | utils->log(conn, SASL_LOG_ERR, | |||
"unable to open Berkeley db %s: %s", | "unable to open Berkeley db %s: %s", | |||
path, db_strerror(ret)); | path, db_strerror(ret)); | |||
utils->seterror(conn, SASL_NOLOG, "Unable to open DB"); | utils->seterror(conn, SASL_NOLOG, "Unable to open DB"); | |||
return SASL_FAIL; | return SASL_FAIL; | |||
} | } | |||
#if defined(KEEP_DB_OPEN) | #if defined(KEEP_DB_OPEN) | |||
/* Save the DB handle for later use */ | /* Save the DB handle for later use */ | |||
g_db = *mbdb; | g_db = *mbdb; | |||
skipping to change at line 373 | skipping to change at line 379 | |||
if (utils->getcallback(conn, SASL_CB_GETOPT, | if (utils->getcallback(conn, SASL_CB_GETOPT, | |||
&getopt, &cntxt) == SASL_OK) { | &getopt, &cntxt) == SASL_OK) { | |||
const char *p; | const char *p; | |||
if (getopt(cntxt, NULL, "sasldb_path", &p, NULL) == SASL_OK | if (getopt(cntxt, NULL, "sasldb_path", &p, NULL) == SASL_OK | |||
&& p != NULL && *p != 0) { | && p != NULL && *p != 0) { | |||
path = p; | path = p; | |||
} | } | |||
} | } | |||
ret = utils->getcallback(conn, SASL_CB_VERIFYFILE, | ret = utils->getcallback(conn, SASL_CB_VERIFYFILE, | |||
&vf, &cntxt); | (sasl_callback_ft *)&vf, &cntxt); | |||
if (ret != SASL_OK) { | if (ret != SASL_OK) { | |||
utils->seterror(conn, 0, "verifyfile failed"); | utils->seterror(conn, 0, "verifyfile failed"); | |||
return ret; | return ret; | |||
} | } | |||
ret = vf(cntxt, path, SASL_VRFY_PASSWD); | ret = vf(cntxt, path, SASL_VRFY_PASSWD); | |||
if (ret == SASL_OK) { | if (ret == SASL_OK) { | |||
db_ok = 1; | db_ok = 1; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 8 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |