summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hdb/db.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-06-13 05:44:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:18 -0500
commit91adebe749beb0dc23cacaea316cb2b724776aad (patch)
tree133d480f5b23b99fcf1149861136103dc4525cb1 /source4/heimdal/lib/hdb/db.c
parentf7110d928afd61cee203d07fd85968af993a327f (diff)
downloadsamba-91adebe749beb0dc23cacaea316cb2b724776aad.tar.gz
samba-91adebe749beb0dc23cacaea316cb2b724776aad.tar.bz2
samba-91adebe749beb0dc23cacaea316cb2b724776aad.zip
r23456: Update Samba4 to current lorikeet-heimdal.
Andrew Bartlett (This used to be commit ae0f81ab235c72cceb120bcdeb051a483cf3cc4f)
Diffstat (limited to 'source4/heimdal/lib/hdb/db.c')
-rw-r--r--source4/heimdal/lib/hdb/db.c60
1 files changed, 45 insertions, 15 deletions
diff --git a/source4/heimdal/lib/hdb/db.c b/source4/heimdal/lib/hdb/db.c
index 0bbf6f2210..870f0431cf 100644
--- a/source4/heimdal/lib/hdb/db.c
+++ b/source4/heimdal/lib/hdb/db.c
@@ -33,7 +33,7 @@
#include "hdb_locl.h"
-RCSID("$Id: db.c,v 1.36 2006/09/12 18:12:37 lha Exp $");
+RCSID("$Id: db.c 20215 2007-02-09 21:59:53Z lha $");
#if HAVE_DB1
@@ -67,8 +67,11 @@ DB_lock(krb5_context context, HDB *db, int operation)
{
DB *d = (DB*)db->hdb_db;
int fd = (*d->fd)(d);
- if(fd < 0)
+ if(fd < 0) {
+ krb5_set_error_string(context,
+ "Can't lock database: %s", db->hdb_name);
return HDB_ERR_CANT_LOCK_DB;
+ }
return hdb_lock(fd, operation);
}
@@ -77,8 +80,11 @@ DB_unlock(krb5_context context, HDB *db)
{
DB *d = (DB*)db->hdb_db;
int fd = (*d->fd)(d);
- if(fd < 0)
+ if(fd < 0) {
+ krb5_set_error_string(context,
+ "Can't unlock database: %s", db->hdb_name);
return HDB_ERR_CANT_LOCK_DB;
+ }
return hdb_unlock(fd);
}
@@ -93,14 +99,22 @@ DB_seq(krb5_context context, HDB *db,
int code;
code = db->hdb_lock(context, db, HDB_RLOCK);
- if(code == -1)
+ if(code == -1) {
+ krb5_set_error_string(context, "Database %s in use", db->hdb_name);
return HDB_ERR_DB_INUSE;
+ }
code = (*d->seq)(d, &key, &value, flag);
db->hdb_unlock(context, db); /* XXX check value */
- if(code == -1)
- return errno;
- if(code == 1)
+ if(code == -1) {
+ code = errno;
+ krb5_set_error_string(context, "Database %s seq error: %s",
+ db->hdb_name, strerror(code));
+ return code;
+ }
+ if(code == 1) {
+ krb5_clear_error_string(context);
return HDB_ERR_NOENTRY;
+ }
key_data.data = key.data;
key_data.length = key.size;
@@ -174,10 +188,16 @@ DB__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply)
return code;
code = (*d->get)(d, &k, &v, 0);
db->hdb_unlock(context, db);
- if(code < 0)
- return errno;
- if(code == 1)
+ if(code < 0) {
+ code = errno;
+ krb5_set_error_string(context, "Database %s get error: %s",
+ db->hdb_name, strerror(code));
+ return code;
+ }
+ if(code == 1) {
+ krb5_clear_error_string(context);
return HDB_ERR_NOENTRY;
+ }
krb5_data_copy(reply, v.data, v.size);
return 0;
@@ -200,10 +220,16 @@ DB__put(krb5_context context, HDB *db, int replace,
return code;
code = (*d->put)(d, &k, &v, replace ? 0 : R_NOOVERWRITE);
db->hdb_unlock(context, db);
- if(code < 0)
- return errno;
- if(code == 1)
+ if(code < 0) {
+ code = errno;
+ krb5_set_error_string(context, "Database %s put error: %s",
+ db->hdb_name, strerror(code));
+ return code;
+ }
+ if(code == 1) {
+ krb5_clear_error_string(context);
return HDB_ERR_EXISTS;
+ }
return 0;
}
@@ -220,8 +246,12 @@ DB__del(krb5_context context, HDB *db, krb5_data key)
return code;
code = (*d->del)(d, &k, 0);
db->hdb_unlock(context, db);
- if(code == 1)
- return HDB_ERR_NOENTRY;
+ if(code == 1) {
+ code = errno;
+ krb5_set_error_string(context, "Database %s put error: %s",
+ db->hdb_name, strerror(code));
+ return code;
+ }
if(code < 0)
return errno;
return 0;