LCOV - code coverage report
Current view: top level - source4/cluster - local.c (source / functions) Hit Total Coverage
Test: coverage report for master 469b22b8 Lines: 23 29 79.3 %
Date: 2024-06-10 12:05:21 Functions: 3 6 50.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    local (dummy) clustering operations
       5             : 
       6             :    Copyright (C) Andrew Tridgell 2006
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "cluster/cluster.h"
      24             : #include "cluster/cluster_private.h"
      25             : #include "dbwrap/dbwrap.h"
      26             : #include "system/filesys.h"
      27             : #include "param/param.h"
      28             : #include "librpc/gen_ndr/server_id.h"
      29             : 
      30             : /*
      31             :   server a server_id for the local node
      32             : */
      33      144534 : static struct server_id local_id(struct cluster_ops *ops, uint64_t pid, uint32_t task_id)
      34             : {
      35       17600 :         struct server_id server_id;
      36      144534 :         ZERO_STRUCT(server_id);
      37      144534 :         server_id.pid = pid;
      38      144534 :         server_id.task_id = task_id;
      39      144534 :         server_id.vnn = NONCLUSTER_VNN;
      40             :         /* This is because we are not in the s3 serverid database */
      41      144534 :         server_id.unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY;
      42      144534 :         return server_id;
      43             : }
      44             : 
      45             : 
      46             : /*
      47             :   open a tmp tdb for the local node. By using smbd_tmp_path() we don't need
      48             :   TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup
      49             : */
      50      110378 : static struct db_context *local_db_tmp_open(struct cluster_ops *ops,
      51             :                                             TALLOC_CTX *mem_ctx,
      52             :                                             struct loadparm_context *lp_ctx,
      53             :                                             const char *dbbase, int flags)
      54             : {
      55      110378 :         TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
      56        5188 :         char *path, *dbname;
      57        5188 :         struct db_context *db;
      58        5188 :         int hash_size, tdb_flags;
      59             : 
      60      110378 :         dbname = talloc_asprintf(mem_ctx, "%s.tdb", dbbase);
      61             : 
      62      110378 :         path = smbd_tmp_path(tmp_ctx, lp_ctx, dbname);
      63             : 
      64      110378 :         hash_size = lpcfg_tdb_hash_size(lp_ctx, path);
      65      110378 :         tdb_flags = lpcfg_tdb_flags(lp_ctx, flags);
      66             : 
      67      110378 :         db = dbwrap_local_open(
      68             :                 mem_ctx,
      69             :                 path,
      70             :                 hash_size,
      71             :                 tdb_flags,
      72             :                 O_RDWR|O_CREAT,
      73             :                 0600,
      74             :                 DBWRAP_LOCK_ORDER_NONE,
      75             :                 DBWRAP_FLAG_NONE);
      76      110378 :         talloc_free(tmp_ctx);
      77      110378 :         return db;
      78             : }
      79             : 
      80             : /*
      81             :   dummy backend handle function
      82             : */
      83           0 : static void *local_backend_handle(struct cluster_ops *ops)
      84             : {
      85           0 :         return NULL;
      86             : }
      87             : 
      88             : /*
      89             :   dummy message init function - not needed as all messages are local
      90             : */
      91           0 : static NTSTATUS local_message_init(struct cluster_ops *ops,
      92             :                                    struct imessaging_context *msg,
      93             :                                    struct server_id server,
      94             :                                    cluster_message_fn_t handler)
      95             : {
      96           0 :         return NT_STATUS_OK;
      97             : }
      98             : 
      99             : /*
     100             :   dummy message send
     101             : */
     102           0 : static NTSTATUS local_message_send(struct cluster_ops *ops,
     103             :                                    struct server_id server, DATA_BLOB *data)
     104             : {
     105           0 :         return NT_STATUS_INVALID_DEVICE_REQUEST;
     106             : }
     107             : 
     108             : static struct cluster_ops cluster_local_ops = {
     109             :         .cluster_id           = local_id,
     110             :         .cluster_db_tmp_open  = local_db_tmp_open,
     111             :         .backend_handle       = local_backend_handle,
     112             :         .message_init         = local_message_init,
     113             :         .message_send         = local_message_send,
     114             :         .private_data         = NULL
     115             : };
     116             : 
     117        1359 : void cluster_local_init(void)
     118             : {
     119        1359 :         cluster_set_ops(&cluster_local_ops);
     120        1359 : }
     121             : 

Generated by: LCOV version 1.14