From 8a982108a4f115e350c4246276f2ec886934c7fe Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 9 Apr 2008 14:59:32 +1000 Subject: Link the new vampire code togeather. This adds in the newly attached secrets handling, as well as an interface to the command line 'net' tool. Andrew Bartlett (This used to be commit 1282e3c39479aa580124206814b493370d10690a) --- source4/utils/net/net.c | 3 +- source4/utils/net/net_join.c | 67 +++++++++++++++++++++++++++++++++++++++++ source4/utils/net/net_vampire.c | 2 +- 3 files changed, 70 insertions(+), 2 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index e0865c4416..c908ea6279 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -102,7 +102,8 @@ static const struct net_functable net_functable[] = { {"time", "get remote server's time\n", net_time, net_time_usage}, {"join", "join a domain\n", net_join, net_join_usage}, {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, - {"samsync", "synchronise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage}, + {"vampire", "join and syncronise an AD domain onto the local server\n", net_vampire, net_vampire_usage}, + {"samsync", "synchronise into the local ldb the sam of an NT4 domain\n", net_samsync_ldb, net_samsync_ldb_usage}, {"user", "manage user accounts\n", net_user, net_user_usage}, {NULL, NULL, NULL, NULL} }; diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 08a4fbd4a1..abdcbf6027 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -100,3 +100,70 @@ int net_join_help(struct net_context *ctx, int argc, const char **argv) d_printf("Joins domain as either member or backup domain controller.\n"); return 0; } + +int net_vampire(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + struct libnet_Vampire *r; + char *tmp, *targetdir = NULL; + const char *domain_name; + + switch (argc) { + case 0: /* no args -> fail */ + return net_vampire_usage(ctx, argc, argv); + case 1: /* only DOMAIN */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + case 2: /* domain and target dir */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + break; + default: /* too many args -> fail */ + return net_vampire_usage(ctx, argc, argv); + } + + domain_name = tmp; + + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + if (!libnetctx) { + return -1; + } + libnetctx->cred = ctx->credentials; + r = talloc(ctx->mem_ctx, struct libnet_Vampire); + if (!r) { + return -1; + } + /* prepare parameters for the vampire */ + r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); + r->in.domain_name = domain_name; + r->in.targetdir = targetdir; + r->out.error_string = NULL; + + /* do the domain vampire */ + status = libnet_Vampire(libnetctx, r, r); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "Vampire of domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); + talloc_free(r); + talloc_free(libnetctx); + return -1; + } + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + + talloc_free(libnetctx); + return 0; +} + +int net_vampire_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net vampire [options]\n"); + return 0; +} + +int net_vampire_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Vampires domain as either member or backup domain controller.\n"); + return 0; +} diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index c798112d7b..4f6371d617 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -169,7 +169,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net samsync_ldb\n"); + d_printf("net samsync\n"); return 0; } -- cgit From e9017ba418202b4b191c5a9ad4a96857558ce606 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 17:22:58 +0200 Subject: Use _OBJ_FILES variables in a couple more places. (This used to be commit 92856d5054106894b65cd1a1b5119c0facfc4cff) --- source4/utils/config.mk | 24 ++++++++++++------------ source4/utils/net/config.mk | 16 +++++++++------- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 9dea2c5af3..a7d82684e4 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -4,8 +4,6 @@ # Start BINARY ntlm_auth [BINARY::ntlm_auth] INSTALLDIR = BINDIR -OBJ_FILES = \ - ntlm_auth.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -20,14 +18,14 @@ PRIVATE_DEPENDENCIES = \ # End BINARY ntlm_auth ################################# +ntlm_auth_OBJ_FILES = utils/ntlm_auth.o + MANPAGES += utils/man/ntlm_auth.1 ################################# # Start BINARY getntacl [BINARY::getntacl] INSTALLDIR = BINDIR -OBJ_FILES = \ - getntacl.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -35,6 +33,8 @@ PRIVATE_DEPENDENCIES = \ WRAP_XATTR \ LIBSAMBA-ERRORS +getntacl_OBJ_FILES = utils/getntacl.o + # End BINARY getntacl ################################# @@ -45,27 +45,25 @@ MANPAGES += utils/man/getntacl.1 [BINARY::setntacl] # disabled until rewritten #INSTALLDIR = BINDIR -OBJ_FILES = \ - setntacl.o # End BINARY setntacl ################################# +setntacl_OBJ_FILES = utils/setntacl.o + ################################# # Start BINARY setnttoken [BINARY::setnttoken] INSTALLDIR = BINDIR -OBJ_FILES = \ - setnttoken.o PRIVATE_DEPENDENCIES = # End BINARY setnttoken ################################# +setnttoken_OBJ_FILES = utils/setnttoken.o + ################################# # Start BINARY nmblookup [BINARY::nmblookup] INSTALLDIR = BINDIR -OBJ_FILES = \ - nmblookup.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -77,12 +75,12 @@ PRIVATE_DEPENDENCIES = \ # End BINARY nmblookup ################################# +nmblookup_OBJ_FILES = utils/nmblookup.o + ################################# # Start BINARY testparm [BINARY::testparm] INSTALLDIR = BINDIR -OBJ_FILES = \ - testparm.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -93,3 +91,5 @@ PRIVATE_DEPENDENCIES = \ CHARSET # End BINARY testparm ################################# + +testparm_OBJ_FILES = utils/testparm.o diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index ced0710ae0..4423c44c15 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -5,13 +5,6 @@ [BINARY::net] INSTALLDIR = BINDIR PRIVATE_PROTO_HEADER = net_proto.h -OBJ_FILES = \ - net.o \ - net_password.o \ - net_time.o \ - net_join.o \ - net_vampire.o \ - net_user.o PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -21,3 +14,12 @@ PRIVATE_DEPENDENCIES = \ POPT_CREDENTIALS # End BINARY net ################################# + +net_OBJ_FILES = $(addprefix utils/net/, \ + net.o \ + net_password.o \ + net_time.o \ + net_join.o \ + net_vampire.o \ + net_user.o) + -- cgit From 4f51b0246db3242ee02ee16905cba13a5dc5633a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Apr 2008 12:43:37 -0400 Subject: Fix problems with event context not being the parent. (This used to be commit 957c4d893acf9e6db06a3fc3a4687ab6bb238635) --- source4/utils/net/net.c | 18 ++++++++++++------ source4/utils/net/net.h | 1 - source4/utils/net/net_join.c | 11 ++++++----- source4/utils/net/net_password.c | 19 ++++++++++--------- source4/utils/net/net_time.c | 5 +++-- source4/utils/net/net_user.c | 13 +++++++------ source4/utils/net/net_vampire.c | 11 ++++++----- 7 files changed, 44 insertions(+), 34 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index c908ea6279..6086a4ce32 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -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; } diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 8c4fbd7fdd..17388079dd 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -22,7 +22,6 @@ #define _UTIL_NET_H struct net_context { - TALLOC_CTX *mem_ctx; struct cli_credentials *credentials; struct loadparm_context *lp_ctx; }; diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index abdcbf6027..2102257c6c 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -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; diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1fcb772e4c..97bb467fac 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -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; diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 1f4bb3ed71..12a8132cea 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -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; diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 39d50e7d8b..57cef6b383 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -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)); diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 4f6371d617..38f05353ed 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -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; } -- cgit From 2bc26db97fea4562415956269d05ea65e5710045 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 20:39:12 +0200 Subject: Fix the build. (This used to be commit a70cbd63d9c398ddcbbaa595ee29343335e89aa7) --- source4/utils/net/net_join.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 2102257c6c..37b3c21fcf 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -114,11 +114,11 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) case 0: /* no args -> fail */ return net_vampire_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 target dir */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); - targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + tmp = talloc_strdup(ctx, argv[0]); + targetdir = talloc_strdup(ctx, argv[1]); break; default: /* too many args -> fail */ return net_vampire_usage(ctx, argc, argv); @@ -131,7 +131,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) return -1; } libnetctx->cred = ctx->credentials; - r = talloc(ctx->mem_ctx, struct libnet_Vampire); + r = talloc(ctx, struct libnet_Vampire); if (!r) { return -1; } @@ -151,7 +151,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } - d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); talloc_free(libnetctx); return 0; -- cgit From a5d52174bd993b32d01d26a795a56df4a92eba45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 22:30:15 +0200 Subject: Avoid event_find_context() when the event context is already available in the net utility. (This used to be commit d40804777edf41889bd461f63f7a07cc1cc60e27) --- source4/utils/net/net.c | 1 + source4/utils/net/net.h | 1 + source4/utils/net/net_join.c | 2 +- source4/utils/net/net_password.c | 4 ++-- source4/utils/net/net_time.c | 2 +- source4/utils/net/net_user.c | 4 ++-- source4/utils/net/net_vampire.c | 6 +++--- 7 files changed, 11 insertions(+), 9 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 6086a4ce32..ab81f07225 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -199,6 +199,7 @@ static int binary_net(int argc, const char **argv) ZERO_STRUCTP(ctx); ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; + ctx->event_ctx = ev; cli_credentials_set_event_context(ctx->credentials, ev); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h index 17388079dd..309bee277c 100644 --- a/source4/utils/net/net.h +++ b/source4/utils/net/net.h @@ -24,6 +24,7 @@ struct net_context { struct cli_credentials *credentials; struct loadparm_context *lp_ctx; + struct event_context *event_ctx; }; struct net_functable { diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 37b3c21fcf..ad63340089 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -58,7 +58,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 97bb467fac..55f7c3c31d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c index 12a8132cea..92e6e77481 100644 --- a/source4/utils/net/net_time.c +++ b/source4/utils/net/net_time.c @@ -43,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(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c index 57cef6b383..c4b8ecb0c2 100644 --- a/source4/utils/net/net_user.c +++ b/source4/utils/net/net_user.c @@ -44,7 +44,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; @@ -84,7 +84,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv) } /* libnet context init and its params */ - lnet_ctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!lnet_ctx) return -1; lnet_ctx->cred = ctx->credentials; diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c index 38f05353ed..14f6a07e4b 100644 --- a/source4/utils/net/net_vampire.c +++ b/source4/utils/net/net_vampire.c @@ -54,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar break; } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -100,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv) return rc; } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -142,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(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From 1efbd5fbf6b0f606ed29a763e2adfa6f99c6beac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 01:03:18 +0200 Subject: Remove event context tracking from the credentials struct. (This used to be commit 4d7fc946b2ec50e774689c9036423b6feef99b8e) --- source4/utils/net/net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils') diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ab81f07225..a87b266568 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -200,7 +200,6 @@ static int binary_net(int argc, const char **argv) ctx->lp_ctx = cmdline_lp_ctx; ctx->credentials = cmdline_credentials; ctx->event_ctx = ev; - cli_credentials_set_event_context(ctx->credentials, ev); rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); -- cgit From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/utils/nmblookup.c | 14 ++++++++++---- source4/utils/ntlm_auth.c | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index fe03e0dbbe..980e06602d 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -24,6 +24,7 @@ #include "includes.h" #include "lib/cmdline/popt_common.h" #include "lib/socket/socket.h" +#include "lib/events/events.h" #include "system/network.h" #include "system/locale.h" #include "lib/socket/netif.h" @@ -180,7 +181,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock, } -static bool process_one(struct loadparm_context *lp_ctx, +static bool process_one(struct loadparm_context *lp_ctx, struct event_context *ev, struct interface *ifaces, const char *name, int nbt_port) { TALLOC_CTX *tmp_ctx = talloc_new(NULL); @@ -211,7 +212,7 @@ static bool process_one(struct loadparm_context *lp_ctx, node_name = talloc_strdup(tmp_ctx, name); } - nbtsock = nbt_name_socket_init(tmp_ctx, NULL, lp_iconv_convenience(lp_ctx)); + nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx)); if (options.root_port) { all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name, @@ -271,6 +272,7 @@ int main(int argc, const char *argv[]) { bool ret = true; struct interface *ifaces; + struct event_context *ev; poptContext pc; int opt; enum { @@ -356,13 +358,17 @@ int main(int argc, const char *argv[]) } load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces); - + + ev = event_context_init(talloc_autofree_context()); + while (poptPeekArg(pc)) { const char *name = poptGetArg(pc); - ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx)); + ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx)); } + talloc_free(ev); + talloc_free(ifaces); poptFreeContext(pc); diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 0c9a41fd70..07c0e4f31e 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -461,6 +461,10 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, return; } + ev = event_context_init(state); + if (!ev) { + exit(1); + } /* setup gensec */ if (!(state->gensec_state)) { switch (stdio_helper_mode) { @@ -468,7 +472,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, case NTLMSSP_CLIENT_1: /* setup the client side */ - nt_status = gensec_client_start(NULL, &state->gensec_state, NULL, lp_ctx); + nt_status = gensec_client_start(NULL, &state->gensec_state, ev, lp_ctx); if (!NT_STATUS_IS_OK(nt_status)) { exit(1); } @@ -476,10 +480,6 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, break; case GSS_SPNEGO_SERVER: case SQUID_2_5_NTLMSSP: - ev = event_context_init(state); - if (!ev) { - exit(1); - } msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), lp_iconv_convenience(lp_ctx), ev); if (!msg) { -- cgit From 7ee76eeae5b3e9e5f5b226039e7276897f5e6764 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 5 May 2008 15:23:57 +1000 Subject: Move NTLM authentication details into auth/ntlm This should help clarify the role of the various files around here (done on Jelmer's request). Andrew Bartlett (This used to be commit efa399037511ced8978f2e7661a71aac7a384883) --- source4/utils/config.mk | 1 + source4/utils/ntlm_auth.c | 1 + 2 files changed, 2 insertions(+) (limited to 'source4/utils') diff --git a/source4/utils/config.mk b/source4/utils/config.mk index a7d82684e4..13f3b0a145 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -13,6 +13,7 @@ PRIVATE_DEPENDENCIES = \ gensec \ LIBCLI_RESOLVE \ auth \ + ntlm_check \ MESSAGING \ LIBEVENTS # End BINARY ntlm_auth diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 07c0e4f31e..95029deffa 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -30,6 +30,7 @@ #include "auth/auth.h" #include "librpc/gen_ndr/ndr_netlogon.h" #include "auth/auth_sam.h" +#include "auth/ntlm/ntlm_check.h" #include "pstring.h" #include "libcli/auth/libcli_auth.h" #include "libcli/security/security.h" -- cgit From 03643aec88244d976da394521adbd29a31339569 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 19:54:27 +0200 Subject: Use variables for source directory in a couple more places. (This used to be commit c41bd3005f5f0b9cfd3709fc9217b4a401d265b4) --- source4/utils/config.mk | 16 ++++++++-------- source4/utils/net/config.mk | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/utils') diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 13f3b0a145..d47b36ea7c 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -19,9 +19,9 @@ PRIVATE_DEPENDENCIES = \ # End BINARY ntlm_auth ################################# -ntlm_auth_OBJ_FILES = utils/ntlm_auth.o +ntlm_auth_OBJ_FILES = $(utilssrcdir)/ntlm_auth.o -MANPAGES += utils/man/ntlm_auth.1 +MANPAGES += $(utilssrcdir)/man/ntlm_auth.1 ################################# # Start BINARY getntacl @@ -34,12 +34,12 @@ PRIVATE_DEPENDENCIES = \ WRAP_XATTR \ LIBSAMBA-ERRORS -getntacl_OBJ_FILES = utils/getntacl.o +getntacl_OBJ_FILES = $(utilssrcdir)/getntacl.o # End BINARY getntacl ################################# -MANPAGES += utils/man/getntacl.1 +MANPAGES += $(utilssrcdir)/man/getntacl.1 ################################# # Start BINARY setntacl @@ -49,7 +49,7 @@ MANPAGES += utils/man/getntacl.1 # End BINARY setntacl ################################# -setntacl_OBJ_FILES = utils/setntacl.o +setntacl_OBJ_FILES = $(utilssrcdir)/setntacl.o ################################# # Start BINARY setnttoken @@ -59,7 +59,7 @@ PRIVATE_DEPENDENCIES = # End BINARY setnttoken ################################# -setnttoken_OBJ_FILES = utils/setnttoken.o +setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o ################################# # Start BINARY nmblookup @@ -76,7 +76,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY nmblookup ################################# -nmblookup_OBJ_FILES = utils/nmblookup.o +nmblookup_OBJ_FILES = $(utilssrcdir)/nmblookup.o ################################# # Start BINARY testparm @@ -93,4 +93,4 @@ PRIVATE_DEPENDENCIES = \ # End BINARY testparm ################################# -testparm_OBJ_FILES = utils/testparm.o +testparm_OBJ_FILES = $(utilssrcdir)/testparm.o diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 4423c44c15..e6fa9617a2 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -1,4 +1,4 @@ -# utils/net subsystem +# $(utilssrcdir)/net subsystem ################################# # Start BINARY net @@ -15,7 +15,7 @@ PRIVATE_DEPENDENCIES = \ # End BINARY net ################################# -net_OBJ_FILES = $(addprefix utils/net/, \ +net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net.o \ net_password.o \ net_time.o \ -- cgit From 4c8756f147f8b9a2806fd76e4cb06bb99d391516 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 22:30:08 +0200 Subject: Create prototype headers from Makefile directory, without smb_build in the middle. (This used to be commit f4a77b96f9c17d853348b70794026e5b9e384942) --- source4/utils/net/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index e6fa9617a2..13c3631b54 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -4,7 +4,6 @@ # Start BINARY net [BINARY::net] INSTALLDIR = BINDIR -PRIVATE_PROTO_HEADER = net_proto.h PRIVATE_DEPENDENCIES = \ LIBSAMBA-HOSTCONFIG \ LIBSAMBA-UTIL \ @@ -23,3 +22,5 @@ net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net_vampire.o \ net_user.o) + +$(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c)) -- cgit From 4c70cda986c86fe536327321d04c29eca81b6409 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 18 May 2008 23:02:47 +0200 Subject: Fix a couple (well, little more than that..) of typos. (This used to be commit a6b52119940a900fb0de3864b8bca94e2965cc24) --- source4/utils/net/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils') diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk index 13c3631b54..93b51e1e28 100644 --- a/source4/utils/net/config.mk +++ b/source4/utils/net/config.mk @@ -23,4 +23,4 @@ net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ net_user.o) -$(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c)) +$(eval $(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c))) -- cgit