2007-01-19 06:54:01 +03:00
/*
Unix SMB / CIFS implementation .
local ( dummy ) clustering operations
Copyright ( C ) Andrew Tridgell 2006
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2007-01-19 06:54:01 +03:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2007-01-19 06:54:01 +03:00
*/
# include "includes.h"
# include "cluster/cluster.h"
# include "cluster/cluster_private.h"
2013-04-11 11:42:15 +04:00
# include "dbwrap/dbwrap.h"
2007-01-20 03:48:31 +03:00
# include "system/filesys.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2011-05-02 04:55:20 +04:00
# include "librpc/gen_ndr/server_id.h"
2007-01-19 06:54:01 +03:00
/*
server a server_id for the local node
*/
2011-05-08 20:28:17 +04:00
static struct server_id local_id ( struct cluster_ops * ops , uint64_t pid , uint32_t task_id )
2007-01-19 06:54:01 +03:00
{
struct server_id server_id ;
ZERO_STRUCT ( server_id ) ;
2011-05-02 04:05:46 +04:00
server_id . pid = pid ;
2011-05-08 20:28:17 +04:00
server_id . task_id = task_id ;
2012-04-30 09:44:01 +04:00
server_id . vnn = NONCLUSTER_VNN ;
/* This is because we are not in the s3 serverid database */
server_id . unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY ;
2007-01-19 06:54:01 +03:00
return server_id ;
}
2007-01-20 03:48:31 +03:00
/*
open a tmp tdb for the local node . By using smbd_tmp_path ( ) we don ' t need
TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup
*/
2013-04-11 11:42:15 +04:00
static struct db_context * local_db_tmp_open ( struct cluster_ops * ops ,
TALLOC_CTX * mem_ctx ,
struct loadparm_context * lp_ctx ,
const char * dbbase , int flags )
2007-01-20 03:48:31 +03:00
{
2013-04-11 11:42:15 +04:00
TALLOC_CTX * tmp_ctx = talloc_new ( mem_ctx ) ;
char * path , * dbname ;
struct db_context * db ;
2018-04-17 17:26:27 +03:00
int hash_size , tdb_flags ;
2013-04-11 11:42:15 +04:00
2015-03-12 15:39:37 +03:00
dbname = talloc_asprintf ( mem_ctx , " %s.tdb " , dbbase ) ;
2013-04-11 11:42:15 +04:00
path = smbd_tmp_path ( tmp_ctx , lp_ctx , dbname ) ;
2018-04-17 17:25:19 +03:00
hash_size = lpcfg_tdb_hash_size ( lp_ctx , path ) ;
2018-04-17 17:26:27 +03:00
tdb_flags = lpcfg_tdb_flags ( lp_ctx , flags ) ;
2018-04-17 17:25:19 +03:00
db = dbwrap_local_open (
mem_ctx ,
path ,
hash_size ,
2018-04-17 17:26:27 +03:00
tdb_flags ,
2018-04-17 17:25:19 +03:00
O_RDWR | O_CREAT ,
0600 ,
DBWRAP_LOCK_ORDER_NONE ,
DBWRAP_FLAG_NONE ) ;
2013-04-11 11:42:15 +04:00
talloc_free ( tmp_ctx ) ;
return db ;
2007-01-20 03:48:31 +03:00
}
2007-02-08 03:58:17 +03:00
/*
dummy backend handle function
*/
static void * local_backend_handle ( struct cluster_ops * ops )
{
return NULL ;
}
/*
dummy message init function - not needed as all messages are local
*/
static NTSTATUS local_message_init ( struct cluster_ops * ops ,
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg ,
2007-02-08 03:58:17 +03:00
struct server_id server ,
cluster_message_fn_t handler )
{
return NT_STATUS_OK ;
}
/*
dummy message send
*/
static NTSTATUS local_message_send ( struct cluster_ops * ops ,
2007-02-09 04:52:13 +03:00
struct server_id server , DATA_BLOB * data )
2007-02-08 03:58:17 +03:00
{
return NT_STATUS_INVALID_DEVICE_REQUEST ;
}
2007-01-19 06:54:01 +03:00
static struct cluster_ops cluster_local_ops = {
2007-01-20 03:48:31 +03:00
. cluster_id = local_id ,
2013-04-11 11:42:15 +04:00
. cluster_db_tmp_open = local_db_tmp_open ,
2007-02-08 03:58:17 +03:00
. backend_handle = local_backend_handle ,
. message_init = local_message_init ,
. message_send = local_message_send ,
2009-02-02 11:36:58 +03:00
. private_data = NULL
2007-01-19 06:54:01 +03:00
} ;
void cluster_local_init ( void )
{
cluster_set_ops ( & cluster_local_ops ) ;
}