summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hdb
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
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')
-rw-r--r--source4/heimdal/lib/hdb/db.c60
-rw-r--r--source4/heimdal/lib/hdb/ext.c16
-rw-r--r--source4/heimdal/lib/hdb/hdb-protos.h64
-rw-r--r--source4/heimdal/lib/hdb/hdb.asn16
-rw-r--r--source4/heimdal/lib/hdb/hdb.c19
-rw-r--r--source4/heimdal/lib/hdb/hdb.h9
-rw-r--r--source4/heimdal/lib/hdb/hdb_err.et2
-rw-r--r--source4/heimdal/lib/hdb/hdb_locl.h2
-rw-r--r--source4/heimdal/lib/hdb/keys.c2
-rw-r--r--source4/heimdal/lib/hdb/keytab.c2
-rw-r--r--source4/heimdal/lib/hdb/mkey.c2
-rw-r--r--source4/heimdal/lib/hdb/ndbm.c2
12 files changed, 154 insertions, 32 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;
diff --git a/source4/heimdal/lib/hdb/ext.c b/source4/heimdal/lib/hdb/ext.c
index 141c63a8ac..aac0ff5367 100644
--- a/source4/heimdal/lib/hdb/ext.c
+++ b/source4/heimdal/lib/hdb/ext.c
@@ -34,7 +34,7 @@
#include "hdb_locl.h"
#include <der.h>
-RCSID("$Id: ext.c,v 1.6 2006/10/14 10:13:03 lha Exp $");
+RCSID("$Id: ext.c 20236 2007-02-16 23:52:29Z lha $");
krb5_error_code
hdb_entry_check_mandatory(krb5_context context, const hdb_entry *ent)
@@ -394,3 +394,17 @@ hdb_entry_get_ConstrainedDelegACL(const hdb_entry *entry,
return 0;
}
+
+krb5_error_code
+hdb_entry_get_aliases(const hdb_entry *entry, const HDB_Ext_Aliases **a)
+{
+ const HDB_extension *ext;
+
+ ext = hdb_find_extension(entry, choice_HDB_extension_data_aliases);
+ if (ext)
+ *a = &ext->data.u.aliases;
+ else
+ *a = NULL;
+
+ return 0;
+}
diff --git a/source4/heimdal/lib/hdb/hdb-protos.h b/source4/heimdal/lib/hdb/hdb-protos.h
index de0545a037..6d679fd48f 100644
--- a/source4/heimdal/lib/hdb/hdb-protos.h
+++ b/source4/heimdal/lib/hdb/hdb-protos.h
@@ -42,6 +42,41 @@ hdb_db_create (
HDB **/*db*/,
const char */*filename*/);
+const char *
+hdb_dbinfo_get_acl_file (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
+const krb5_config_binding *
+hdb_dbinfo_get_binding (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
+const char *
+hdb_dbinfo_get_dbname (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
+const char *
+hdb_dbinfo_get_label (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
+const char *
+hdb_dbinfo_get_mkey_file (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
+struct hdb_dbinfo *
+hdb_dbinfo_get_next (
+ struct hdb_dbinfo */*dbp*/,
+ struct hdb_dbinfo */*dbprevp*/);
+
+const char *
+hdb_dbinfo_get_realm (
+ krb5_context /*context*/,
+ struct hdb_dbinfo */*dbp*/);
+
krb5_error_code
hdb_enctype2key (
krb5_context /*context*/,
@@ -58,7 +93,13 @@ hdb_entry2string (
int
hdb_entry2value (
krb5_context /*context*/,
- hdb_entry */*ent*/,
+ const hdb_entry */*ent*/,
+ krb5_data */*value*/);
+
+int
+hdb_entry_alias2value (
+ krb5_context /*context*/,
+ const hdb_entry_alias */*alias*/,
krb5_data */*value*/);
krb5_error_code
@@ -76,6 +117,11 @@ hdb_entry_get_ConstrainedDelegACL (
const hdb_entry */*entry*/,
const HDB_Ext_Constrained_delegation_acl **/*a*/);
+krb5_error_code
+hdb_entry_get_aliases (
+ const hdb_entry */*entry*/,
+ const HDB_Ext_Aliases **/*a*/);
+
int
hdb_entry_get_password (
krb5_context /*context*/,
@@ -125,6 +171,11 @@ hdb_foreach (
void */*data*/);
void
+hdb_free_dbinfo (
+ krb5_context /*context*/,
+ struct hdb_dbinfo **/*dbp*/);
+
+void
hdb_free_entry (
krb5_context /*context*/,
hdb_entry_ex */*ent*/);
@@ -159,6 +210,11 @@ hdb_generate_key_set_password (
Key **/*keys*/,
size_t */*num_keys*/);
+int
+hdb_get_dbinfo (
+ krb5_context /*context*/,
+ struct hdb_dbinfo **/*dbp*/);
+
krb5_error_code
hdb_init_db (
krb5_context /*context*/,
@@ -314,6 +370,12 @@ hdb_value2entry (
krb5_data */*value*/,
hdb_entry */*ent*/);
+int
+hdb_value2entry_alias (
+ krb5_context /*context*/,
+ krb5_data */*value*/,
+ hdb_entry_alias */*ent*/);
+
krb5_error_code
hdb_write_master_key (
krb5_context /*context*/,
diff --git a/source4/heimdal/lib/hdb/hdb.asn1 b/source4/heimdal/lib/hdb/hdb.asn1
index c8c276ff6e..acd8f61d7e 100644
--- a/source4/heimdal/lib/hdb/hdb.asn1
+++ b/source4/heimdal/lib/hdb/hdb.asn1
@@ -1,4 +1,4 @@
--- $Id: hdb.asn1,v 1.17 2006/08/24 10:45:19 lha Exp $
+-- $Id: hdb.asn1 20236 2007-02-16 23:52:29Z lha $
HDB DEFINITIONS ::=
BEGIN
@@ -120,4 +120,8 @@ hdb_entry ::= SEQUENCE {
extensions[13] HDB-extensions OPTIONAL
}
+hdb_entry_alias ::= [APPLICATION 0] SEQUENCE {
+ principal[0] Principal OPTIONAL
+}
+
END
diff --git a/source4/heimdal/lib/hdb/hdb.c b/source4/heimdal/lib/hdb/hdb.c
index cd4f24a732..f0731ed98e 100644
--- a/source4/heimdal/lib/hdb/hdb.c
+++ b/source4/heimdal/lib/hdb/hdb.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,7 +33,7 @@
#include "hdb_locl.h"
-RCSID("$Id: hdb.c,v 1.64 2006/11/28 14:24:27 lha Exp $");
+RCSID("$Id: hdb.c 20214 2007-02-09 21:51:10Z lha $");
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
@@ -56,7 +56,7 @@ static struct hdb_method methods[] = {
{"ldapi:", hdb_ldapi_create},
#endif
#ifdef _SAMBA_BUILD_
- {"ldb:", hdb_ldb_create},
+ {"ldb:", hdb_ldb_create},
#endif
#ifdef HAVE_LDB /* Used for integrated samba build */
{"ldb:", hdb_ldb_create},
@@ -81,11 +81,15 @@ hdb_next_enctype2key(krb5_context context,
for (k = *key ? (*key) + 1 : e->keys.val;
k < e->keys.val + e->keys.len;
- k++)
+ k++)
+ {
if(k->key.keytype == enctype){
*key = k;
return 0;
}
+ }
+ krb5_set_error_string(context, "No next enctype %d for hdb-entry",
+ (int)enctype);
return KRB5_PROG_ETYPE_NOSUPP; /* XXX */
}
@@ -164,6 +168,8 @@ hdb_foreach(krb5_context context,
krb5_error_code ret;
hdb_entry_ex entry;
ret = db->hdb_firstkey(context, db, flags, &entry);
+ if (ret == 0)
+ krb5_clear_error_string(context);
while(ret == 0){
ret = (*func)(context, db, &entry, data);
hdb_free_entry(context, &entry);
@@ -228,8 +234,11 @@ hdb_init_db(krb5_context context, HDB *db)
version.length = strlen(version.data) + 1; /* zero terminated */
ret = (*db->hdb__put)(context, db, 0, tag, version);
ret2 = db->hdb_unlock(context, db);
- if (ret)
+ if (ret) {
+ if (ret2)
+ krb5_clear_error_string(context);
return ret;
+ }
return ret2;
}
diff --git a/source4/heimdal/lib/hdb/hdb.h b/source4/heimdal/lib/hdb/hdb.h
index dcfceb58f0..830589388f 100644
--- a/source4/heimdal/lib/hdb/hdb.h
+++ b/source4/heimdal/lib/hdb/hdb.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-/* $Id: hdb.h,v 1.38 2006/04/28 07:37:11 lha Exp $ */
+/* $Id: hdb.h 20535 2007-04-23 07:49:16Z lha $ */
#ifndef __HDB_H__
#define __HDB_H__
@@ -41,6 +41,8 @@
#include <heim_asn1.h>
#include <hdb_asn1.h>
+struct hdb_dbinfo;
+
enum hdb_lockop{ HDB_RLOCK, HDB_WLOCK };
/* flags for various functions */
@@ -50,6 +52,7 @@ enum hdb_lockop{ HDB_RLOCK, HDB_WLOCK };
#define HDB_F_GET_SERVER 8 /* fetch server */
#define HDB_F_GET_KRBTGT 16 /* fetch krbtgt */
#define HDB_F_GET_ANY 28 /* fetch any of client,server,krbtgt */
+#define HDB_F_CANON 32 /* want canonicalition */
/* key usage for master key */
#define HDB_KU_MKEY 0x484442
@@ -69,7 +72,7 @@ typedef struct HDB{
char *hdb_name;
int hdb_master_key_set;
hdb_master_key hdb_master_key;
- void *hdb_openp;
+ int hdb_openp;
krb5_error_code (*hdb_open)(krb5_context,
struct HDB*,
diff --git a/source4/heimdal/lib/hdb/hdb_err.et b/source4/heimdal/lib/hdb/hdb_err.et
index f2636b2fea..5c5b80bb36 100644
--- a/source4/heimdal/lib/hdb/hdb_err.et
+++ b/source4/heimdal/lib/hdb/hdb_err.et
@@ -3,7 +3,7 @@
#
# This might look like a com_err file, but is not
#
-id "$Id: hdb_err.et,v 1.6 2005/08/11 13:17:22 lha Exp $"
+id "$Id: hdb_err.et 15878 2005-08-11 13:17:22Z lha $"
error_table hdb
diff --git a/source4/heimdal/lib/hdb/hdb_locl.h b/source4/heimdal/lib/hdb/hdb_locl.h
index 0bf4e8191c..ad16075b24 100644
--- a/source4/heimdal/lib/hdb/hdb_locl.h
+++ b/source4/heimdal/lib/hdb/hdb_locl.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-/* $Id: hdb_locl.h,v 1.19 2003/09/10 21:54:58 lha Exp $ */
+/* $Id: hdb_locl.h 12820 2003-09-10 21:54:58Z lha $ */
#ifndef __HDB_LOCL_H__
#define __HDB_LOCL_H__
diff --git a/source4/heimdal/lib/hdb/keys.c b/source4/heimdal/lib/hdb/keys.c
index 8d4810f5c9..9b87050120 100644
--- a/source4/heimdal/lib/hdb/keys.c
+++ b/source4/heimdal/lib/hdb/keys.c
@@ -33,7 +33,7 @@
#include "hdb_locl.h"
-RCSID("$Id: keys.c,v 1.6 2006/10/22 09:40:12 lha Exp $");
+RCSID("$Id: keys.c 18819 2006-10-22 09:40:12Z lha $");
/*
* free all the memory used by (len, keys)
diff --git a/source4/heimdal/lib/hdb/keytab.c b/source4/heimdal/lib/hdb/keytab.c
index 7ae3ec3150..5c867daf20 100644
--- a/source4/heimdal/lib/hdb/keytab.c
+++ b/source4/heimdal/lib/hdb/keytab.c
@@ -35,7 +35,7 @@
/* keytab backend for HDB databases */
-RCSID("$Id: keytab.c,v 1.16 2006/10/09 12:36:40 lha Exp $");
+RCSID("$Id: keytab.c 18380 2006-10-09 12:36:40Z lha $");
struct hdb_data {
char *dbname;
diff --git a/source4/heimdal/lib/hdb/mkey.c b/source4/heimdal/lib/hdb/mkey.c
index 40569b29ad..02d87b6cf3 100644
--- a/source4/heimdal/lib/hdb/mkey.c
+++ b/source4/heimdal/lib/hdb/mkey.c
@@ -36,7 +36,7 @@
#define O_BINARY 0
#endif
-RCSID("$Id: mkey.c,v 1.22 2006/05/05 10:27:59 lha Exp $");
+RCSID("$Id: mkey.c 17445 2006-05-05 10:37:46Z lha $");
struct hdb_master_key_data {
krb5_keytab_entry keytab;
diff --git a/source4/heimdal/lib/hdb/ndbm.c b/source4/heimdal/lib/hdb/ndbm.c
index 6c72ea78c5..6575b8a417 100644
--- a/source4/heimdal/lib/hdb/ndbm.c
+++ b/source4/heimdal/lib/hdb/ndbm.c
@@ -33,7 +33,7 @@
#include "hdb_locl.h"
-RCSID("$Id: ndbm.c,v 1.38 2005/12/13 11:54:10 lha Exp $");
+RCSID("$Id: ndbm.c 16395 2005-12-13 11:54:10Z lha $");
#if HAVE_NDBM