summaryrefslogtreecommitdiff
path: root/source4/utils
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-04-15 09:54:41 +0200
committerAndrew Tridgell <tridge@samba.org>2008-04-15 09:54:41 +0200
commitb967afca648eea481e586f367f99464418cf8468 (patch)
tree3fbe9cc92a21013cbd1eb2b6fa1b73ccddfbb151 /source4/utils
parent9cd04363f56ba5ee4f8b1ffaf662fe81cc995e99 (diff)
parentafaba23131dc079be3cd92e87495ec8b2ebdc4ae (diff)
downloadsamba-b967afca648eea481e586f367f99464418cf8468.tar.gz
samba-b967afca648eea481e586f367f99464418cf8468.tar.bz2
samba-b967afca648eea481e586f367f99464418cf8468.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
(This used to be commit e891157b4ec7b2f845fb20c4106d80bf169f2072)
Diffstat (limited to 'source4/utils')
-rw-r--r--source4/utils/config.mk24
-rw-r--r--source4/utils/net/config.mk16
-rw-r--r--source4/utils/net/net.c18
-rw-r--r--source4/utils/net/net.h1
-rw-r--r--source4/utils/net/net_join.c21
-rw-r--r--source4/utils/net/net_password.c19
-rw-r--r--source4/utils/net/net_time.c5
-rw-r--r--source4/utils/net/net_user.c13
-rw-r--r--source4/utils/net/net_vampire.c11
9 files changed, 70 insertions, 58 deletions
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)
+
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..37b3c21fcf 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;
@@ -113,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);
@@ -130,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;
}
@@ -150,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;
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;
}