summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/script/installmisc.sh2
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py11
-rw-r--r--source4/utils/net/net.c26
3 files changed, 21 insertions, 18 deletions
diff --git a/source4/script/installmisc.sh b/source4/script/installmisc.sh
index 31ca7e645d..1617ff7948 100755
--- a/source4/script/installmisc.sh
+++ b/source4/script/installmisc.sh
@@ -49,7 +49,7 @@ cp setup/ad-schema/*.txt $SETUPDIR/ad-schema || exit 1
cp setup/display-specifiers/*.txt $SETUPDIR/display-specifiers || exit 1
echo "Installing sbin scripts from setup/*"
-for p in domainlevel enableaccount newuser provision setexpiry setpassword
+for p in enableaccount newuser provision setexpiry setpassword
do
cp setup/$p $SBINDIR || exit 1
chmod a+x $SBINDIR/$p
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 5c18d29fc3..cb8fa01fe1 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -19,6 +19,7 @@
import optparse
from samba import getopt as options, Ldb
+import sys
class Option(optparse.Option):
@@ -82,7 +83,11 @@ class Command(object):
if len(args) < len(self.takes_args):
self.usage(args)
return -1
- return self.run(*args, **kwargs)
+ try:
+ return self.run(*args, **kwargs)
+ except CommandError, e:
+ print >>sys.stderr, "ERROR: %s" % e
+ return -1
def run(self):
"""Run the command. This should be overriden by all subclasses."""
@@ -97,11 +102,7 @@ class SuperCommand(Command):
def run(self, subcommand, *args, **kwargs):
if not subcommand in subcommands:
print >>sys.stderr, "ERROR: No such subcommand '%s'" % subcommand
- try:
return subcommands[subcommand].run(*args, **kwargs)
- except CommandError, e:
- print >>sys.stderr, "ERROR: %s" % e.message
- return -1
def usage(self, subcommand=None, *args, **kwargs):
if subcommand is None:
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);