The branch, master has been updated via 59b588a waf: a better way to detect duplicated symbols via 0846b3c s4: Update/Set local USN only on attribute that have been modified/created from d84a8d5 s3-selftest Add tests to show kerberos works across a password change
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 59b588a16c7be9ccfe42703e7d4b161fa513da76 Author: Andrew Tridgell <tri...@samba.org> Date: Wed Apr 6 13:35:49 2011 +1000 waf: a better way to detect duplicated symbols this detects when we have the same symbol linked in twice in any binary by using ldd and nm on the binary and its associated libraries. Some of these duplicates are caused by a subsystem being linked twice, and some are caused by two versions of the same function name being linked into a binary Pair-Programmed-With: Andrew Bartlett <abart...@samba.org> Autobuild-User: Andrew Tridgell <tri...@samba.org> Autobuild-Date: Wed Apr 6 06:44:14 CEST 2011 on sn-devel-104 commit 0846b3c8a28fa1baa4215694d098a32c83d59d6f Author: Matthieu Patou <m...@matws.net> Date: Tue Apr 5 14:49:05 2011 +0400 s4: Update/Set local USN only on attribute that have been modified/created Signed-off-by: Andrew Tridgell <tri...@samba.org> ----------------------------------------------------------------------- Summary of changes: buildtools/wafsamba/symbols.py | 102 ++++++++++++++++++----- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 24 ++++-- 2 files changed, 97 insertions(+), 29 deletions(-) Changeset truncated at 500 lines: diff --git a/buildtools/wafsamba/symbols.py b/buildtools/wafsamba/symbols.py index 0e862cb..5059c60 100644 --- a/buildtools/wafsamba/symbols.py +++ b/buildtools/wafsamba/symbols.py @@ -17,6 +17,7 @@ from samba_utils import * # # bld.env.syslib_symbols: dictionary mapping system library name to set of symbols # for that library +# bld.env.library_dict : dictionary mapping built library paths to subsystem names # # LOCAL_CACHE(bld, 'TARGET_TYPE') : dictionary mapping subsystem name to target type @@ -30,11 +31,11 @@ def symbols_extract(objfiles, dynamic=False): if dynamic: # needed for some .so files cmd.append("-D") - cmd.extend(objfiles) + cmd.extend(list(objfiles)) nmpipe = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout if len(objfiles) == 1: - filename = objfiles[0] + filename = list(objfiles)[0] ret[filename] = { "PUBLIC": set(), "UNDEFINED" : set()} for line in nmpipe: @@ -68,6 +69,35 @@ def real_name(name): return name +def get_ldd_libs(bld, binname): + '''find the list of linked libraries for any binary or library + binname is the path to the binary/library on disk + ''' + ret = set() + lddpipe = subprocess.Popen(['ldd', binname], stdout=subprocess.PIPE).stdout + for line in lddpipe: + line = line.strip() + cols = line.split(" ") + if len(cols) < 3 or cols[1] != "=>" or cols[2] == '': + continue + ret.add(os.path.realpath(cols[2])) + return ret + + +def get_ldd_libs_recursive(bld, binname, seen=set()): + '''find the recursive list of linked libraries for any binary or library + binname is the path to the binary/library on disk. seen is a set used + to prevent loops + ''' + if binname in seen: + return set() + ret = get_ldd_libs(bld, binname) + seen.add(binname) + for lib in ret: + ret = ret.union(get_ldd_libs_recursive(bld, lib, seen)) + return ret + + def find_syslib_path(bld, libname, deps): '''find the path to the syslib we will link against''' # the strategy is to use the targets that depend on the library, and run ldd @@ -160,6 +190,20 @@ def build_symbol_sets(bld, tgt_list): bld.env.used_symbols[name] = bld.env.used_symbols[name].union(t2.used_symbols) +def build_library_dict(bld, tgt_list): + '''build the library_dict dictionary''' + + if bld.env.library_dict: + return + + bld.env.library_dict = {} + + for t in tgt_list: + if t.samba_type in [ 'LIBRARY', 'PYTHON' ]: + linkpath = os.path.realpath(t.link_task.outputs[0].abspath(bld.env)) + bld.env.library_dict[linkpath] = t.sname + + def build_syslib_sets(bld, tgt_list): '''build the public_symbols for all syslibs''' @@ -444,6 +488,37 @@ def symbols_whyneeded(task): Logs.info("target '%s' uses symbols %s from '%s'" % (target, overlap, subsystem)) +def report_duplicate(bld, binname, sym, libs): + '''report duplicated symbols''' + if sym in ['_init', '_fini']: + return + libnames = [] + for lib in libs: + if lib in bld.env.library_dict: + libnames.append(bld.env.library_dict[lib]) + else: + libnames.append(lib) + print("%s: Symbol %s linked in multiple libraries %s" % (binname, sym, libnames)) + + +def symbols_dupcheck_binary(bld, binname): + '''check for duplicated symbols in one binary''' + libs = get_ldd_libs_recursive(bld, binname) + + symlist = symbols_extract(libs, dynamic=True) + + symmap = {} + for libpath in symlist: + for sym in symlist[libpath]['PUBLIC']: + if not sym in symmap: + symmap[sym] = set() + symmap[sym].add(libpath) + for sym in symmap: + if len(symmap[sym]) > 1: + for libpath in symmap[sym]: + if libpath in bld.env.library_dict: + report_duplicate(bld, binname, sym, symmap[sym]) + break def symbols_dupcheck(task): '''check for symbols defined in two different subsystems''' @@ -452,25 +527,12 @@ def symbols_dupcheck(task): targets = LOCAL_CACHE(bld, 'TARGET_TYPE') - Logs.info("Checking for duplicate symbols") - for sym in bld.env.symbol_map: - subsystems = set(bld.env.symbol_map[sym]) - if len(subsystems) == 1: - continue - - if sym in ['main', '_init', '_fini', 'init_samba_module', 'samba_init_module', 'ldb_init_module' ]: - # these are expected to be in many subsystems - continue + build_library_dict(bld, tgt_list) + for t in tgt_list: + if t.samba_type == 'BINARY': + binname = os_path_relpath(t.link_task.outputs[0].abspath(bld.env), os.getcwd()) + symbols_dupcheck_binary(bld, binname) - # if all of them are in system libraries, we can ignore them. This copes - # with the duplication between libc, libpthread and libattr - all_syslib = True - for s in subsystems: - if s != 'c' and (not s in targets or targets[s] != 'SYSLIB'): - all_syslib = False - if all_syslib: - continue - Logs.info("symbol %s appears in %s" % (sym, subsystems)) def SYMBOL_CHECK(bld): diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 6180dfc..06c63a8 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -3455,6 +3455,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) ni++; } + ar->seq_num = 0; /* now merge in the new meta data */ for (i=0; i < rmd->ctr.ctr1.count; i++) { bool found = false; @@ -3471,6 +3472,13 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) if (cmp) { /* replace the entry */ nmd.ctr.ctr1.array[j] = rmd->ctr.ctr1.array[i]; + if (ar->seq_num == 0) { + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &ar->seq_num); + if (ret != LDB_SUCCESS) { + return replmd_replicated_request_error(ar, ret); + } + } + nmd.ctr.ctr1.array[j].local_usn = ar->seq_num; found = true; break; } @@ -3493,6 +3501,13 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) if (found) continue; nmd.ctr.ctr1.array[ni] = rmd->ctr.ctr1.array[i]; + if (ar->seq_num == 0) { + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &ar->seq_num); + if (ret != LDB_SUCCESS) { + return replmd_replicated_request_error(ar, ret); + } + } + nmd.ctr.ctr1.array[ni].local_usn = ar->seq_num; ni++; } @@ -3527,15 +3542,6 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", ar->index_current, msg->num_elements); - ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &ar->seq_num); - if (ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ret); - } - - for (i=0; i<ni; i++) { - nmd.ctr.ctr1.array[i].local_usn = ar->seq_num; - } - /* create the meta data value */ ndr_err = ndr_push_struct_blob(&nmd_value, msg, &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); -- Samba Shared Repository