[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Thu Aug 9 20:09:03 MDT 2012
The branch, master has been updated
via 51a7154 nsswitch: add ABI checking and symbol versions to libwbclient
via fdd07e8 s4-dsdb: Explain better what records are written during schema set
via 1d1bdc3 lib/ldb: Use tdb_parse_record and a callback rather than tdb_fetch()
from a5495bc Remove smb_panic() from unix_strlower(). Just rely on error code return.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 51a71547ef0c883970e9ef86a33c42e1b815cc4d
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 10 10:17:31 2012 +1000
nsswitch: add ABI checking and symbol versions to libwbclient
This will ensure that we do not unintentionally break the ABI.
Andrew Bartlett
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Fri Aug 10 04:08:54 CEST 2012 on sn-devel-104
commit fdd07e87c6fc7a4a0ea7c6f99080d78e526042e6
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 10 08:44:04 2012 +1000
s4-dsdb: Explain better what records are written during schema set
This is controlled by setting write_indices_and_attributes.
Andrew Bartlett
commit 1d1bdc315b4619f0ca5b2a0db602cbe283f8dca8
Author: Andrew Bartlett <abartlet at samba.org>
Date: Thu Aug 9 22:46:48 2012 +1000
lib/ldb: Use tdb_parse_record and a callback rather than tdb_fetch()
This avoid allocation at the tdb layer as we will allocate this
with talloc right away anyway.
Andrew Bartlett
-----------------------------------------------------------------------
Summary of changes:
lib/ldb/ldb_tdb/ldb_search.c | 54 ++++++++++----
nsswitch/libwbclient/ABI/wbclient-0.9.sigs | 75 ++++++++++++++++++++
nsswitch/libwbclient/wscript | 3 +
source4/dsdb/pydsdb.c | 6 +-
source4/dsdb/schema/schema_set.c | 23 ++++--
.../scripting/python/samba/provision/__init__.py | 6 +-
source4/scripting/python/samba/samdb.py | 8 +-
7 files changed, 142 insertions(+), 33 deletions(-)
create mode 100644 nsswitch/libwbclient/ABI/wbclient-0.9.sigs
Changeset truncated at 500 lines:
diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c
index e631f7b..703ad6a 100644
--- a/lib/ldb/ldb_tdb/ldb_search.c
+++ b/lib/ldb/ldb_tdb/ldb_search.c
@@ -234,6 +234,26 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
return LDB_ERR_NO_SUCH_OBJECT;
}
+struct ltdb_parse_data_unpack_ctx {
+ struct ldb_message *msg;
+ struct ldb_module *module;
+};
+
+static int ltdb_parse_data_unpack(TDB_DATA key, TDB_DATA data,
+ void *private_data)
+{
+ struct ltdb_parse_data_unpack_ctx *ctx = private_data;
+
+ int ret = ltdb_unpack_data(ctx->module, &data, ctx->msg);
+ if (ret == -1) {
+ struct ldb_context *ldb = ldb_module_get_ctx(ctx->module);
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid data for index %*.*s\n",
+ (int)key.dsize, (int)key.dsize, key.dptr);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ return ret;
+}
+
/*
search the database for a single simple dn, returning all attributes
in a single message
@@ -246,9 +266,11 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
- TDB_DATA tdb_key, tdb_data;
-
- memset(msg, 0, sizeof(*msg));
+ TDB_DATA tdb_key;
+ struct ltdb_parse_data_unpack_ctx ctx = {
+ .msg = msg,
+ .module = module
+ };
/* form the key */
tdb_key = ltdb_key(module, dn);
@@ -256,24 +278,24 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
return LDB_ERR_OPERATIONS_ERROR;
}
- tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
- talloc_free(tdb_key.dptr);
- if (!tdb_data.dptr) {
- return LDB_ERR_NO_SUCH_OBJECT;
- }
-
+ memset(msg, 0, sizeof(*msg));
+
msg->num_elements = 0;
msg->elements = NULL;
- ret = ltdb_unpack_data(module, &tdb_data, msg);
- free(tdb_data.dptr);
+ ret = tdb_parse_record(ltdb->tdb, tdb_key,
+ ltdb_parse_data_unpack, &ctx);
+ talloc_free(tdb_key.dptr);
+
if (ret == -1) {
- struct ldb_context *ldb = ldb_module_get_ctx(module);
- ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid data for index %s\n",
- ldb_dn_get_linearized(msg->dn));
- return LDB_ERR_OPERATIONS_ERROR;
+ if (tdb_error(ltdb->tdb) == TDB_ERR_NOEXIST) {
+ return LDB_ERR_NO_SUCH_OBJECT;
+ }
+ return LDB_ERR_OPERATIONS_ERROR;
+ } else if (ret != LDB_SUCCESS) {
+ return ret;
}
-
+
if (!msg->dn) {
msg->dn = ldb_dn_copy(msg, dn);
}
diff --git a/nsswitch/libwbclient/ABI/wbclient-0.9.sigs b/nsswitch/libwbclient/ABI/wbclient-0.9.sigs
new file mode 100644
index 0000000..ec25e76
--- /dev/null
+++ b/nsswitch/libwbclient/ABI/wbclient-0.9.sigs
@@ -0,0 +1,75 @@
+wbcAddNamedBlob: wbcErr (size_t *, struct wbcNamedBlob **, const char *, uint32_t, uint8_t *, size_t)
+wbcAllocateGid: wbcErr (gid_t *)
+wbcAllocateMemory: void *(size_t, size_t, void (*)(void *))
+wbcAllocateStringArray: const char **(int)
+wbcAllocateUid: wbcErr (uid_t *)
+wbcAuthenticateUser: wbcErr (const char *, const char *)
+wbcAuthenticateUserEx: wbcErr (const struct wbcAuthUserParams *, struct wbcAuthUserInfo **, struct wbcAuthErrorInfo **)
+wbcChangeTrustCredentials: wbcErr (const char *, struct wbcAuthErrorInfo **)
+wbcChangeUserPassword: wbcErr (const char *, const char *, const char *)
+wbcChangeUserPasswordEx: wbcErr (const struct wbcChangePasswordParams *, struct wbcAuthErrorInfo **, enum wbcPasswordChangeRejectReason *, struct wbcUserPasswordPolicyInfo **)
+wbcCheckTrustCredentials: wbcErr (const char *, struct wbcAuthErrorInfo **)
+wbcCredentialCache: wbcErr (struct wbcCredentialCacheParams *, struct wbcCredentialCacheInfo **, struct wbcAuthErrorInfo **)
+wbcCredentialSave: wbcErr (const char *, const char *)
+wbcDcInfo: wbcErr (const char *, size_t *, const char ***, const char ***)
+wbcDomainInfo: wbcErr (const char *, struct wbcDomainInfo **)
+wbcEndgrent: wbcErr (void)
+wbcEndpwent: wbcErr (void)
+wbcErrorString: const char *(wbcErr)
+wbcFreeMemory: void (void *)
+wbcGetDisplayName: wbcErr (const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
+wbcGetGroups: wbcErr (const char *, uint32_t *, gid_t **)
+wbcGetSidAliases: wbcErr (const struct wbcDomainSid *, struct wbcDomainSid *, uint32_t, uint32_t **, uint32_t *)
+wbcGetgrent: wbcErr (struct group **)
+wbcGetgrgid: wbcErr (gid_t, struct group **)
+wbcGetgrlist: wbcErr (struct group **)
+wbcGetgrnam: wbcErr (const char *, struct group **)
+wbcGetpwent: wbcErr (struct passwd **)
+wbcGetpwnam: wbcErr (const char *, struct passwd **)
+wbcGetpwsid: wbcErr (struct wbcDomainSid *, struct passwd **)
+wbcGetpwuid: wbcErr (uid_t, struct passwd **)
+wbcGidToSid: wbcErr (gid_t, struct wbcDomainSid *)
+wbcGuidToString: wbcErr (const struct wbcGuid *, char **)
+wbcInterfaceDetails: wbcErr (struct wbcInterfaceDetails **)
+wbcLibraryDetails: wbcErr (struct wbcLibraryDetails **)
+wbcListGroups: wbcErr (const char *, uint32_t *, const char ***)
+wbcListTrusts: wbcErr (struct wbcDomainInfo **, size_t *)
+wbcListUsers: wbcErr (const char *, uint32_t *, const char ***)
+wbcLogoffUser: wbcErr (const char *, uid_t, const char *)
+wbcLogoffUserEx: wbcErr (const struct wbcLogoffUserParams *, struct wbcAuthErrorInfo **)
+wbcLogonUser: wbcErr (const struct wbcLogonUserParams *, struct wbcLogonUserInfo **, struct wbcAuthErrorInfo **, struct wbcUserPasswordPolicyInfo **)
+wbcLookupDomainController: wbcErr (const char *, uint32_t, struct wbcDomainControllerInfo **)
+wbcLookupDomainControllerEx: wbcErr (const char *, struct wbcGuid *, const char *, uint32_t, struct wbcDomainControllerInfoEx **)
+wbcLookupName: wbcErr (const char *, const char *, struct wbcDomainSid *, enum wbcSidType *)
+wbcLookupRids: wbcErr (struct wbcDomainSid *, int, uint32_t *, const char **, const char ***, enum wbcSidType **)
+wbcLookupSid: wbcErr (const struct wbcDomainSid *, char **, char **, enum wbcSidType *)
+wbcLookupSids: wbcErr (const struct wbcDomainSid *, int, struct wbcDomainInfo **, int *, struct wbcTranslatedName **)
+wbcLookupUserSids: wbcErr (const struct wbcDomainSid *, bool, uint32_t *, struct wbcDomainSid **)
+wbcPing: wbcErr (void)
+wbcPingDc: wbcErr (const char *, struct wbcAuthErrorInfo **)
+wbcQueryGidToSid: wbcErr (gid_t, struct wbcDomainSid *)
+wbcQuerySidToGid: wbcErr (const struct wbcDomainSid *, gid_t *)
+wbcQuerySidToUid: wbcErr (const struct wbcDomainSid *, uid_t *)
+wbcQueryUidToSid: wbcErr (uid_t, struct wbcDomainSid *)
+wbcRemoveGidMapping: wbcErr (gid_t, const struct wbcDomainSid *)
+wbcRemoveUidMapping: wbcErr (uid_t, const struct wbcDomainSid *)
+wbcRequestResponse: wbcErr (int, struct winbindd_request *, struct winbindd_response *)
+wbcRequestResponsePriv: wbcErr (int, struct winbindd_request *, struct winbindd_response *)
+wbcResolveWinsByIP: wbcErr (const char *, char **)
+wbcResolveWinsByName: wbcErr (const char *, char **)
+wbcSetGidHwm: wbcErr (gid_t)
+wbcSetGidMapping: wbcErr (gid_t, const struct wbcDomainSid *)
+wbcSetUidHwm: wbcErr (uid_t)
+wbcSetUidMapping: wbcErr (uid_t, const struct wbcDomainSid *)
+wbcSetgrent: wbcErr (void)
+wbcSetpwent: wbcErr (void)
+wbcSidToGid: wbcErr (const struct wbcDomainSid *, gid_t *)
+wbcSidToString: wbcErr (const struct wbcDomainSid *, char **)
+wbcSidToStringBuf: int (const struct wbcDomainSid *, char *, int)
+wbcSidToUid: wbcErr (const struct wbcDomainSid *, uid_t *)
+wbcSidTypeString: const char *(enum wbcSidType)
+wbcSidsToUnixIds: wbcErr (const struct wbcDomainSid *, uint32_t, struct wbcUnixId *)
+wbcStrDup: char *(const char *)
+wbcStringToGuid: wbcErr (const char *, struct wbcGuid *)
+wbcStringToSid: wbcErr (const char *, struct wbcDomainSid *)
+wbcUidToSid: wbcErr (uid_t, struct wbcDomainSid *)
diff --git a/nsswitch/libwbclient/wscript b/nsswitch/libwbclient/wscript
index 6b9c99c..8f7b704 100644
--- a/nsswitch/libwbclient/wscript
+++ b/nsswitch/libwbclient/wscript
@@ -27,6 +27,7 @@ def build(bld):
#
# Logs.info("\tSelected embedded libwbclient build")
+ abi_match = 'wbc*'
bld.SAMBA_LIBRARY('wbclient',
source='''
wbc_guid.c
@@ -39,4 +40,6 @@ def build(bld):
deps='winbind-client',
pc_files='wbclient.pc',
public_headers='wbclient.h',
+ abi_directory='ABI',
+ abi_match=abi_match,
vnum=VERSION)
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index 9023d69..39229f4 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -873,9 +873,9 @@ static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
struct ldb_context *from_ldb;
struct dsdb_schema *schema;
int ret;
- char write_attributes = true;
+ char write_indices_and_attributes = true;
if (!PyArg_ParseTuple(args, "OO|b",
- &py_ldb, &py_from_ldb, &write_attributes))
+ &py_ldb, &py_from_ldb, &write_indices_and_attributes))
return NULL;
PyErr_LDB_OR_RAISE(py_ldb, ldb);
@@ -888,7 +888,7 @@ static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
return NULL;
}
- ret = dsdb_reference_schema(ldb, schema, write_attributes);
+ ret = dsdb_reference_schema(ldb, schema, write_indices_and_attributes);
PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb);
Py_RETURN_NONE;
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 286a8a3..e226118 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -50,8 +50,13 @@ const struct ldb_schema_attribute *dsdb_attribute_handler_override(struct ldb_co
}
return a->ldb_schema_attribute;
}
-
-static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_attributes)
+/*
+ * Set the attribute handlers onto the LDB, and potentially write the
+ * @INDEXLIST, @IDXONE and @ATTRIBUTES records. The @ATTRIBUTES records
+ * are required so we can operate on a schema-less database (say the
+ * backend during emergency fixes) and during the schema load.
+ */
+static int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_indices_and_attributes)
{
int ret = LDB_SUCCESS;
struct ldb_result *res;
@@ -65,7 +70,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
/* setup our own attribute name to schema handler */
ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema);
- if (!write_attributes) {
+ if (!write_indices_and_attributes) {
return ret;
}
@@ -454,7 +459,7 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
}
/* Set the new attributes based on the new schema */
- ret = dsdb_schema_set_attributes(ldb, schema, true);
+ ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -469,9 +474,13 @@ static struct dsdb_schema *global_schema;
/**
* Make this ldb use a specified schema, already fully calculated and belonging to another ldb
+ *
+ * The write_indices_and_attributes controls writing of the @ records
+ * because we cannot write to a database that does not yet exist on
+ * disk.
*/
int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema,
- bool write_attributes)
+ bool write_indices_and_attributes)
{
int ret;
struct dsdb_schema *old_schema;
@@ -495,7 +504,7 @@ int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema,
return ret;
}
- ret = dsdb_schema_set_attributes(ldb, schema, write_attributes);
+ ret = dsdb_schema_set_indices_and_attributes(ldb, schema, write_indices_and_attributes);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -519,7 +528,7 @@ int dsdb_set_global_schema(struct ldb_context *ldb)
}
/* Set the new attributes based on the new schema */
- ret = dsdb_schema_set_attributes(ldb, global_schema, false /* Don't write attributes, it's expensive */);
+ ret = dsdb_schema_set_indices_and_attributes(ldb, global_schema, false /* Don't write indices and attributes, it's expensive */);
if (ret == LDB_SUCCESS) {
/* Keep a reference to this schema, just in case the original copy is replaced */
if (talloc_reference(ldb, global_schema) == NULL) {
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index 94e857e..6834d40 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -1121,7 +1121,7 @@ def setup_samdb(path, session_info, provision_backend, lp, names,
logger.info("Pre-loading the Samba 4 and AD schema")
# Load the schema from the one we computed earlier
- samdb.set_schema(schema, write_attributes=False)
+ samdb.set_schema(schema, write_indices_and_attributes=False)
# Set the NTDS settings DN manually - in order to have it already around
# before the provisioned tree exists and we connect
@@ -1133,8 +1133,8 @@ def setup_samdb(path, session_info, provision_backend, lp, names,
# But we have to give it one more kick to have it use the schema
# during provision - it needs, now that it is connected, to write
- # the schema @INDEX records to the database.
- samdb.set_schema(schema, write_attributes=True)
+ # the schema @ATTRIBUTES and @INDEXLIST records to the database.
+ samdb.set_schema(schema, write_indices_and_attributes=True)
return samdb
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 3355e9a..7db1b00 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -608,11 +608,11 @@ accountExpires: %u
def load_partition_usn(self, base_dn):
return dsdb._dsdb_load_partition_usn(self, base_dn)
- def set_schema(self, schema, write_attributes=True):
- self.set_schema_from_ldb(schema.ldb, write_attributes=write_attributes)
+ def set_schema(self, schema, write_indices_and_attributes=True):
+ self.set_schema_from_ldb(schema.ldb, write_indices_and_attributes=write_indices_and_attributes)
- def set_schema_from_ldb(self, ldb_conn, write_attributes=True):
- dsdb._dsdb_set_schema_from_ldb(self, ldb_conn, write_attributes)
+ def set_schema_from_ldb(self, ldb_conn, write_indices_and_attributes=True):
+ dsdb._dsdb_set_schema_from_ldb(self, ldb_conn, write_indices_and_attributes)
def dsdb_DsReplicaAttribute(self, ldb, ldap_display_name, ldif_elements):
'''convert a list of attribute values to a DRSUAPI DsReplicaAttribute'''
--
Samba Shared Repository
More information about the samba-cvs
mailing list