s4-loadparm: 2nd half of lp_ to lpcfg_ conversion
[ira/wip.git] / source4 / dsdb / samdb / ldb_modules / kludge_acl.c
index cc29d26cf03a12a71f68028fbd3035979571c200..e6f288d01cc190ccb942be84d986b361d324f7a0 100644 (file)
@@ -56,7 +56,7 @@ static enum security_user_level what_is_user(struct ldb_module *module)
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct auth_session_info *session_info
                = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo");
-       return security_session_user_level(session_info);
+       return security_session_user_level(session_info, NULL);
 }
 
 static const char *user_name(TALLOC_CTX *mem_ctx, struct ldb_module *module) 
@@ -94,10 +94,12 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess
 {
        struct ldb_message_element *oc_el;
        struct ldb_message_element *allowedAttributes;
-       const struct dsdb_schema *schema = dsdb_get_schema(ldb);
+       /* We need to ensure that the strings returned are valid for as long as the msg is valid */
+       const struct dsdb_schema *schema = dsdb_get_schema(ldb, msg);
        TALLOC_CTX *mem_ctx;
        const char **attr_list;
-       int i, ret;
+       unsigned int i;
+       int ret;
 
        /* If we don't have a schema yet, we can't do anything... */
        if (schema == NULL) {
@@ -113,8 +115,7 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess
        
        mem_ctx = talloc_new(msg);
        if (!mem_ctx) {
-               ldb_oom(ldb);
-               return LDB_ERR_OPERATIONS_ERROR;
+               return ldb_oom(ldb);
        }
 
        /* To ensure that oc_el is valid, we must look for it after 
@@ -142,9 +143,12 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message *
 {
        struct ldb_message_element *oc_el;
        struct ldb_message_element *allowedClasses;
-       const struct dsdb_schema *schema = dsdb_get_schema(ldb);
+
+       /* We need to ensure that the strings returned are valid for as long as the msg is valid */
+       const struct dsdb_schema *schema = dsdb_get_schema(ldb, msg);
        const struct dsdb_class *sclass;
-       int i, j, ret;
+       unsigned int i, j;
+       int ret;
 
        /* If we don't have a schema yet, we can't do anything... */
        if (schema == NULL) {
@@ -199,7 +203,8 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares)
        struct ldb_context *ldb;
        struct kludge_acl_context *ac;
        struct kludge_private_data *data;
-       int i, ret;
+       unsigned int i;
+       int ret;
 
        ac = talloc_get_type(req->context, struct kludge_acl_context);
        data = talloc_get_type(ldb_module_get_private(ac->module), struct kludge_private_data);
@@ -310,14 +315,14 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req)
        struct ldb_request *down_req;
        struct kludge_private_data *data;
        const char * const *attrs;
-       int ret, i;
+       int ret;
+       unsigned int i;
 
        ldb = ldb_module_get_ctx(module);
 
        ac = talloc(req, struct kludge_acl_context);
        if (ac == NULL) {
-               ldb_oom(ldb);
-               return LDB_ERR_OPERATIONS_ERROR;
+               return ldb_oom(ldb);
        }
 
        data = talloc_get_type(ldb_module_get_private(module), struct kludge_private_data);
@@ -436,7 +441,8 @@ static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *re
 static int kludge_acl_init(struct ldb_module *module)
 {
        struct ldb_context *ldb;
-       int ret, i;
+       int ret;
+       unsigned int i;
        TALLOC_CTX *mem_ctx = talloc_new(module);
        static const char *attrs[] = { "passwordAttribute", NULL };
        struct ldb_result *res;
@@ -449,18 +455,16 @@ static int kludge_acl_init(struct ldb_module *module)
 
        data = talloc(module, struct kludge_private_data);
        if (data == NULL) {
-               ldb_oom(ldb);
-               return LDB_ERR_OPERATIONS_ERROR;
+               return ldb_oom(ldb);
        }
 
        data->password_attrs = NULL;
-       data->acl_perform = lp_parm_bool(ldb_get_opaque(ldb, "loadparm"),
+       data->acl_perform = lpcfg_parm_bool(ldb_get_opaque(ldb, "loadparm"),
                                         NULL, "acl", "perform", false);
        ldb_module_set_private(module, data);
 
        if (!mem_ctx) {
-               ldb_oom(ldb);
-               return LDB_ERR_OPERATIONS_ERROR;
+               return ldb_oom(ldb);
        }
 
        ret = ldb_search(ldb, mem_ctx, &res,
@@ -487,8 +491,7 @@ static int kludge_acl_init(struct ldb_module *module)
        data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1);
        if (!data->password_attrs) {
                talloc_free(mem_ctx);
-               ldb_oom(ldb);
-               return LDB_ERR_OPERATIONS_ERROR;
+               return ldb_oom(ldb);
        }
        for (i=0; i < password_attributes->num_values; i++) {
                data->password_attrs[i] = (const char *)password_attributes->values[i].data;