The branch, master has been updated via b6dff75... build: added --cross-answers support via 5040e2a... s4-dev: expanded selftest-vars.sh to match current testenv via e6cbbd9... s4-python: PyErr_SetString() will crash on NULL strings via 93f4f7a... build: fixed a python-3 indent error via 4e51bf1... build: expanded testwaf to include cross-compiling and python versions from 59fa1e1... Final fix for #7331 - Compound async SMB 2 requests don't work right.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit b6dff759f7016bb4820fc8f9d660bf565c7caeee Author: Andrew Tridgell <tri...@samba.org> Date: Mon Apr 19 15:58:37 2010 +1000 build: added --cross-answers support This allows you to easily cross-compile even without a --cross-execute emulator See http://wiki.samba.org/index.php/Waf#cross-compiling for details commit 5040e2a6fbe8b240b1d445e1260bb95203618b75 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Apr 19 13:49:00 2010 +1000 s4-dev: expanded selftest-vars.sh to match current testenv commit e6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd Author: Andrew Tridgell <tri...@samba.org> Date: Mon Apr 19 13:43:53 2010 +1000 s4-python: PyErr_SetString() will crash on NULL strings use nt_errstr() when no error available commit 93f4f7a0375b95540d7f701c295b88ed9c6322d8 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Apr 19 13:43:12 2010 +1000 build: fixed a python-3 indent error commit 4e51bf1ffdf55b8292383415bcc23803c8a56bc9 Author: Andrew Tridgell <tri...@samba.org> Date: Mon Apr 19 13:42:53 2010 +1000 build: expanded testwaf to include cross-compiling and python versions ----------------------------------------------------------------------- Summary of changes: buildtools/testwaf.sh | 42 ++++++++--- buildtools/wafsamba/samba_autoconf.py | 3 +- buildtools/wafsamba/samba_conftests.py | 2 +- buildtools/wafsamba/samba_cross.py | 114 ++++++++++++++++++++++++++++-- buildtools/wafsamba/samba_utils.py | 2 +- buildtools/wafsamba/wscript | 4 + source4/auth/credentials/pycredentials.c | 2 +- source4/libnet/py_net.c | 15 +++-- source4/scripting/devel/selftest-vars.sh | 45 +++++++++++- 9 files changed, 197 insertions(+), 32 deletions(-) Changeset truncated at 500 lines: diff --git a/buildtools/testwaf.sh b/buildtools/testwaf.sh index 00e37c6..5f24bdd 100755 --- a/buildtools/testwaf.sh +++ b/buildtools/testwaf.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -e +set -x + d=$(dirname $0) cd $d/.. @@ -15,28 +18,45 @@ echo "testing in dirs $tests" for d in $tests; do echo "`date`: testing $d" - pushd $d || exit 1 + pushd $d rm -rf bin type waf - waf dist || exit 1 - waf configure -C --enable-developer --prefix=$PREFIX || exit 1 - time waf build || exit 1 - time waf build || exit 1 - waf install || exit 1 - waf distcheck || exit 1 + waf dist + waf configure -C --enable-developer --prefix=$PREFIX + time waf build + time waf build + waf install + waf distcheck case $d in "source4/lib/ldb") - ldd bin/ldbadd || exit 1 + ldd bin/ldbadd ;; "lib/replace") - ldd bin/replace_testsuite || exit 1 + ldd bin/replace_testsuite ;; "lib/talloc") - ldd bin/talloc_testsuite || exit 1 + ldd bin/talloc_testsuite ;; "lib/tdb") - ldd bin/tdbtool || exit 1 + ldd bin/tdbtool ;; esac popd done + +echo "testing python portability" +pushd lib/talloc +#versions="python2.4 python2.5 python2.6 python3.0 python3.1" +versions="python2.4 python2.5 python2.6" +for p in $versions; do + echo "Testing $p" + $p ../../buildtools/bin/waf configure -C --enable-developer --prefix=$PREFIX + $p ../../buildtools/bin/waf build install +done +popd + +echo "testing cross compiling" +pushd lib/talloc +CC=arm-linux-gnu-gcc ./configure -C --prefix=$PREFIX --cross-compile --cross-execute='qemu-arm-static -L /usr/arm-linux-gnu' +make && make install +popd diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index dd7abe2..fa58e8f 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -372,7 +372,7 @@ def CHECK_CODE(conf, code, define, cflags = TO_LIST(cflags) cflags.extend(ccflags) - exec_args = conf.SAMBA_CROSS_ARGS() + exec_args = conf.SAMBA_CROSS_ARGS(msg=msg) ret = conf.check(fragment=fragment, execute=execute, @@ -567,6 +567,7 @@ def SAMBA_CONFIG_H(conf, path=None): conf.write_config_header('config.h', top=True) else: conf.write_config_header(path) + conf.SAMBA_CROSS_CHECK_COMPLETE() @conf diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py index ccd4763..e86f939 100644 --- a/buildtools/wafsamba/samba_conftests.py +++ b/buildtools/wafsamba/samba_conftests.py @@ -165,7 +165,7 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None): ADD_LD_LIBRARY_PATH(os.path.join(bdir, 'default/libdir')) # we need to run the program, try to get its result - args = conf.SAMBA_CROSS_ARGS() + args = conf.SAMBA_CROSS_ARGS(msg=msg) proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE) (out, err) = proc.communicate() w = conf.log.write diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py index 70d74e0..7c3e7d2 100644 --- a/buildtools/wafsamba/samba_cross.py +++ b/buildtools/wafsamba/samba_cross.py @@ -1,15 +1,83 @@ # functions for handling cross-compilation -import pproc, Utils +import Utils, Logs, sys, os, Options, re from Configure import conf -from pproc import Popen real_Popen = None -class cross_Popen(Popen): +ANSWER_UNKNOWN = (254, "") +ANSWER_FAIL = (255, "") +ANSWER_OK = (0, "") + +cross_answers_incomplete = False + + +def add_answer(ca_file, msg, answer): + '''add an answer to a set of cross answers''' + try: + f = open(ca_file, 'a') + except: + Logs.error("Unable to open cross-answers file %s" % ca_file) + sys.exit(1) + if answer == ANSWER_OK: + f.write('%s: OK\n' % msg) + elif answer == ANSWER_UNKNOWN: + f.write('%s: UNKNOWN\n' % msg) + elif answer == ANSWER_FAIL: + f.write('%s: FAIL\n' % msg) + else: + (retcode, retstring) = answer + f.write('%s: (%d, "%s")' % (msg, retcode, retstring)) + f.close() + + +def cross_answer(ca_file, msg): + '''return a (retcode,retstring) tuple from a answers file''' + try: + f = open(ca_file, 'r') + except: + add_answer(ca_file, msg, ANSWER_UNKNOWN) + return ANSWER_UNKNOWN + for line in f: + line = line.strip() + if line == '' or line[0] == '#': + continue + if line.find(':') != -1: + a = line.split(':') + thismsg = a[0].strip() + if thismsg != msg: + continue + ans = a[1].strip() + if ans == "OK" or ans == "YES": + f.close() + return ANSWER_OK + elif ans == "UNKNOWN": + f.close() + return ANSWER_UNKNOWN + elif ans == "FAIL" or ans == "NO": + f.close() + return ANSWER_FAIL + elif ans[0] == '"': + return (0, ans.strip('"')) + elif ans[0] == "'": + return (0, ans.strip("'")) + else: + m = re.match('\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans) + if m: + f.close() + return (int(m.group(1)), m.group(2)) + else: + raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file)) + f.close() + add_answer(ca_file, msg, ANSWER_UNKNOWN) + return ANSWER_UNKNOWN + + +class cross_Popen(Utils.pproc.Popen): '''cross-compilation wrapper for Popen''' def __init__(*k, **kw): (obj, args) = k + if '--cross-execute' in args: # when --cross-execute is set, then change the arguments # to use the cross emulator @@ -17,13 +85,25 @@ class cross_Popen(Popen): newargs = args[i+1].split() newargs.extend(args[0:i]) args = newargs - Popen.__init__(*(obj, args), **kw) + elif '--cross-answers' in args: + # when --cross-answers is set, then change the arguments + # to use the cross answers if available + i = args.index('--cross-answers') + ca_file = args[i+1] + msg = args[i+2] + ans = cross_answer(ca_file, msg) + if ans == ANSWER_UNKNOWN: + global cross_answers_incomplete + cross_answers_incomplete = True + (retcode, retstring) = ans + args = ['/bin/sh', '-c', 'echo %s; exit %d' % (retstring, retcode)] + real_Popen.__init__(*(obj, args), **kw) @conf -def SAMBA_CROSS_ARGS(conf): +def SAMBA_CROSS_ARGS(conf, msg=None): '''get exec_args to pass when running cross compiled binaries''' - if not conf.env.CROSS_COMPILE or not conf.env.CROSS_EXECUTE: + if not conf.env.CROSS_COMPILE: return [] global real_Popen @@ -31,4 +111,24 @@ def SAMBA_CROSS_ARGS(conf): real_Popen = Utils.pproc.Popen Utils.pproc.Popen = cross_Popen - return ['--cross-execute', conf.env.CROSS_EXECUTE] + ret = [] + + if conf.env.CROSS_EXECUTE: + ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE]) + elif conf.env.CROSS_ANSWERS: + if msg is None: + raise Utils.WafError("Cannot have NULL msg in cross-answers") + ret.extend(['--cross-answers', os.path.join(Options.launch_dir, conf.env.CROSS_ANSWERS), msg]) + + if ret == []: + raise Utils.WafError("Cannot cross-compile without either --cross-execute or --cross-answers") + + return ret + +...@conf +def SAMBA_CROSS_CHECK_COMPLETE(conf): + '''check if we have some unanswered questions''' + global cross_answers_incomplete + if conf.env.CROSS_COMPILE and cross_answers_incomplete: + raise Utils.WafError("Cross answers file %s is incomplete" % conf.env.CROSS_ANSWERS) + return True diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index cbea755..b989f91 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -452,7 +452,7 @@ def CHECK_MAKEFLAGS(bld): if opt[0:2] == 'V=': Options.options.verbose = Logs.verbose = int(opt[2:]) if Logs.verbose > 0: - Logs.zones = ['runner'] + Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*'] elif opt[0].isupper() and opt.find('=') != -1: diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index a611797..a49e5e7 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -93,6 +93,9 @@ def set_options(opt): gr.add_option('--cross-execute', help=("command prefix to use for cross-execution in configure"), action='store', dest='CROSS_EXECUTE', default='') + gr.add_option('--cross-answers', + help=("answers to cross-compilation configuration (auto modified)"), + action='store', dest='CROSS_ANSWERS', default='') gr.add_option('--hostcc', help=("set host compiler when cross compiling"), action='store', dest='HOSTCC', default=False) @@ -152,6 +155,7 @@ def configure(conf): conf.env.CROSS_COMPILE = Options.options.CROSS_COMPILE conf.env.CROSS_EXECUTE = Options.options.CROSS_EXECUTE + conf.env.CROSS_ANSWERS = Options.options.CROSS_ANSWERS conf.env.HOSTCC = Options.options.HOSTCC conf.env.AUTOCONF_BUILD = Options.options.AUTOCONF_BUILD diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c index c5cca4f..361e4c9 100644 --- a/source4/auth/credentials/pycredentials.c +++ b/source4/auth/credentials/pycredentials.c @@ -283,7 +283,7 @@ static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg return PyCredentialCacheContainer_from_ccache_container(ccc); } - PyErr_SetString(PyExc_RuntimeError, error_string); + PyErr_SetString(PyExc_RuntimeError, error_string?error_string:"NULL"); talloc_free(event_ctx); return NULL; diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index ec41ca3..6bd4c0c 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -52,7 +52,7 @@ static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwar status = libnet_Join(self->libnet_ctx, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { - PyErr_SetString(PyExc_RuntimeError, r.out.error_string); + PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -93,7 +93,8 @@ static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObje status = libnet_SetPassword(self->libnet_ctx, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { - PyErr_SetString(PyExc_RuntimeError, r.generic.out.error_string); + PyErr_SetString(PyExc_RuntimeError, + r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -127,7 +128,8 @@ static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObj status = libnet_export_keytab(self->libnet_ctx, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { - PyErr_SetString(PyExc_RuntimeError, r.out.error_string); + PyErr_SetString(PyExc_RuntimeError, + r.out.error_string?r.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -164,7 +166,8 @@ static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwar status = libnet_RemoteTOD(self->libnet_ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - PyErr_SetString(PyExc_RuntimeError, r.generic.out.error_string); + PyErr_SetString(PyExc_RuntimeError, + r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -204,7 +207,7 @@ static PyObject *py_net_user_create(py_net_Object *self, PyObject *args, PyObjec status = libnet_CreateUser(self->libnet_ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - PyErr_SetString(PyExc_RuntimeError, r.out.error_string); + PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } @@ -238,7 +241,7 @@ static PyObject *py_net_user_delete(py_net_Object *self, PyObject *args, PyObjec status = libnet_DeleteUser(self->libnet_ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - PyErr_SetString(PyExc_RuntimeError, r.out.error_string); + PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status)); talloc_free(mem_ctx); return NULL; } diff --git a/source4/scripting/devel/selftest-vars.sh b/source4/scripting/devel/selftest-vars.sh index 1ee9eb3..f275cea 100644 --- a/source4/scripting/devel/selftest-vars.sh +++ b/source4/scripting/devel/selftest-vars.sh @@ -1,10 +1,47 @@ # . these into your shell to allow you to run with socketwrapper # outside the test environment -export SELFTEST_INTERFACES=127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8 -export SOCKET_WRAPPER_DEFAULT_IFACE=6 -export SOCKET_WRAPPER_DIR=./st/w export UID_WRAPPER=1 export NSS_WRAPPER_PASSWD=st/dc/passwd export NSS_WRAPPER_GROUP=st/dc/group -export KRB5_CONFIG=st/dc/etc/krb5.conf +export CONFIGURATION="--configfile=$PWD/st/dc/etc/smb.conf" +export MEMBER_SERVER=localmember3 +export MEMBER_SERVER_IP=127.0.0.3 +export MEMBER_NETBIOSNAME=localmember3 +export MEMBER_NETBIOSALIAS=localmember +export RPC_PROXY_SERVER=localrpcproxy4 +export RPC_PROXY_SERVER_IP=127.0.0.4 +export RPC_PROXY_NETBIOSNAME=localrpcproxy4 +export RPC_PROXY_NETBIOSALIAS=localrpcproxy +export SELFTEST_TARGET="samba4" +export SELFTEST_MAXTIME=1200 +export NETBIOSNAME=localdc1 +export REALM=SAMBA.EXAMPLE.COM +export SOCKET_WRAPPER_DEFAULT_IFACE=1 +export SERVER=localdc1 +export WINBINDD_SOCKET_DIR=$PWD/st/dc/winbindd_socket +export SELFTEST_PREFIX=$PWD/st +export DOMAIN=SAMBADOMAIN +export BUILDDIR=. +export DC_SERVER_IP=127.0.0.1 +export SELFTEST_INTERFACES=127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8 +export SOCKET_WRAPPER_DIR=$PWD/st/w +export DC_USERNAME=Administrator +export USERNAME=Administrator +export SERVER_IP=127.0.0.1 +export KRB5_CONFIG=$PWD/st/dc/etc/krb5.conf +export PREFIX_ABS=$PWD/st +export SRCDIR_ABS=$PWD +export PREFIX=./st +export KRB5CCNAME=./st/krb5ticket +export SRCDIR=. +export TLS_ENABLED=yes +export DC_NETBIOSALIAS=localdc +export DC_NETBIOSNAME=localdc1 +export DC_SERVER=localdc1 +export DC_PASSWORD=localdcpass +export PYTHONPATH=$PWD/bin/python +export PASSWORD=localdcpass +export LDB_MODULES_PATH=$PWD/bin/modules/ldb +export NETBIOSALIAS=localdc +export SMB_CONF_PATH=$PWD/st/dc/etc/smb.conf -- Samba Shared Repository