return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY);
}
- ret = libnetapi_net_init(context, lp_ctx);
+ ret = libnetapi_net_init(context, lp_ctx, NULL);
TALLOC_FREE(frame);
return ret;
}
****************************************************************/
NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context,
- struct loadparm_context *lp_ctx)
+ struct loadparm_context *lp_ctx,
+ struct cli_credentials *creds)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY);
}
- ctx->creds = cli_credentials_init(ctx);
+ ctx->creds = creds;
if (ctx->creds == NULL) {
- TALLOC_FREE(frame);
- return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY);
+ ctx->creds = cli_credentials_init(ctx);
+ if (ctx->creds == NULL) {
+ TALLOC_FREE(frame);
+ return W_ERROR_V(WERR_NOT_ENOUGH_MEMORY);
+ }
+ /* Ignore return code, as we might not have a smb.conf */
+ (void)cli_credentials_guess(ctx->creds, lp_ctx);
}
BlockSignals(True, SIGPIPE);
- /* Ignore return code, as we might not have a smb.conf */
- (void)cli_credentials_guess(ctx->creds, lp_ctx);
-
status = libnetapi_init_private_context(ctx);
if (status != 0) {
TALLOC_FREE(frame);
/* This function is to init the libnetapi subsystem, without
* re-reading config files or setting debug levels etc */
NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **ctx,
- struct loadparm_context *lp_ctx);
+ struct loadparm_context *lp_ctx,
+ struct cli_credentials *creds);
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
net_warn_member_options();
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
- if (status != 0) {
- return -1;
- }
-
-
if (argc == 0) {
if (c->display_usage) {
d_printf("%s\n%s",
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
{NULL, NULL, 0, NULL, NULL}
};
- status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx);
- if (status != 0) {
- return -1;
- }
-
- status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (status != 0) {
return -1;
}
return -1;
}
- if (libnetapi_net_init(&c->netapi_ctx, c->lp_ctx) != 0) {
- return -1;
- }
-
- net_api_status = libnetapi_set_creds(c->netapi_ctx, c->creds);
+ net_api_status = libnetapi_net_init(&c->netapi_ctx, c->lp_ctx, c->creds);
if (net_api_status != 0) {
return -1;
}
NET_API_STATUS status;
struct libnetapi_ctx *ctx;
TALLOC_CTX *frame = talloc_stackframe();
+ struct cli_credentials *creds = samba_cmdline_get_creds();
if (!lp_load_global(lpcfg_configfile(tctx->lp_ctx))) {
fprintf(stderr, "error loading %s\n", lpcfg_configfile(tctx->lp_ctx));
load_interfaces();
- status = libnetapi_net_init(&ctx, tctx->lp_ctx);
+ status = libnetapi_net_init(&ctx, tctx->lp_ctx, creds);
if (status != 0) {
talloc_free(frame);
return false;
}
- libnetapi_set_username(ctx,
- cli_credentials_get_username(samba_cmdline_get_creds()));
- libnetapi_set_password(ctx,
- cli_credentials_get_password(samba_cmdline_get_creds()));
-
*ctx_p = ctx;
talloc_free(frame);