LCOV - code coverage report
Current view: top level - source4/dsdb/samdb/ldb_modules - lazy_commit.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 9 41 22.0 %
Date: 2024-02-28 12:06:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* 
       2             :    ldb database library
       3             : 
       4             :    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
       5             : 
       6             :    This program is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU General Public License as published by
       8             :    the Free Software Foundation; either version 3 of the License, or
       9             :    (at your option) any later version.
      10             :    
      11             :    This program is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU General Public License for more details.
      15             :    
      16             :    You should have received a copy of the GNU General Public License
      17             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18             : */
      19             : 
      20             : /*
      21             :  *  Name: ldb
      22             :  *
      23             :  *  Component: ldb lazy_commit module
      24             :  *
      25             :  *  Description: module to pretend to support the 'lazy commit' control
      26             :  *
      27             :  *  Author: Andrew Bartlett
      28             :  */
      29             : 
      30             : #include "includes.h"
      31             : #include "ldb_module.h"
      32             : #include "dsdb/samdb/ldb_modules/util.h"
      33             : 
      34    22515502 : static int unlazy_op(struct ldb_module *module, struct ldb_request *req)
      35             : {
      36     1346344 :         int ret;
      37     1346344 :         struct ldb_request *new_req;
      38    22515502 :         struct ldb_control *control = ldb_request_get_control(req, LDB_CONTROL_SERVER_LAZY_COMMIT);
      39    22515502 :         if (!control) {
      40    22515502 :                 return ldb_next_request(module, req);
      41             :         } 
      42             :         
      43           0 :         switch (req->operation) {
      44           0 :         case LDB_SEARCH:
      45           0 :                 ret = ldb_build_search_req_ex(&new_req, ldb_module_get_ctx(module),
      46             :                                               req,
      47             :                                               req->op.search.base,
      48             :                                               req->op.search.scope,
      49             :                                               req->op.search.tree,
      50             :                                               req->op.search.attrs,
      51             :                                               req->controls,
      52             :                                               req, dsdb_next_callback,
      53             :                                               req);
      54           0 :                 LDB_REQ_SET_LOCATION(new_req);
      55           0 :                 break;
      56           0 :         case LDB_ADD:
      57           0 :                 ret = ldb_build_add_req(&new_req, ldb_module_get_ctx(module), req,
      58             :                                         req->op.add.message,
      59             :                                         req->controls,
      60             :                                         req, dsdb_next_callback,
      61             :                                         req);
      62           0 :                 LDB_REQ_SET_LOCATION(new_req);
      63           0 :                 break;
      64           0 :         case LDB_MODIFY:
      65           0 :                 ret = ldb_build_mod_req(&new_req, ldb_module_get_ctx(module), req,
      66             :                                         req->op.mod.message,
      67             :                                         req->controls,
      68             :                                         req, dsdb_next_callback,
      69             :                                         req);
      70           0 :                 LDB_REQ_SET_LOCATION(new_req);
      71           0 :                 break;
      72           0 :         case LDB_DELETE:
      73           0 :                 ret = ldb_build_del_req(&new_req, ldb_module_get_ctx(module), req,
      74             :                                         req->op.del.dn,
      75             :                                         req->controls,
      76             :                                         req, dsdb_next_callback,
      77             :                                         req);
      78           0 :                 LDB_REQ_SET_LOCATION(new_req);
      79           0 :                 break;
      80           0 :         case LDB_RENAME:
      81           0 :                 ret = ldb_build_rename_req(&new_req, ldb_module_get_ctx(module), req,
      82             :                                            req->op.rename.olddn,
      83             :                                            req->op.rename.newdn,
      84             :                                            req->controls,
      85             :                                            req, dsdb_next_callback,
      86             :                                            req);
      87           0 :                 LDB_REQ_SET_LOCATION(new_req);
      88           0 :                 break;
      89           0 :         case LDB_EXTENDED:
      90           0 :                 ret = ldb_build_extended_req(&new_req, ldb_module_get_ctx(module),
      91             :                                              req,
      92             :                                              req->op.extended.oid,
      93             :                                              req->op.extended.data,
      94             :                                              req->controls,
      95             :                                              req, dsdb_next_callback,
      96             :                                              req);
      97           0 :                 LDB_REQ_SET_LOCATION(new_req);
      98           0 :                 break;
      99           0 :         default:
     100           0 :                 ldb_set_errstring(ldb_module_get_ctx(module),
     101             :                                   "Unsupported request type!");
     102           0 :                 ret = LDB_ERR_UNWILLING_TO_PERFORM;
     103             :         }
     104             : 
     105           0 :         if (ret != LDB_SUCCESS) {
     106           0 :                 return ret;
     107             :         }
     108             : 
     109           0 :         control->critical = 0;
     110           0 :         return ldb_next_request(module, new_req);
     111             : }
     112             : 
     113             : static const struct ldb_module_ops ldb_lazy_commit_module_ops = {
     114             :         .name              = "lazy_commit",
     115             :         .search            = unlazy_op,
     116             :         .add               = unlazy_op,
     117             :         .modify            = unlazy_op,
     118             :         .del               = unlazy_op,
     119             :         .rename            = unlazy_op,
     120             :         .request           = unlazy_op,
     121             :         .extended          = unlazy_op,
     122             : };
     123             : 
     124        5922 : int ldb_lazy_commit_module_init(const char *version)
     125             : {
     126        5922 :         LDB_MODULE_CHECK_VERSION(version);
     127        5922 :         return ldb_register_module(&ldb_lazy_commit_module_ops);
     128             : }

Generated by: LCOV version 1.14