mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
Fix problems with event context not being the parent.
(This used to be commit 957c4d893a
)
This commit is contained in:
parent
97e09c2f87
commit
4f51b0246d
@ -28,20 +28,17 @@ struct libnet_context *libnet_context_init(struct event_context *ev,
|
||||
{
|
||||
struct libnet_context *ctx;
|
||||
|
||||
/* We require an event context here */
|
||||
if (!ev) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create brand new libnet context */
|
||||
ctx = talloc(ev, struct libnet_context);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* events */
|
||||
if (ev == NULL) {
|
||||
ev = event_context_find(ctx);
|
||||
if (ev == NULL) {
|
||||
talloc_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
ctx->event_ctx = ev;
|
||||
ctx->lp_ctx = lp_ctx;
|
||||
|
||||
|
@ -22,11 +22,12 @@
|
||||
#include "libnet.h"
|
||||
#include "param/param.h"
|
||||
#include "libcli/security/security.h"
|
||||
#include "lib/events/events.h"
|
||||
|
||||
struct libnet_context *py_net_ctx(PyObject *obj)
|
||||
struct libnet_context *py_net_ctx(PyObject *obj, struct event_context *ev)
|
||||
{
|
||||
/* FIXME: Use obj */
|
||||
return libnet_context_init(NULL, global_loadparm);
|
||||
return libnet_context_init(ev, global_loadparm);
|
||||
}
|
||||
|
||||
static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
@ -35,6 +36,7 @@ static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
NTSTATUS status;
|
||||
PyObject *result;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct event_context *ev;
|
||||
struct libnet_context *libnet_ctx;
|
||||
const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
|
||||
|
||||
@ -43,9 +45,12 @@ static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
&r.in.join_type, &r.in.level))
|
||||
return NULL;
|
||||
|
||||
mem_ctx = talloc_new(NULL);
|
||||
/* FIXME: we really need to get a context from the caller or we may end
|
||||
* up with 2 event contexts */
|
||||
ev = event_context_init(NULL);
|
||||
mem_ctx = talloc_new(ev);
|
||||
|
||||
libnet_ctx = py_net_ctx(cls);
|
||||
libnet_ctx = py_net_ctx(cls, ev);
|
||||
|
||||
status = libnet_Join(libnet_ctx, mem_ctx, &r);
|
||||
if (NT_STATUS_IS_ERR(status)) {
|
||||
|
@ -136,7 +136,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
|
||||
of specific server name. */
|
||||
domain_name = lp_workgroup(torture->lp_ctx);
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
if (ctx == NULL) {
|
||||
d_printf("failed to create libnet context\n");
|
||||
return false;
|
||||
@ -190,7 +190,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
if (ctx == NULL) {
|
||||
d_printf("failed to create libnet context\n");
|
||||
ret = false;
|
||||
@ -245,7 +245,6 @@ bool torture_domain_open_samr(struct torture_context *torture)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct libnet_context *ctx;
|
||||
struct event_context *evt_ctx=NULL;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct policy_handle domain_handle, handle;
|
||||
struct libnet_DomainOpen io;
|
||||
@ -255,7 +254,7 @@ bool torture_domain_open_samr(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_domainopen_lsa");
|
||||
|
||||
ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
/* we're accessing domain controller so the domain name should be
|
||||
@ -320,7 +319,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
if (ctx == NULL) {
|
||||
d_printf("failed to create libnet context\n");
|
||||
ret = false;
|
||||
@ -388,7 +387,7 @@ bool torture_domain_list(struct torture_context *torture)
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
if (ctx == NULL) {
|
||||
d_printf("failed to create libnet context\n");
|
||||
ret = false;
|
||||
|
@ -235,7 +235,7 @@ bool torture_groupinfo_api(struct torture_context *torture)
|
||||
|
||||
prep_mem_ctx = talloc_init("prepare torture group info");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
status = torture_rpc_connection(torture,
|
||||
@ -300,7 +300,7 @@ bool torture_grouplist(struct torture_context *torture)
|
||||
struct libnet_GroupList req;
|
||||
int i;
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
domain_name.string = lp_workgroup(torture->lp_ctx);
|
||||
@ -361,7 +361,7 @@ bool torture_creategroup(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_creategroup");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
req.in.group_name = TEST_GROUPNAME;
|
||||
|
@ -40,7 +40,7 @@ bool torture_lookup(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_lookup");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
|
||||
@ -84,7 +84,7 @@ bool torture_lookup_host(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_lookup_host");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
|
||||
@ -127,7 +127,7 @@ bool torture_lookup_pdc(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_lookup_pdc");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
talloc_steal(ctx, mem_ctx);
|
||||
@ -171,7 +171,7 @@ bool torture_lookup_sam_name(struct torture_context *torture)
|
||||
struct libnet_context *ctx;
|
||||
struct libnet_LookupName r;
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
mem_ctx = talloc_init("torture lookup sam name");
|
||||
|
@ -89,7 +89,7 @@ static bool torture_rpc_connect(struct torture_context *torture,
|
||||
{
|
||||
struct libnet_context *ctx;
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
d_printf("Testing connection to LSA interface\n");
|
||||
|
@ -131,7 +131,7 @@ bool torture_listshares(struct torture_context *torture)
|
||||
goto done;
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
printf("Couldn't allocate libnet context\n");
|
||||
ret = false;
|
||||
@ -210,7 +210,7 @@ bool torture_delshare(struct torture_context *torture)
|
||||
status = torture_rpc_binding(torture, &binding);
|
||||
torture_assert_ntstatus_ok(torture, status, "Failed to get binding");
|
||||
|
||||
libnetctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
libnetctx->cred = cmdline_credentials;
|
||||
|
||||
status = torture_rpc_connection(torture,
|
||||
|
@ -241,7 +241,7 @@ bool torture_createuser(struct torture_context *torture)
|
||||
|
||||
mem_ctx = talloc_init("test_createuser");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
req.in.user_name = TEST_USERNAME;
|
||||
@ -287,7 +287,7 @@ bool torture_deleteuser(struct torture_context *torture)
|
||||
|
||||
prep_mem_ctx = talloc_init("prepare test_deleteuser");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
req.in.user_name = TEST_USERNAME;
|
||||
@ -482,7 +482,7 @@ bool torture_modifyuser(struct torture_context *torture)
|
||||
|
||||
prep_mem_ctx = talloc_init("prepare test_deleteuser");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
status = torture_rpc_connection(torture,
|
||||
@ -616,7 +616,7 @@ bool torture_userinfo_api(struct torture_context *torture)
|
||||
|
||||
prep_mem_ctx = talloc_init("prepare torture user info");
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
status = torture_rpc_connection(torture,
|
||||
@ -681,7 +681,7 @@ bool torture_userlist(struct torture_context *torture)
|
||||
struct libnet_UserList req;
|
||||
int i;
|
||||
|
||||
ctx = libnet_context_init(NULL, torture->lp_ctx);
|
||||
ctx = libnet_context_init(torture->ev, torture->lp_ctx);
|
||||
ctx->cred = cmdline_credentials;
|
||||
|
||||
domain_name.string = lp_workgroup(torture->lp_ctx);
|
||||
|
@ -56,7 +56,7 @@ static bool test_NetShareAdd(TALLOC_CTX *mem_ctx,
|
||||
|
||||
printf("Creating share %s\n", sharename);
|
||||
|
||||
if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
|
||||
if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ static bool test_NetShareDel(TALLOC_CTX *mem_ctx,
|
||||
|
||||
printf("Deleting share %s\n", sharename);
|
||||
|
||||
if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
|
||||
if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
|
||||
struct samr_SetUserInfo s;
|
||||
union samr_UserInfo u;
|
||||
|
||||
tj = talloc(NULL, struct test_join);
|
||||
tj = talloc(tctx, struct test_join);
|
||||
if (!tj) return NULL;
|
||||
|
||||
libnet_r = talloc(tj, struct libnet_JoinDomain);
|
||||
@ -320,7 +320,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
libnet_ctx = libnet_context_init(NULL, tctx->lp_ctx);
|
||||
libnet_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);
|
||||
if (!libnet_ctx) {
|
||||
talloc_free(tj);
|
||||
return NULL;
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "librpc/rpc/dcerpc.h"
|
||||
#include "param/param.h"
|
||||
|
||||
#include "auth/credentials/credentials.h"
|
||||
|
||||
static bool run_matching(struct torture_context *torture,
|
||||
const char *prefix,
|
||||
const char *expr,
|
||||
@ -673,7 +675,7 @@ int main(int argc,char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
torture = torture_context_init(talloc_autofree_context(), ui_ops);
|
||||
torture = torture_context_init(cli_credentials_get_event_context(cmdline_credentials), ui_ops);
|
||||
if (basedir != NULL) {
|
||||
if (basedir[0] != '/') {
|
||||
fprintf(stderr, "Please specify an absolute path to --basedir\n");
|
||||
|
@ -27,14 +27,14 @@
|
||||
#include "auth/credentials/credentials.h"
|
||||
#include "lib/cmdline/popt_common.h"
|
||||
|
||||
struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
|
||||
struct torture_context *torture_context_init(struct event_context *event_ctx,
|
||||
const struct torture_ui_ops *ui_ops)
|
||||
{
|
||||
struct torture_context *torture = talloc_zero(mem_ctx,
|
||||
struct torture_context *torture = talloc_zero(event_ctx,
|
||||
struct torture_context);
|
||||
torture->ui_ops = ui_ops;
|
||||
torture->returncode = true;
|
||||
torture->ev = cli_credentials_get_event_context(cmdline_credentials);
|
||||
torture->ev = event_ctx;
|
||||
|
||||
if (ui_ops->init)
|
||||
ui_ops->init(torture);
|
||||
|
@ -390,7 +390,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
|
||||
struct torture_tcase *tcase,
|
||||
const char *name);
|
||||
|
||||
struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
|
||||
struct torture_context *torture_context_init(struct event_context *event_ctx,
|
||||
const struct torture_ui_ops *ui_ops);
|
||||
|
||||
#endif /* __TORTURE_UI_H__ */
|
||||
|
@ -553,8 +553,7 @@ _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
|
||||
|
||||
_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, struct torture_context *tctx, int conn_index)
|
||||
{
|
||||
return torture_open_connection_ev(c, conn_index, tctx,
|
||||
cli_credentials_get_event_context(cmdline_credentials));
|
||||
return torture_open_connection_ev(c, conn_index, tctx, tctx->ev);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "lib/ldb/include/ldb.h"
|
||||
#include "librpc/rpc/dcerpc.h"
|
||||
#include "param/param.h"
|
||||
#include "lib/events/events.h"
|
||||
#include "auth/credentials/credentials.h"
|
||||
|
||||
/*
|
||||
run a function from a function table. If not found then
|
||||
@ -140,7 +142,7 @@ static int binary_net(int argc, const char **argv)
|
||||
int rc;
|
||||
int argc_new;
|
||||
const char **argv_new;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct event_context *ev;
|
||||
struct net_context *ctx = NULL;
|
||||
poptContext pc;
|
||||
struct poptOption long_options[] = {
|
||||
@ -183,17 +185,21 @@ static int binary_net(int argc, const char **argv)
|
||||
|
||||
dcerpc_init();
|
||||
|
||||
mem_ctx = talloc_init("net_context");
|
||||
ctx = talloc(mem_ctx, struct net_context);
|
||||
ev = event_context_init(NULL);
|
||||
if (!ev) {
|
||||
d_printf("Failed to create an event context\n");
|
||||
exit(1);
|
||||
}
|
||||
ctx = talloc(ev, struct net_context);
|
||||
if (!ctx) {
|
||||
d_printf("talloc_init(net_context) failed\n");
|
||||
d_printf("Failed to talloc a net_context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ZERO_STRUCTP(ctx);
|
||||
ctx->mem_ctx = mem_ctx;
|
||||
ctx->lp_ctx = cmdline_lp_ctx;
|
||||
ctx->credentials = cmdline_credentials;
|
||||
cli_credentials_set_event_context(ctx->credentials, ev);
|
||||
|
||||
rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage);
|
||||
|
||||
@ -201,7 +207,7 @@ static int binary_net(int argc, const char **argv)
|
||||
DEBUG(0,("return code = %d\n", rc));
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
talloc_free(ev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#define _UTIL_NET_H
|
||||
|
||||
struct net_context {
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct cli_credentials *credentials;
|
||||
struct loadparm_context *lp_ctx;
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "libnet/libnet.h"
|
||||
#include "libcli/security/security.h"
|
||||
#include "param/param.h"
|
||||
#include "lib/events/events.h"
|
||||
|
||||
int net_join(struct net_context *ctx, int argc, const char **argv)
|
||||
{
|
||||
@ -38,10 +39,10 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
|
||||
case 0: /* no args -> fail */
|
||||
return net_join_usage(ctx, argc, argv);
|
||||
case 1: /* only DOMAIN */
|
||||
tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
tmp = talloc_strdup(ctx, argv[0]);
|
||||
break;
|
||||
case 2: /* DOMAIN and role */
|
||||
tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
tmp = talloc_strdup(ctx, argv[0]);
|
||||
if (strcasecmp(argv[1], "BDC") == 0) {
|
||||
secure_channel_type = SEC_CHAN_BDC;
|
||||
} else if (strcasecmp(argv[1], "MEMBER") == 0) {
|
||||
@ -57,12 +58,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
|
||||
|
||||
domain_name = tmp;
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
libnetctx->cred = ctx->credentials;
|
||||
r = talloc(ctx->mem_ctx, struct libnet_Join);
|
||||
r = talloc(ctx, struct libnet_Join);
|
||||
if (!r) {
|
||||
return -1;
|
||||
}
|
||||
@ -83,7 +84,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
|
||||
talloc_free(libnetctx);
|
||||
return -1;
|
||||
}
|
||||
d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid));
|
||||
d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid));
|
||||
|
||||
talloc_free(libnetctx);
|
||||
return 0;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "utils/net/net.h"
|
||||
#include "libnet/libnet.h"
|
||||
#include "system/filesys.h"
|
||||
#include "lib/events/events.h"
|
||||
#include "auth/credentials/credentials.h"
|
||||
|
||||
/*
|
||||
@ -46,13 +47,13 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
|
||||
if (argc > 0 && argv[0]) {
|
||||
new_password = argv[0];
|
||||
} else {
|
||||
password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:",
|
||||
password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:",
|
||||
cli_credentials_get_domain(ctx->credentials),
|
||||
cli_credentials_get_username(ctx->credentials));
|
||||
new_password = getpass(password_prompt);
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
@ -66,7 +67,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
|
||||
r.generic.in.newpassword = new_password;
|
||||
|
||||
/* do password change */
|
||||
status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r);
|
||||
status = libnet_ChangePassword(libnetctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string));
|
||||
return -1;
|
||||
@ -101,10 +102,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
|
||||
case 0: /* no args -> fail */
|
||||
return net_password_set_usage(ctx, argc, argv);
|
||||
case 1: /* only DOM\\user; prompt for password */
|
||||
tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
tmp = talloc_strdup(ctx, argv[0]);
|
||||
break;
|
||||
case 2: /* DOM\\USER and password */
|
||||
tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
tmp = talloc_strdup(ctx, argv[0]);
|
||||
new_password = argv[1];
|
||||
break;
|
||||
default: /* too mayn args -> fail */
|
||||
@ -115,19 +116,19 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
|
||||
if ((p = strchr_m(tmp,'\\'))) {
|
||||
*p = 0;
|
||||
domain_name = tmp;
|
||||
account_name = talloc_strdup(ctx->mem_ctx, p+1);
|
||||
account_name = talloc_strdup(ctx, p+1);
|
||||
} else {
|
||||
account_name = tmp;
|
||||
domain_name = cli_credentials_get_domain(ctx->credentials);
|
||||
}
|
||||
|
||||
if (!new_password) {
|
||||
password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:",
|
||||
password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:",
|
||||
domain_name, account_name);
|
||||
new_password = getpass(password_prompt);
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
@ -140,7 +141,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
|
||||
r.generic.in.newpassword = new_password;
|
||||
|
||||
/* do password change */
|
||||
status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r);
|
||||
status = libnet_SetPassword(libnetctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string));
|
||||
return -1;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "libnet/libnet.h"
|
||||
#include "utils/net/net.h"
|
||||
#include "system/time.h"
|
||||
#include "lib/events/events.h"
|
||||
|
||||
/*
|
||||
* Code for getting the remote time
|
||||
@ -42,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
|
||||
return net_time_usage(ctx, argc, argv);
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
@ -53,7 +54,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
|
||||
r.generic.in.server_name = server_name;
|
||||
|
||||
/* get the time */
|
||||
status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r);
|
||||
status = libnet_RemoteTOD(libnetctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("net_time: %s\n",r.generic.out.error_string));
|
||||
return -1;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "includes.h"
|
||||
#include "utils/net/net.h"
|
||||
#include "libnet/libnet.h"
|
||||
#include "lib/events/events.h"
|
||||
#include "auth/credentials/credentials.h"
|
||||
|
||||
static int net_user_add(struct net_context *ctx, int argc, const char **argv)
|
||||
@ -36,14 +37,14 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
|
||||
return net_user_usage(ctx, argc, argv);
|
||||
break;
|
||||
case 1:
|
||||
user_name = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
user_name = talloc_strdup(ctx, argv[0]);
|
||||
break;
|
||||
default:
|
||||
return net_user_usage(ctx, argc, argv);
|
||||
}
|
||||
|
||||
/* libnet context init and its params */
|
||||
lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!lnet_ctx) return -1;
|
||||
|
||||
lnet_ctx->cred = ctx->credentials;
|
||||
@ -52,7 +53,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
|
||||
r.in.user_name = user_name;
|
||||
r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred);
|
||||
|
||||
status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r);
|
||||
status = libnet_CreateUser(lnet_ctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to add user account: %s\n",
|
||||
r.out.error_string));
|
||||
@ -76,14 +77,14 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
|
||||
return net_user_usage(ctx, argc, argv);
|
||||
break;
|
||||
case 1:
|
||||
user_name = talloc_strdup(ctx->mem_ctx, argv[0]);
|
||||
user_name = talloc_strdup(ctx, argv[0]);
|
||||
break;
|
||||
default:
|
||||
return net_user_usage(ctx, argc, argv);
|
||||
}
|
||||
|
||||
/* libnet context init and its params */
|
||||
lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!lnet_ctx) return -1;
|
||||
|
||||
lnet_ctx->cred = ctx->credentials;
|
||||
@ -92,7 +93,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
|
||||
r.in.user_name = user_name;
|
||||
r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred);
|
||||
|
||||
status = libnet_DeleteUser(lnet_ctx, ctx->mem_ctx, &r);
|
||||
status = libnet_DeleteUser(lnet_ctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("Failed to delete user account: %s\n",
|
||||
r.out.error_string));
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "librpc/gen_ndr/samr.h"
|
||||
#include "auth/auth.h"
|
||||
#include "param/param.h"
|
||||
#include "lib/events/events.h"
|
||||
|
||||
static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv)
|
||||
{
|
||||
@ -53,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
|
||||
break;
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
@ -63,7 +64,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
|
||||
r.in.machine_account = NULL;
|
||||
r.in.binding_string = NULL;
|
||||
|
||||
status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r);
|
||||
status = libnet_SamDump_keytab(libnetctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("libnet_SamDump returned %s: %s\n",
|
||||
nt_errstr(status),
|
||||
@ -99,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
|
||||
return rc;
|
||||
}
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
@ -109,7 +110,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
|
||||
r.in.machine_account = NULL;
|
||||
r.in.binding_string = NULL;
|
||||
|
||||
status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r);
|
||||
status = libnet_SamDump(libnetctx, ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0,("libnet_SamDump returned %s: %s\n",
|
||||
nt_errstr(status),
|
||||
@ -141,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
|
||||
struct libnet_context *libnetctx;
|
||||
struct libnet_samsync_ldb r;
|
||||
|
||||
libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
|
||||
libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx);
|
||||
if (!libnetctx) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user