s4: popt: Global replace of cmdline_credentials -> popt_get_cmdline_credentials().
[gd/samba-autobuild/.git] / source4 / torture / libnetapi / libnetapi.c
index 3476f1d7b9a77c8bd4ab232d44bd5159f3827a28..dc48caf60318966b352c65e35db5b8997450e12b 100644 (file)
@@ -31,10 +31,12 @@ bool torture_libnetapi_init_context(struct torture_context *tctx,
 {
        NET_API_STATUS status;
        struct libnetapi_ctx *ctx;
+       TALLOC_CTX *frame = talloc_stackframe();
 
-       if (!lp_load(lpcfg_configfile(tctx->lp_ctx), true, false, false, true)) {
+       if (!lp_load_global(lpcfg_configfile(tctx->lp_ctx))) {
                fprintf(stderr, "error loading %s\n", lpcfg_configfile(tctx->lp_ctx));
-               return W_ERROR_V(WERR_GENERAL_FAILURE);
+               talloc_free(frame);
+               return W_ERROR_V(WERR_GEN_FAILURE);
        }
 
        init_names();
@@ -42,16 +44,18 @@ bool torture_libnetapi_init_context(struct torture_context *tctx,
 
        status = libnetapi_net_init(&ctx);
        if (status != 0) {
+               talloc_free(frame);
                return false;
        }
 
        libnetapi_set_username(ctx,
-               cli_credentials_get_username(cmdline_credentials));
+               cli_credentials_get_username(popt_get_cmdline_credentials()));
        libnetapi_set_password(ctx,
-               cli_credentials_get_password(cmdline_credentials));
+               cli_credentials_get_password(popt_get_cmdline_credentials()));
 
        *ctx_p = ctx;
 
+       talloc_free(frame);
        return true;
 }
 
@@ -76,11 +80,11 @@ static bool torture_libnetapi_initialize(struct torture_context *tctx)
        return true;
 }
 
-NTSTATUS torture_libnetapi_init(void)
+NTSTATUS torture_libnetapi_init(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite;
 
-       suite = torture_suite_create(talloc_autofree_context(), "netapi");
+       suite = torture_suite_create(ctx, "netapi");
 
        torture_suite_add_simple_test(suite, "server", torture_libnetapi_server);
        torture_suite_add_simple_test(suite, "group", torture_libnetapi_group);
@@ -89,7 +93,7 @@ NTSTATUS torture_libnetapi_init(void)
 
        suite->description = talloc_strdup(suite, "libnetapi convenience interface tests");
 
-       torture_register_suite(suite);
+       torture_register_suite(ctx, suite);
 
        return NT_STATUS_OK;
 }