summaryrefslogtreecommitdiff
path: root/source4/utils/net
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-12-30 14:55:07 +0100
committerAndrew Tridgell <tridge@samba.org>2009-12-31 17:33:02 +1100
commit31cc963ba0adc043032ad2113b44a5d599fa07d5 (patch)
treed42e1aa348a7cbcf9dd2fb2b3d7c410266e0b6ec /source4/utils/net
parent3a271a89b5e6d23089f9391f0cfd42f6631c925a (diff)
downloadsamba-31cc963ba0adc043032ad2113b44a5d599fa07d5.tar.gz
samba-31cc963ba0adc043032ad2113b44a5d599fa07d5.tar.bz2
samba-31cc963ba0adc043032ad2113b44a5d599fa07d5.zip
net: Allow python subcommands to provide commands that are not recognized by
net itself. Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4/utils/net')
-rw-r--r--source4/utils/net/net.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c
index 68fee9709f..ee5cdf8e1c 100644
--- a/source4/utils/net/net.c
+++ b/source4/utils/net/net.c
@@ -292,6 +292,33 @@ static int binary_net(int argc, const char **argv)
setlinebuf(stdout);
+ dcerpc_init(cmdline_lp_ctx);
+
+ ev = s4_event_context_init(NULL);
+ if (!ev) {
+ d_printf("Failed to create an event context\n");
+ exit(1);
+ }
+ py_load_samba_modules();
+ Py_Initialize();
+ PySys_SetArgv(argc, argv);
+ py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+
+ py_cmds = py_commands();
+ if (py_cmds == NULL) {
+ return 1;
+ }
+
+ if (argc > 1) {
+ py_cmd = PyDict_GetItemString(py_cmds, argv[1]);
+ if (py_cmd != NULL) {
+ rc = py_call_with_string_args(py_cmd, "_run",
+ argc-1, argv+1);
+ talloc_free(ev);
+ return rc;
+ }
+ }
+
pc = poptGetContext("net", argc, (const char **) argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
@@ -319,13 +346,7 @@ static int binary_net(int argc, const char **argv)
return net_usage(ctx, argc, argv);
}
- dcerpc_init(cmdline_lp_ctx);
- ev = s4_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("Failed to talloc a net_context\n");
@@ -337,23 +358,7 @@ static int binary_net(int argc, const char **argv)
ctx->credentials = cmdline_credentials;
ctx->event_ctx = ev;
- py_load_samba_modules();
- Py_Initialize();
- PySys_SetArgv(argc, argv);
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
-
- py_cmds = py_commands();
- if (py_cmds == NULL) {
- return 1;
- }
- py_cmd = PyDict_GetItemString(py_cmds, argv_new[1]);
- if (py_cmd != NULL) {
- rc = py_call_with_string_args(py_cmd, "_run",
- argc-1, argv+1);
- talloc_free(ev);
- return rc;
- }
rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable,
net_usage);