2005-10-14 16:37:13 +04:00
/*
Unix SMB / CIFS implementation .
WINS Replication server
Copyright ( C ) Stefan Metzmacher 2005
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
2005-10-14 16:37:13 +04: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/>.
2005-10-14 16:37:13 +04:00
*/
# include "includes.h"
2008-10-11 23:31:42 +04:00
# include "../lib/util/dlinklist.h"
2005-10-14 16:37:13 +04:00
# include "smbd/service_task.h"
2006-03-07 15:08:58 +03:00
# include "smbd/service.h"
2005-10-14 16:37:13 +04:00
# include "lib/messaging/irpc.h"
2006-03-16 03:23:11 +03:00
# include "librpc/gen_ndr/winsrepl.h"
2005-10-14 16:38:07 +04:00
# include "wrepl_server/wrepl_server.h"
2005-10-14 16:52:35 +04:00
# include "nbt_server/wins/winsdb.h"
# include "ldb/include/ldb.h"
2005-11-08 03:11:45 +03:00
# include "ldb/include/ldb_errors.h"
2005-12-28 18:38:36 +03:00
# include "auth/auth.h"
2007-11-16 22:12:00 +03:00
# include "ldb_wrap.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2007-12-12 00:23:14 +03:00
# include "lib/socket/netif.h"
2005-10-14 16:37:13 +04:00
2007-12-02 18:20:41 +03:00
static struct ldb_context * wins_config_db_connect ( TALLOC_CTX * mem_ctx ,
2008-12-29 22:24:57 +03:00
struct tevent_context * ev_ctx ,
2007-12-02 18:20:41 +03:00
struct loadparm_context * lp_ctx )
2005-12-17 18:45:38 +03:00
{
2008-04-17 14:23:44 +04:00
return ldb_wrap_connect ( mem_ctx , ev_ctx , lp_ctx , private_path ( mem_ctx ,
2007-12-02 18:20:41 +03:00
lp_ctx , lp_wins_config_url ( lp_ctx ) ) ,
2007-12-03 17:53:28 +03:00
system_session ( mem_ctx , lp_ctx ) , NULL , 0 , NULL ) ;
2005-12-17 18:45:38 +03:00
}
2006-01-03 23:19:39 +03:00
static uint64_t wins_config_db_get_seqnumber ( struct ldb_context * ldb )
{
int ret ;
struct ldb_dn * dn ;
struct ldb_result * res = NULL ;
TALLOC_CTX * tmp_ctx = talloc_new ( ldb ) ;
uint64_t seqnumber = 0 ;
2006-11-22 03:59:34 +03:00
dn = ldb_dn_new ( tmp_ctx , ldb , " @BASEINFO " ) ;
2006-01-03 23:19:39 +03:00
if ( ! dn ) goto failed ;
/* find the record in the WINS database */
2008-09-23 22:30:06 +04:00
ret = ldb_search ( ldb , tmp_ctx , & res , dn , LDB_SCOPE_BASE , NULL , NULL ) ;
2006-01-03 23:19:39 +03:00
if ( ret ! = LDB_SUCCESS ) goto failed ;
if ( res - > count > 1 ) goto failed ;
if ( res - > count = = 1 ) {
2006-08-13 12:00:36 +04:00
seqnumber = ldb_msg_find_attr_as_uint64 ( res - > msgs [ 0 ] , " sequenceNumber " , 0 ) ;
2006-01-03 23:19:39 +03:00
}
failed :
talloc_free ( tmp_ctx ) ;
return seqnumber ;
}
2005-10-14 16:55:41 +04:00
/*
open winsdb
*/
2007-12-02 18:20:41 +03:00
static NTSTATUS wreplsrv_open_winsdb ( struct wreplsrv_service * service ,
struct loadparm_context * lp_ctx )
2005-10-14 16:37:13 +04:00
{
2007-12-12 00:23:14 +03:00
const char * owner = lp_parm_string ( lp_ctx , NULL , " winsdb " , " local_owner " ) ;
if ( owner = = NULL ) {
struct interface * ifaces ;
2007-12-12 00:23:20 +03:00
load_interfaces ( service , lp_interfaces ( lp_ctx ) , & ifaces ) ;
2007-12-12 00:23:14 +03:00
owner = iface_n_ip ( ifaces , 0 ) ;
}
2008-04-17 14:23:44 +04:00
service - > wins_db = winsdb_connect ( service , service - > task - > event_ctx , lp_ctx , owner , WINSDB_HANDLE_CALLER_WREPL ) ;
2005-10-14 16:55:41 +04:00
if ( ! service - > wins_db ) {
return NT_STATUS_INTERNAL_DB_ERROR ;
}
2008-04-17 14:23:44 +04:00
service - > config . ldb = wins_config_db_connect ( service , service - > task - > event_ctx , lp_ctx ) ;
2005-12-17 18:45:38 +03:00
if ( ! service - > config . ldb ) {
return NT_STATUS_INTERNAL_DB_ERROR ;
}
2005-11-23 12:38:44 +03:00
/* the default renew interval is 6 days */
2007-12-02 18:20:41 +03:00
service - > config . renew_interval = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " renew_interval " , 6 * 24 * 60 * 60 ) ;
2005-11-23 12:38:44 +03:00
/* the default tombstone (extinction) interval is 6 days */
2007-12-02 18:20:41 +03:00
service - > config . tombstone_interval = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " tombstone_interval " , 6 * 24 * 60 * 60 ) ;
2005-11-23 12:38:44 +03:00
/* the default tombstone (extinction) timeout is 1 day */
2007-12-02 18:20:41 +03:00
service - > config . tombstone_timeout = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " tombstone_timeout " , 1 * 24 * 60 * 60 ) ;
2005-11-23 12:38:44 +03:00
2005-12-22 14:40:14 +03:00
/* the default tombstone extra timeout is 3 days */
2007-12-02 18:20:41 +03:00
service - > config . tombstone_extra_timeout = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " tombstone_extra_timeout " , 3 * 24 * 60 * 60 ) ;
2005-12-22 14:40:14 +03:00
2005-11-23 12:38:44 +03:00
/* the default verify interval is 24 days */
2007-12-02 18:20:41 +03:00
service - > config . verify_interval = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " verify_interval " , 24 * 24 * 60 * 60 ) ;
2005-11-23 12:38:44 +03:00
2005-12-22 14:40:14 +03:00
/* the default scavenging interval is 'renew_interval/2' */
2007-12-02 18:20:41 +03:00
service - > config . scavenging_interval = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " scavenging_interval " ,
2005-12-22 14:40:14 +03:00
service - > config . renew_interval / 2 ) ;
2005-12-14 13:56:43 +03:00
/* the maximun interval to the next periodic processing event */
2007-12-02 18:20:41 +03:00
service - > config . periodic_interval = lp_parm_int ( lp_ctx , NULL , " wreplsrv " , " periodic_interval " , 15 ) ;
2005-12-14 13:56:43 +03:00
2005-10-14 16:55:41 +04:00
return NT_STATUS_OK ;
2005-10-14 16:37:13 +04:00
}
2005-10-14 16:55:41 +04:00
struct wreplsrv_partner * wreplsrv_find_partner ( struct wreplsrv_service * service , const char * peer_addr )
2005-10-14 16:52:35 +04:00
{
struct wreplsrv_partner * cur ;
for ( cur = service - > partners ; cur ; cur = cur - > next ) {
if ( strcmp ( cur - > address , peer_addr ) = = 0 ) {
return cur ;
}
}
return NULL ;
}
/*
load our replication partners
*/
2006-01-03 23:19:39 +03:00
NTSTATUS wreplsrv_load_partners ( struct wreplsrv_service * service )
2005-10-14 16:52:35 +04:00
{
2006-01-03 23:19:39 +03:00
struct wreplsrv_partner * partner ;
2005-11-08 03:11:45 +03:00
struct ldb_result * res = NULL ;
2005-10-14 16:52:35 +04:00
int ret ;
2007-04-19 21:00:15 +04:00
TALLOC_CTX * tmp_ctx ;
2005-10-14 16:52:35 +04:00
int i ;
2006-01-03 23:19:39 +03:00
uint64_t new_seqnumber ;
new_seqnumber = wins_config_db_get_seqnumber ( service - > config . ldb ) ;
/* if it's not the first run and nothing changed we're done */
if ( service - > config . seqnumber ! = 0 & & service - > config . seqnumber = = new_seqnumber ) {
return NT_STATUS_OK ;
}
2007-04-19 21:00:15 +04:00
tmp_ctx = talloc_new ( service ) ;
NT_STATUS_HAVE_NO_MEMORY ( tmp_ctx ) ;
2006-01-03 23:19:39 +03:00
service - > config . seqnumber = new_seqnumber ;
2005-10-14 16:52:35 +04:00
/* find the record in the WINS database */
2008-09-23 22:30:06 +04:00
ret = ldb_search ( service - > config . ldb , tmp_ctx , & res ,
ldb_dn_new ( tmp_ctx , service - > config . ldb , " CN=PARTNERS " ) ,
LDB_SCOPE_SUBTREE , NULL , " (objectClass=wreplPartner) " ) ;
2005-11-08 03:11:45 +03:00
if ( ret ! = LDB_SUCCESS ) goto failed ;
2006-01-03 23:19:39 +03:00
/* first disable all existing partners */
for ( partner = service - > partners ; partner ; partner = partner - > next ) {
partner - > type = WINSREPL_PARTNER_NONE ;
}
2005-10-14 16:52:35 +04:00
2005-11-08 03:11:45 +03:00
for ( i = 0 ; i < res - > count ; i + + ) {
2006-01-03 23:19:39 +03:00
const char * address ;
2006-08-13 12:00:36 +04:00
address = ldb_msg_find_attr_as_string ( res - > msgs [ i ] , " address " , NULL ) ;
2006-01-03 23:19:39 +03:00
if ( ! address ) {
goto failed ;
}
partner = wreplsrv_find_partner ( service , address ) ;
if ( partner ) {
if ( partner - > name ! = partner - > address ) {
talloc_free ( discard_const ( partner - > name ) ) ;
}
partner - > name = NULL ;
talloc_free ( discard_const ( partner - > our_address ) ) ;
partner - > our_address = NULL ;
2005-10-14 16:52:35 +04:00
2006-01-03 23:19:39 +03:00
/* force rescheduling of pulling */
partner - > pull . next_run = timeval_zero ( ) ;
} else {
partner = talloc_zero ( service , struct wreplsrv_partner ) ;
if ( partner = = NULL ) goto failed ;
partner - > service = service ;
partner - > address = address ;
talloc_steal ( partner , partner - > address ) ;
DLIST_ADD_END ( service - > partners , partner , struct wreplsrv_partner * ) ;
}
2005-10-14 16:52:35 +04:00
2006-08-13 12:00:36 +04:00
partner - > name = ldb_msg_find_attr_as_string ( res - > msgs [ i ] , " name " , partner - > address ) ;
2006-01-03 23:19:39 +03:00
talloc_steal ( partner , partner - > name ) ;
2006-08-13 12:00:36 +04:00
partner - > our_address = ldb_msg_find_attr_as_string ( res - > msgs [ i ] , " ourAddress " , NULL ) ;
2006-01-03 23:19:39 +03:00
talloc_steal ( partner , partner - > our_address ) ;
2006-08-13 12:00:36 +04:00
partner - > type = ldb_msg_find_attr_as_uint ( res - > msgs [ i ] , " type " , WINSREPL_PARTNER_BOTH ) ;
partner - > pull . interval = ldb_msg_find_attr_as_uint ( res - > msgs [ i ] , " pullInterval " ,
2005-11-07 17:34:49 +03:00
WINSREPL_DEFAULT_PULL_INTERVAL ) ;
2006-08-13 12:00:36 +04:00
partner - > pull . retry_interval = ldb_msg_find_attr_as_uint ( res - > msgs [ i ] , " pullRetryInterval " ,
2005-11-07 17:34:49 +03:00
WINSREPL_DEFAULT_PULL_RETRY_INTERVAL ) ;
2006-08-13 12:00:36 +04:00
partner - > push . change_count = ldb_msg_find_attr_as_uint ( res - > msgs [ i ] , " pushChangeCount " ,
2005-11-07 17:34:49 +03:00
WINSREPL_DEFAULT_PUSH_CHANGE_COUNT ) ;
2008-03-26 22:07:10 +03:00
partner - > push . use_inform = ldb_msg_find_attr_as_uint ( res - > msgs [ i ] , " pushUseInform " , true ) ;
2005-10-14 16:52:35 +04:00
2005-12-23 15:42:04 +03:00
DEBUG ( 3 , ( " wreplsrv_load_partners: found partner: %s type: 0x%X \n " ,
partner - > address , partner - > type ) ) ;
2005-10-14 16:52:35 +04:00
}
2006-01-03 23:19:39 +03:00
DEBUG ( 2 , ( " wreplsrv_load_partners: %u partners found: wins_config_db seqnumber %llu \n " ,
2006-09-09 14:05:58 +04:00
res - > count , ( unsigned long long ) service - > config . seqnumber ) ) ;
2005-12-23 15:42:04 +03:00
2005-10-14 16:52:35 +04:00
talloc_free ( tmp_ctx ) ;
return NT_STATUS_OK ;
failed :
talloc_free ( tmp_ctx ) ;
return NT_STATUS_FOOBAR ;
}
2005-10-14 18:02:47 +04:00
NTSTATUS wreplsrv_fill_wrepl_table ( struct wreplsrv_service * service ,
TALLOC_CTX * mem_ctx ,
struct wrepl_table * table_out ,
const char * initiator ,
2007-10-07 01:48:28 +04:00
bool full_table )
2005-10-14 18:02:47 +04:00
{
struct wreplsrv_owner * cur ;
uint32_t i = 0 ;
table_out - > partner_count = 0 ;
table_out - > partners = NULL ;
table_out - > initiator = initiator ;
2006-01-02 20:19:09 +03:00
for ( cur = service - > table ; cur ; cur = cur - > next ) {
if ( full_table ) {
table_out - > partner_count + + ;
continue ;
}
if ( strcmp ( initiator , cur - > owner . address ) ! = 0 ) continue ;
2005-10-14 18:02:47 +04:00
table_out - > partner_count + + ;
2006-01-02 20:19:09 +03:00
break ;
2005-10-14 18:02:47 +04:00
}
table_out - > partners = talloc_array ( mem_ctx , struct wrepl_wins_owner , table_out - > partner_count ) ;
NT_STATUS_HAVE_NO_MEMORY ( table_out - > partners ) ;
2006-01-02 20:19:09 +03:00
for ( cur = service - > table ; cur & & i < table_out - > partner_count ; cur = cur - > next ) {
2006-01-19 19:34:05 +03:00
/*
* if it ' s our local entry
* update the max version
*/
if ( cur = = service - > owner ) {
cur - > owner . max_version = winsdb_get_maxVersion ( service - > wins_db ) ;
}
2006-01-02 20:19:09 +03:00
if ( full_table ) {
table_out - > partners [ i ] = cur - > owner ;
i + + ;
continue ;
}
if ( strcmp ( initiator , cur - > owner . address ) ! = 0 ) continue ;
2005-10-14 18:02:47 +04:00
table_out - > partners [ i ] = cur - > owner ;
i + + ;
2006-01-02 20:19:09 +03:00
break ;
2005-10-14 18:02:47 +04:00
}
return NT_STATUS_OK ;
}
2006-01-02 20:19:09 +03:00
struct wreplsrv_owner * wreplsrv_find_owner ( struct wreplsrv_service * service ,
struct wreplsrv_owner * table ,
const char * wins_owner )
2005-10-14 16:52:35 +04:00
{
struct wreplsrv_owner * cur ;
for ( cur = table ; cur ; cur = cur - > next ) {
if ( strcmp ( cur - > owner . address , wins_owner ) = = 0 ) {
2006-01-02 20:19:09 +03:00
/*
* if it ' s our local entry
* update the max version
*/
if ( cur = = service - > owner ) {
cur - > owner . max_version = winsdb_get_maxVersion ( service - > wins_db ) ;
}
2005-10-14 16:52:35 +04:00
return cur ;
}
}
return NULL ;
}
/*
update the wins_owner_table max_version , if the given version is the highest version
if no entry for the wins_owner exists yet , create one
*/
2005-10-14 18:02:47 +04:00
NTSTATUS wreplsrv_add_table ( struct wreplsrv_service * service ,
TALLOC_CTX * mem_ctx , struct wreplsrv_owner * * _table ,
const char * wins_owner , uint64_t version )
2005-10-14 16:52:35 +04:00
{
struct wreplsrv_owner * table = * _table ;
struct wreplsrv_owner * cur ;
2006-01-02 20:19:09 +03:00
if ( ! wins_owner | | strcmp ( wins_owner , " 0.0.0.0 " ) = = 0 ) {
wins_owner = service - > wins_db - > local_owner ;
2005-10-14 16:52:35 +04:00
}
2006-01-02 20:19:09 +03:00
cur = wreplsrv_find_owner ( service , table , wins_owner ) ;
2005-10-14 16:52:35 +04:00
/* if it doesn't exists yet, create one */
if ( ! cur ) {
cur = talloc_zero ( mem_ctx , struct wreplsrv_owner ) ;
NT_STATUS_HAVE_NO_MEMORY ( cur ) ;
cur - > owner . address = talloc_strdup ( cur , wins_owner ) ;
NT_STATUS_HAVE_NO_MEMORY ( cur - > owner . address ) ;
cur - > owner . min_version = 0 ;
cur - > owner . max_version = 0 ;
cur - > owner . type = 1 ; /* don't know why this is always 1 */
cur - > partner = wreplsrv_find_partner ( service , wins_owner ) ;
2006-01-02 20:19:09 +03:00
DLIST_ADD_END ( table , cur , struct wreplsrv_owner * ) ;
2005-10-14 16:52:35 +04:00
* _table = table ;
}
/* the min_version is always 0 here, and won't be updated */
2006-06-08 19:20:05 +04:00
/* if the given version is higher than the current max_version, update */
2005-10-14 16:52:35 +04:00
if ( cur - > owner . max_version < version ) {
cur - > owner . max_version = version ;
2006-01-02 20:19:09 +03:00
/* if it's for our local db, we need to update the wins.ldb too */
if ( cur = = service - > owner ) {
uint64_t ret ;
ret = winsdb_set_maxVersion ( service - > wins_db , cur - > owner . max_version ) ;
if ( ret ! = cur - > owner . max_version ) {
DEBUG ( 0 , ( " winsdb_set_maxVersion(%llu) failed: %llu \n " ,
2006-09-09 14:05:58 +04:00
( unsigned long long ) cur - > owner . max_version ,
( unsigned long long ) ret ) ) ;
2006-01-02 20:19:09 +03:00
return NT_STATUS_INTERNAL_DB_CORRUPTION ;
}
}
2005-10-14 16:52:35 +04:00
}
return NT_STATUS_OK ;
}
/*
load the partner table
*/
static NTSTATUS wreplsrv_load_table ( struct wreplsrv_service * service )
{
2005-11-08 03:11:45 +03:00
struct ldb_result * res = NULL ;
2005-10-14 16:52:35 +04:00
int ret ;
NTSTATUS status ;
TALLOC_CTX * tmp_ctx = talloc_new ( service ) ;
2005-12-30 23:08:52 +03:00
struct ldb_context * ldb = service - > wins_db - > ldb ;
2005-10-14 16:52:35 +04:00
int i ;
2006-01-02 20:19:09 +03:00
struct wreplsrv_owner * local_owner ;
2005-10-14 16:52:35 +04:00
const char * wins_owner ;
uint64_t version ;
const char * const attrs [ ] = {
" winsOwner " ,
2005-10-14 16:55:59 +04:00
" versionID " ,
2005-10-14 16:52:35 +04:00
NULL
} ;
2006-01-02 20:19:09 +03:00
/*
* make sure we have our local entry in the list ,
* but we set service - > owner when we ' re done
* to avoid to many calls to wreplsrv_local_max_version ( )
*/
status = wreplsrv_add_table ( service ,
service , & service - > table ,
service - > wins_db - > local_owner , 0 ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) goto failed ;
local_owner = wreplsrv_find_owner ( service , service - > table , service - > wins_db - > local_owner ) ;
if ( ! local_owner ) {
status = NT_STATUS_INTERNAL_ERROR ;
goto failed ;
}
2005-10-14 16:52:35 +04:00
/* find the record in the WINS database */
2008-09-23 22:30:06 +04:00
ret = ldb_search ( ldb , tmp_ctx , & res , NULL , LDB_SCOPE_SUBTREE ,
attrs , " (objectClass=winsRecord) " ) ;
2005-10-14 16:52:35 +04:00
status = NT_STATUS_INTERNAL_DB_CORRUPTION ;
2005-11-08 03:11:45 +03:00
if ( ret ! = LDB_SUCCESS ) goto failed ;
2005-10-14 16:52:35 +04:00
2005-11-08 03:11:45 +03:00
for ( i = 0 ; i < res - > count ; i + + ) {
2006-08-13 12:00:36 +04:00
wins_owner = ldb_msg_find_attr_as_string ( res - > msgs [ i ] , " winsOwner " , NULL ) ;
version = ldb_msg_find_attr_as_uint64 ( res - > msgs [ i ] , " versionID " , 0 ) ;
2005-10-14 16:52:35 +04:00
2006-01-02 20:19:09 +03:00
status = wreplsrv_add_table ( service ,
service , & service - > table ,
wins_owner , version ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) goto failed ;
2005-11-08 03:11:45 +03:00
talloc_free ( res - > msgs [ i ] ) ;
2005-10-14 16:52:35 +04:00
}
2006-01-03 23:19:39 +03:00
2006-01-02 20:19:09 +03:00
/*
* this makes sure we call wreplsrv_local_max_version ( ) before returning in
* wreplsrv_find_owner ( )
*/
service - > owner = local_owner ;
/*
* this makes sure the maxVersion in the database is updated ,
* with the highest version we found , if this is higher than the current stored one
*/
status = wreplsrv_add_table ( service ,
service , & service - > table ,
service - > wins_db - > local_owner , local_owner - > owner . max_version ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) goto failed ;
2005-10-14 16:52:35 +04:00
talloc_free ( tmp_ctx ) ;
return NT_STATUS_OK ;
failed :
talloc_free ( tmp_ctx ) ;
return status ;
}
2005-10-14 16:48:20 +04:00
/*
setup our replication partners
*/
static NTSTATUS wreplsrv_setup_partners ( struct wreplsrv_service * service )
{
2005-10-14 16:52:35 +04:00
NTSTATUS status ;
status = wreplsrv_load_partners ( service ) ;
NT_STATUS_NOT_OK_RETURN ( status ) ;
status = wreplsrv_load_table ( service ) ;
NT_STATUS_NOT_OK_RETURN ( status ) ;
2005-10-14 16:48:20 +04:00
return NT_STATUS_OK ;
}
2005-10-14 16:37:13 +04:00
/*
startup the wrepl task
*/
static void wreplsrv_task_init ( struct task_server * task )
{
NTSTATUS status ;
struct wreplsrv_service * service ;
2008-02-04 13:58:29 +03:00
if ( ! lp_wins_support ( task - > lp_ctx ) ) {
return ;
}
2006-03-09 20:48:41 +03:00
task_server_set_title ( task , " task[wreplsrv] " ) ;
2005-10-14 16:37:13 +04:00
service = talloc_zero ( task , struct wreplsrv_service ) ;
if ( ! service ) {
task_server_terminate ( task , " wreplsrv_task_init: out of memory " ) ;
return ;
}
2005-12-22 14:40:14 +03:00
service - > task = task ;
service - > startup_time = timeval_current ( ) ;
task - > private = service ;
2005-10-14 16:37:13 +04:00
/*
2005-10-14 16:48:20 +04:00
* setup up all partners , and open the winsdb
2005-10-14 16:37:13 +04:00
*/
2007-12-02 19:09:52 +03:00
status = wreplsrv_open_winsdb ( service , task - > lp_ctx ) ;
2005-10-14 16:48:20 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
task_server_terminate ( task , " wreplsrv_task_init: wreplsrv_open_winsdb() failed " ) ;
return ;
}
/*
* setup timed events for each partner we want to pull from
*/
status = wreplsrv_setup_partners ( service ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
task_server_terminate ( task , " wreplsrv_task_init: wreplsrv_setup_partners() failed " ) ;
return ;
}
2005-10-14 16:37:13 +04:00
/*
* setup listen sockets , so we can anwser requests from our partners ,
* which pull from us
*/
2007-12-02 21:27:49 +03:00
status = wreplsrv_setup_sockets ( service , task - > lp_ctx ) ;
2005-10-14 16:37:13 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
task_server_terminate ( task , " wreplsrv_task_init: wreplsrv_setup_sockets() failed " ) ;
return ;
}
2005-12-14 13:56:43 +03:00
status = wreplsrv_setup_periodic ( service ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
task_server_terminate ( task , " wreplsrv_task_init: wreplsrv_setup_periodic() failed " ) ;
return ;
}
2005-10-14 16:37:13 +04:00
irpc_add_name ( task - > msg_ctx , " wrepl_server " ) ;
}
/*
register ourselves as a available server
*/
NTSTATUS server_service_wrepl_init ( void )
{
2008-02-04 13:58:29 +03:00
return register_server_service ( " wrepl " , wreplsrv_task_init ) ;
2005-10-14 16:37:13 +04:00
}