diff options
Diffstat (limited to 'source4/utils/net/net.c')
-rw-r--r-- | source4/utils/net/net.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 9725402c7f..7b8f092f93 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -130,7 +130,6 @@ int net_run_function(struct net_context *ctx, int (*usage_fn)(struct net_context *ctx, int argc, const char **argv)) { int i; - PyObject *py_cmds, *py_cmd; if (argc == 0) { return usage_fn(ctx, argc, argv); @@ -144,17 +143,6 @@ int net_run_function(struct net_context *ctx, return functable[i].fn(ctx, argc-1, argv+1); } - py_cmds = py_commands(); - if (py_cmds == NULL) { - return 1; - } - - py_cmd = PyDict_GetItemString(py_cmds, argv[0]); - if (py_cmd != NULL) { - return py_call_with_string_args(py_cmd, "_run", - argc-1, argv+1); - } - d_printf("No command: %s\n", argv[0]); return usage_fn(ctx, argc, argv); } @@ -288,6 +276,7 @@ static int binary_net(int argc, const char **argv) int opt,i; int rc; int argc_new; + PyObject *py_cmds, *py_cmd; const char **argv_new; struct tevent_context *ev; struct net_context *ctx = NULL; @@ -352,6 +341,19 @@ static int binary_net(int argc, const char **argv) Py_Initialize(); 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[1]); + if (py_cmd != NULL) { + rc = py_call_with_string_args(py_cmd, "_run", + argc-2, argv+2); + talloc_free(ev); + return rc; + } + rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); |