summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-01 06:55:41 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-11-01 12:22:16 +0100
commitfca89804ad00ddcf103a06e4b2ffa2b5a25aa6b5 (patch)
tree2319eced57810a120f0c13d3b0510a6771ce0cbc
parent797aaa618eb4ba04c1001f092d81b5ff0140d4b4 (diff)
downloadsamba-fca89804ad00ddcf103a06e4b2ffa2b5a25aa6b5.tar.gz
samba-fca89804ad00ddcf103a06e4b2ffa2b5a25aa6b5.tar.bz2
samba-fca89804ad00ddcf103a06e4b2ffa2b5a25aa6b5.zip
s4:dsdb/rootdse: Pass rootdse context to rootdse_add_dynamic
This replaced the *module parameter, and uses ac->module in the function instead, same for *req and *attrs.
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 167201ec60..bcae804945 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -43,6 +43,11 @@ struct private_data {
bool block_anonymous;
};
+struct rootdse_context {
+ struct ldb_module *module;
+ struct ldb_request *req;
+};
+
/*
return 1 if a specific attribute has been requested
*/
@@ -216,11 +221,11 @@ static int dsdb_module_we_are_master(struct ldb_module *module, struct ldb_dn *d
/*
add dynamically generated attributes to rootDSE result
*/
-static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *msg,
- const char * const *attrs, struct ldb_request *req)
+static int rootdse_add_dynamic(struct rootdse_context *ac, struct ldb_message *msg)
{
struct ldb_context *ldb;
- struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data);
+ struct private_data *priv = talloc_get_type(ldb_module_get_private(ac->module), struct private_data);
+ const char * const *attrs = ac->req->op.search.attrs;
char **server_sasl;
const struct dsdb_schema *schema;
int *val;
@@ -241,7 +246,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
};
unsigned int i;
- ldb = ldb_module_get_ctx(module);
+ ldb = ldb_module_get_ctx(ac->module);
schema = dsdb_get_schema(ldb, NULL);
msg->dn = ldb_dn_new(msg, ldb, NULL);
@@ -262,11 +267,11 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
struct ldb_result *res;
int ret;
const char *dns_attrs[] = { "dNSHostName", NULL };
- ret = dsdb_module_search_dn(module, msg, &res, samdb_server_dn(ldb, msg),
+ ret = dsdb_module_search_dn(ac->module, msg, &res, samdb_server_dn(ldb, msg),
dns_attrs,
DSDB_FLAG_NEXT_MODULE |
DSDB_FLAG_AS_SYSTEM,
- req);
+ ac->req);
if (ret == LDB_SUCCESS) {
const char *hostname = ldb_msg_find_attr_as_string(res->msgs[0], "dNSHostName", NULL);
if (hostname != NULL) {
@@ -402,7 +407,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
for (i=0; i<3; i++) {
bool master;
- int ret = dsdb_module_we_are_master(module, dns[i], &master, req);
+ int ret = dsdb_module_we_are_master(ac->module, dns[i], &master, ac->req);
if (ret != LDB_SUCCESS) {
goto failed;
}
@@ -474,7 +479,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
/* TODO: lots more dynamic attributes should be added here */
- edn_control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID);
+ edn_control = ldb_request_get_control(ac->req, LDB_CONTROL_EXTENDED_DN_OID);
/* convert any GUID attributes to be in the right form */
for (i=0; guid_attrs[i]; i++) {
@@ -486,17 +491,17 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
if (!do_attribute(attrs, guid_attrs[i])) continue;
- attr_dn = ldb_msg_find_attr_as_dn(ldb, req, msg, guid_attrs[i]);
+ attr_dn = ldb_msg_find_attr_as_dn(ldb, ac->req, msg, guid_attrs[i]);
if (attr_dn == NULL) {
continue;
}
- ret = dsdb_module_search_dn(module, req, &res,
+ ret = dsdb_module_search_dn(ac->module, ac->req, &res,
attr_dn, no_attrs,
DSDB_FLAG_NEXT_MODULE |
DSDB_FLAG_AS_SYSTEM |
DSDB_SEARCH_SHOW_EXTENDED_DN,
- req);
+ ac->req);
if (ret != LDB_SUCCESS) {
return ldb_operr(ldb);
}
@@ -534,8 +539,8 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
int ret;
for (i=0; dn_attrs[i]; i++) {
if (!do_attribute(attrs, dn_attrs[i])) continue;
- ret = expand_dn_in_message(module, msg, dn_attrs[i],
- edn_control, req);
+ ret = expand_dn_in_message(ac->module, msg, dn_attrs[i],
+ edn_control, ac->req);
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ ": Failed to expand DN in rootDSE for %s\n",
dn_attrs[i]));
@@ -554,11 +559,6 @@ failed:
handle search requests
*/
-struct rootdse_context {
- struct ldb_module *module;
- struct ldb_request *req;
-};
-
static struct rootdse_context *rootdse_init_context(struct ldb_module *module,
struct ldb_request *req)
{
@@ -609,8 +609,7 @@ static int rootdse_callback(struct ldb_request *req, struct ldb_reply *ares)
/* for each record returned post-process to add any dynamic
attributes that have been asked for */
- ret = rootdse_add_dynamic(ac->module, ares->message,
- ac->req->op.search.attrs, ac->req);
+ ret = rootdse_add_dynamic(ac, ares->message);
if (ret != LDB_SUCCESS) {
talloc_free(ares);
return ldb_module_done(ac->req, NULL, NULL, ret);