r25446: Merge some changes I made on the way home from SFO:
[jelmer/samba4-debian.git] / source / wrepl_server / wrepl_server.c
index 55ab76c2289b63dd13c68e1af4eb31dbb6700ca9..f4b48ae916edab1024e806df4cdb342fa8a457aa 100644 (file)
@@ -7,7 +7,7 @@
    
    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
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
 #include "ldb/include/ldb_errors.h"
 #include "auth/auth.h"
 #include "db_wrap.h"
+#include "param/param.h"
 
 static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx)
 {
-       return ldb_wrap_connect(mem_ctx, private_path(mem_ctx, lp_wins_config_url()),
+       return ldb_wrap_connect(mem_ctx, global_loadparm, private_path(mem_ctx, 
+                               global_loadparm, 
+                               lp_wins_config_url(global_loadparm)),
                                system_session(mem_ctx), NULL, 0, NULL);
 }
 
@@ -47,7 +49,7 @@ static uint64_t wins_config_db_get_seqnumber(struct ldb_context *ldb)
        TALLOC_CTX *tmp_ctx = talloc_new(ldb);
        uint64_t seqnumber = 0;
 
-       dn = ldb_dn_explode(tmp_ctx, "@BASEINFO");
+       dn = ldb_dn_new(tmp_ctx, ldb, "@BASEINFO");
        if (!dn) goto failed;
 
        /* find the record in the WINS database */
@@ -82,26 +84,26 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service)
        }
 
        /* the default renew interval is 6 days */
-       service->config.renew_interval    = lp_parm_int(-1,"wreplsrv","renew_interval", 6*24*60*60);
+       service->config.renew_interval    = lp_parm_int(global_loadparm, NULL,"wreplsrv","renew_interval", 6*24*60*60);
 
        /* the default tombstone (extinction) interval is 6 days */
-       service->config.tombstone_interval= lp_parm_int(-1,"wreplsrv","tombstone_interval", 6*24*60*60);
+       service->config.tombstone_interval= lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_interval", 6*24*60*60);
 
        /* the default tombstone (extinction) timeout is 1 day */
-       service->config.tombstone_timeout = lp_parm_int(-1,"wreplsrv","tombstone_timeout", 1*24*60*60);
+       service->config.tombstone_timeout = lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_timeout", 1*24*60*60);
 
        /* the default tombstone extra timeout is 3 days */
-       service->config.tombstone_extra_timeout = lp_parm_int(-1,"wreplsrv","tombstone_extra_timeout", 3*24*60*60);
+       service->config.tombstone_extra_timeout = lp_parm_int(global_loadparm, NULL,"wreplsrv","tombstone_extra_timeout", 3*24*60*60);
 
        /* the default verify interval is 24 days */
-       service->config.verify_interval   = lp_parm_int(-1,"wreplsrv","verify_interval", 24*24*60*60);
+       service->config.verify_interval   = lp_parm_int(global_loadparm, NULL,"wreplsrv","verify_interval", 24*24*60*60);
 
        /* the default scavenging interval is 'renew_interval/2' */
-       service->config.scavenging_interval=lp_parm_int(-1,"wreplsrv","scavenging_interval",
+       service->config.scavenging_interval=lp_parm_int(global_loadparm, NULL,"wreplsrv","scavenging_interval",
                                                        service->config.renew_interval/2);
 
        /* the maximun interval to the next periodic processing event */
-       service->config.periodic_interval = lp_parm_int(-1,"wreplsrv","periodic_interval", 15);
+       service->config.periodic_interval = lp_parm_int(global_loadparm, NULL,"wreplsrv","periodic_interval", 15);
 
        return NT_STATUS_OK;
 }
@@ -127,7 +129,7 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
        struct wreplsrv_partner *partner;
        struct ldb_result *res = NULL;
        int ret;
-       TALLOC_CTX *tmp_ctx = talloc_new(service);
+       TALLOC_CTX *tmp_ctx;
        int i;
        uint64_t new_seqnumber;
 
@@ -138,10 +140,13 @@ NTSTATUS wreplsrv_load_partners(struct wreplsrv_service *service)
                return NT_STATUS_OK;
        }
 
+       tmp_ctx = talloc_new(service);
+       NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
        service->config.seqnumber = new_seqnumber;
 
        /* find the record in the WINS database */
-       ret = ldb_search(service->config.ldb, ldb_dn_explode(tmp_ctx, "CN=PARTNERS"), LDB_SCOPE_SUBTREE,
+       ret = ldb_search(service->config.ldb, ldb_dn_new(tmp_ctx, service->config.ldb, "CN=PARTNERS"), LDB_SCOPE_SUBTREE,
                         "(objectClass=wreplPartner)", NULL, &res);
        if (ret != LDB_SUCCESS) goto failed;
        talloc_steal(tmp_ctx, res);
@@ -491,7 +496,7 @@ static void wreplsrv_task_init(struct task_server *task)
  */
 static NTSTATUS wreplsrv_init(struct event_context *event_ctx, const struct model_ops *model_ops)
 {
-       if (!lp_wins_support()) {
+       if (!lp_wins_support(global_loadparm)) {
                return NT_STATUS_OK;
        }