Commit 20f77125 authored by Jelmer Vernooij's avatar Jelmer Vernooij

Merge tag 'upstream/1.1.23'

Upstream version 1.1.23

# gpg: Signature made Sun 08 Nov 2015 21:17:23 GMT using RSA key ID 04D1E9F8
# gpg: Good signature from "Jelmer Vernooij <jelmer@jelmer.uk>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@samba.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@apache.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@debian.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@ubuntu.com>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@vernstok.nl>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@jelmer.co.uk>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@openchange.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jrvernooij@tigris.org>" [ultimate]
parents 7736914a 78b22634
This diff is collapsed.
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
# Text wrapper for ldb bindings
#
# Copyright (C) 2015 Petr Viktorin <pviktori@redhat.com>
# Published under the GNU LGPLv3 or later
import sys
import functools
import ldb
def _recursive_encode(obj):
if isinstance(obj, bytes):
return obj
elif isinstance(obj, str):
return obj.encode('utf-8')
else:
return [_recursive_encode(o) for o in obj]
class _WrapBase(object):
@classmethod
def _wrap(cls, wrapped):
self = cls.__new__(cls)
self._wrapped = wrapped
return self
def __len__(self):
return len(self._wrapped)
def __eq__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped == other._wrapped
else:
return self._wrapped == other
def __ne__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped != other._wrapped
else:
return self._wrapped != other
def __lt__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped < other._wrapped
else:
return self._wrapped < other
def __le__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped >= other._wrapped
else:
return self._wrapped >= other
def __gt__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped > other._wrapped
else:
return self._wrapped > other
def __ge__(self, other):
if hasattr(other, '_wrapped'):
return self._wrapped >= other._wrapped
else:
return self._wrapped >= other
def __repr__(self):
return '%s.text' % repr(self._wrapped)
class MessageElementTextWrapper(_WrapBase):
"""Text interface for a LDB message element"""
def __iter__(self):
for item in self._wrapped:
yield item.decode('utf-8')
def __getitem__(self, key):
result = self._wrapped[key]
if result is None:
return None
else:
return result.decode('utf-8')
@property
def flags(self):
return self._wrapped.flags
@property
def set_flags(self):
return self._wrapped.set_flags
_wrap_element = MessageElementTextWrapper._wrap
class MessageTextWrapper(_WrapBase):
"""Text interface for a LDB message"""
def __getitem__(self, key):
result = self._wrapped[key]
if result is None:
return None
else:
return _wrap_element(result)
def get(self, *args, **kwargs):
result = self._wrapped.get(*args, **kwargs)
if isinstance(result, ldb.MessageElement):
return _wrap_element(result)
elif isinstance(result, bytes):
return result.decode('utf-8')
else:
return result
def __setitem__(self, key, item):
self._wrapped[key] = _recursive_encode(item)
def __delitem__(self, key):
del self._wrapped[key]
def elements(self):
return [_wrap_element(el) for el in self._wrapped.elements()]
def items(self):
return [(attr, _wrap_element(el)) for attr, el in self._wrapped.items()]
@property
def keys(self):
return self._wrapped.keys
@property
def remove(self):
return self._wrapped.remove
@property
def add(self):
return self._wrapped.add
@property
def dn(self):
return self._wrapped.dn
@dn.setter
def dn(self, new_value):
self._wrapped.dn = new_value
# handle substitution of variables in .in files
import re, os
import Build, sys, Logs
from samba_utils import *
from samba_utils import SUBST_VARS_RECURSIVE
def subst_at_vars(task):
'''substiture @VAR@ style variables in a file'''
env = task.env
src = task.inputs[0].srcpath(env)
tgt = task.outputs[0].bldpath(env)
s = task.inputs[0].read()
f = open(src, 'r')
s = f.read()
f.close()
# split on the vars
a = re.split('(@\w+@)', s)
out = []
......@@ -27,9 +24,7 @@ def subst_at_vars(task):
v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
out.append(v)
contents = ''.join(out)
f = open(tgt, 'w')
s = f.write(contents)
f.close()
task.outputs[0].write(contents)
return 0
def CONFIGURE_FILE(bld, in_file, **kwargs):
......
......@@ -14,7 +14,7 @@ lock = threading.Lock()
preprocessor_flag = '-MD'
@feature('cc')
@feature('c', 'cc')
@before('apply_core')
def add_mmd_cc(self):
if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
......
......@@ -10,12 +10,11 @@
"Execute the tasks"
import sys, random, time, threading, traceback, os
import sys, random, threading
try: from Queue import Queue
except ImportError: from queue import Queue
import Build, Utils, Logs, Options
from Logs import debug, error
from Constants import *
import Utils, Options
from Constants import EXCEPTION, CRASHED, MAXJOBS, ASK_LATER, SKIPPED, SKIP_ME, SUCCESS
GAP = 15
......
# handle substitution of variables in pc files
import Build, sys, Logs
from samba_utils import *
import os, re, sys
import Build, Logs
from samba_utils import SUBST_VARS_RECURSIVE, TO_LIST
def subst_at_vars(task):
'''substiture @VAR@ style variables in a file'''
src = task.inputs[0].srcpath(task.env)
tgt = task.outputs[0].bldpath(task.env)
f = open(src, 'r')
s = f.read()
f.close()
s = task.inputs[0].read()
# split on the vars
a = re.split('(@\w+@)', s)
out = []
......@@ -37,9 +34,7 @@ def subst_at_vars(task):
break
out.append(v)
contents = ''.join(out)
f = open(tgt, 'w')
s = f.write(contents)
f.close()
task.outputs[0].write(contents)
return 0
......
......@@ -137,7 +137,8 @@ def abi_check(self):
topsrc = self.bld.srcnode.abspath()
abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh')
abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.name, self.vnum)
abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname,
self.vnum)
tsk = self.create_task('abi_check', self.link_task.outputs[0])
tsk.ABI_FILE = abi_file
......@@ -147,12 +148,10 @@ def abi_check(self):
def abi_process_file(fname, version, symmap):
'''process one ABI file, adding new symbols to the symmap'''
f = open(fname, mode='r')
for line in f:
for line in Utils.readf(fname).splitlines():
symname = line.split(":")[0]
if not symname in symmap:
symmap[symname] = version
f.close()
def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
......
# a waf tool to add autoconf-like macros to the configure section
import Build, os, sys, Options, preproc, Logs
import string
import os, sys
import Build, Options, preproc, Logs
from Configure import conf
from samba_utils import *
import samba_cross
from TaskGen import feature
from samba_utils import TO_LIST, GET_TARGET_TYPE, SET_TARGET_TYPE, runonce, unique_list, mkdir_p
missing_headers = set()
......@@ -569,7 +569,7 @@ int foo()
(ccflags, ldflags, cpppath) = library_flags(conf, lib)
if shlib:
res = conf.check(features='cc cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
res = conf.check(features='c cshlib', fragment=fragment, lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
else:
res = conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags, uselib=lib.upper())
......@@ -657,9 +657,23 @@ def SAMBA_CONFIG_H(conf, path=None):
if not IN_LAUNCH_DIR(conf):
return
if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
conf.ADD_CFLAGS('-fstack-protector')
conf.ADD_LDFLAGS('-fstack-protector')
# we need to build real code that can't be optimized away to test
if conf.check(fragment='''
#include <stdio.h>
int main(void)
{
char t[100000];
while (fgets(t, sizeof(t), stdin));
return 0;
}
''',
execute=0,
ccflags='-fstack-protector',
ldflags='-fstack-protector',
msg='Checking if toolchain accepts -fstack-protector'):
conf.ADD_CFLAGS('-fstack-protector')
conf.ADD_LDFLAGS('-fstack-protector')
if Options.options.debug:
conf.ADD_CFLAGS('-g', testflags=True)
......
# waf build tool for building automatic prototypes from C source
import os
import Build
from samba_utils import *
from samba_utils import SET_TARGET_TYPE, os_path_relpath
def SAMBA_AUTOPROTO(bld, header, source):
'''rule for samba prototype generation'''
......
# functions to support bundled libraries
import sys
import Build, Options, Logs
from Configure import conf
import sys, Logs
from samba_utils import *
from samba_utils import TO_LIST, runonce
def PRIVATE_NAME(bld, name, private_extension, private_library):
'''possibly rename a library to include a bundled extension'''
......@@ -107,16 +108,6 @@ def LIB_MUST_BE_PRIVATE(conf, libname):
return ('ALL' in conf.env.PRIVATE_LIBS or
libname in conf.env.PRIVATE_LIBS)
@conf
def CHECK_PREREQUISITES(conf, prereqs):
missing = []
for syslib in TO_LIST(prereqs):
f = 'FOUND_SYSTEMLIB_%s' % syslib
if not f in conf.env:
missing.append(syslib)
return missing
@runonce
@conf
def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
......@@ -141,11 +132,34 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
this first tries via pkg-config, then if that fails
tries by testing for a specified function in the specified lib
'''
if conf.LIB_MUST_BE_BUNDLED(libname):
return False
# We always do a logic validation of 'onlyif' first
missing = []
if onlyif:
for l in TO_LIST(onlyif):
f = 'FOUND_SYSTEMLIB_%s' % l
if not f in conf.env:
Logs.error('ERROR: CHECK_BUNDLED_SYSTEM(%s) - ' % (libname) +
'missing prerequisite check for ' +
'system library %s, onlyif=%r' % (l, onlyif))
sys.exit(1)
if not conf.env[f]:
missing.append(l)
found = 'FOUND_SYSTEMLIB_%s' % libname
if found in conf.env:
return conf.env[found]
if conf.LIB_MUST_BE_BUNDLED(libname):
conf.env[found] = False
return False
# see if the library should only use a system version if another dependent
# system version is found. That prevents possible use of mixed library
# versions
if missing:
if not conf.LIB_MAY_BE_BUNDLED(libname):
Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
sys.exit(1)
conf.env[found] = False
return False
def check_functions_headers_code():
'''helper function for CHECK_BUNDLED_SYSTEM'''
......@@ -166,19 +180,6 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
return False
return True
# see if the library should only use a system version if another dependent
# system version is found. That prevents possible use of mixed library
# versions
if onlyif:
missing = conf.CHECK_PREREQUISITES(onlyif)
if missing:
if not conf.LIB_MAY_BE_BUNDLED(libname):
Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing))
sys.exit(1)
conf.env[found] = False
return False
minversion = minimum_library_version(conf, libname, minversion)
msg = 'Checking for system %s' % libname
......
......@@ -2,10 +2,9 @@
# to test for commonly needed configuration options
import os, shutil, re
import Build, Configure, Utils
import Build, Configure, Utils, Options, Logs
from Configure import conf
import config_c
from samba_utils import *
from samba_utils import TO_LIST, ADD_LD_LIBRARY_PATH
def add_option(self, *k, **kw):
......@@ -197,7 +196,7 @@ int foo(int v) {
return v * 2;
}
'''
return conf.check(features='cc cshlib',vnum="1",fragment=snip,msg=msg)
return conf.check(features='c cshlib',vnum="1",fragment=snip,msg=msg)
@conf
def CHECK_NEED_LC(conf, msg):
......@@ -216,9 +215,7 @@ def CHECK_NEED_LC(conf, msg):
os.makedirs(subdir)
dest = open(os.path.join(subdir, 'liblc1.c'), 'w')
dest.write('#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
dest.close()
Utils.writef(os.path.join(subdir, 'liblc1.c'), '#include <stdio.h>\nint lib_func(void) { FILE *f = fopen("foo", "r");}\n')
bld = Build.BuildContext()
bld.log = conf.log
......@@ -229,7 +226,7 @@ def CHECK_NEED_LC(conf, msg):
bld.rescan(bld.srcnode)
bld(features='cc cshlib',
bld(features='c cshlib',
source='liblctest/liblc1.c',
ldflags=conf.env['EXTRA_LDFLAGS'],
target='liblc',
......@@ -249,9 +246,6 @@ def CHECK_SHLIB_W_PYTHON(conf, msg):
'''check if we need -undefined dynamic_lookup'''
dir = find_config_dir(conf)
env = conf.env
snip = '''
#include <Python.h>
#include <crt_externs.h>
......@@ -264,7 +258,7 @@ int foo(int v) {
ldb_module = PyImport_ImportModule("ldb");
return v * 2;
}'''
return conf.check(features='cc cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
return conf.check(features='c cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
# this one is quite complex, and should probably be broken up
# into several parts. I'd quite like to create a set of CHECK_COMPOUND()
......@@ -291,13 +285,8 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
os.makedirs(subdir)
dest = open(os.path.join(subdir, 'lib1.c'), 'w')
dest.write('int lib_func(void) { return 42; }\n')
dest.close()
dest = open(os.path.join(dir, 'main.c'), 'w')
dest.write('int main(void) {return !(lib_func() == 42);}\n')
dest.close()
Utils.writef(os.path.join(subdir, 'lib1.c'), 'int lib_func(void) { return 42; }\n')
Utils.writef(os.path.join(dir, 'main.c'), 'int main(void) {return !(lib_func() == 42);}\n')
bld = Build.BuildContext()
bld.log = conf.log
......@@ -311,17 +300,15 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
ldflags = []
if version_script:
ldflags.append("-Wl,--version-script=%s/vscript" % bld.path.abspath())
dest = open(os.path.join(dir,'vscript'), 'w')
dest.write('TEST_1.0A2 { global: *; };\n')
dest.close()
Utils.writef(os.path.join(dir,'vscript'), 'TEST_1.0A2 { global: *; };\n')
bld(features='cc cshlib',
bld(features='c cshlib',
source='libdir/lib1.c',
target='libdir/lib1',
ldflags=ldflags,
name='lib1')
o = bld(features='cc cprogram',
o = bld(features='c cprogram',
source='main.c',
target='prog1',
uselib_local='lib1')
......@@ -383,15 +370,13 @@ def CHECK_PERL_MANPAGE(conf, msg=None, section=None):
if not os.path.exists(bdir):
os.makedirs(bdir)
dest = open(os.path.join(bdir, 'Makefile.PL'), 'w')
dest.write("""
Utils.writef(os.path.join(bdir, 'Makefile.PL'), """
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'WafTest',
'EXE_FILES' => [ 'WafTest' ]
);
""")
dest.close()
back = os.path.abspath('.')
os.chdir(bdir)
proc = Utils.pproc.Popen(['perl', 'Makefile.PL'],
......@@ -406,9 +391,7 @@ WriteMakefile(
return
if section:
f = open(os.path.join(bdir,'Makefile'), 'r')
man = f.read()
f.close()
man = Utils.readf(os.path.join(bdir,'Makefile'))
m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
if not m:
conf.check_message_2('not found', color='YELLOW')
......@@ -537,53 +520,3 @@ def CHECK_STANDARD_LIBPATH(conf):
conf.env.STANDARD_LIBPATH = dirlist
waf_config_c_parse_flags = config_c.parse_flags;
def samba_config_c_parse_flags(line1, uselib, env):
#
# We do a special treatment of the rpath components
# in the linkflags line, because currently the upstream
# parse_flags function is incomplete with respect to
# treatment of the rpath. The remainder of the linkflags
# line is later passed to the original funcion.
#
lst1 = shlex.split(line1)
lst2 = []
while lst1:
x = lst1.pop(0)
#
# NOTE on special treatment of -Wl,-R and -Wl,-rpath:
#
# It is important to not put a library provided RPATH
# into the LINKFLAGS but in the RPATH instead, since
# the provided LINKFLAGS get prepended to our own internal
# RPATH later, and hence can potentially lead to linking
# in too old versions of our internal libs.
#
# We do this filtering here on our own because of some
# bugs in the real parse_flags() function.
#
if x == '-Wl,-rpath' or x == '-Wl,-R':
x = lst1.pop(0)
if x.startswith('-Wl,'):
rpath = x[4:]
else:
rpath = x
elif x.startswith('-Wl,-R,'):
rpath = x[7:]
elif x.startswith('-Wl,-R'):
rpath = x[6:]
elif x.startswith('-Wl,-rpath,'):
rpath = x[11:]
else:
lst2.append(x)
continue
env.append_value('RPATH_' + uselib, rpath)
line2 = ' '.join(lst2)
waf_config_c_parse_flags(line2, uselib, env)
return
config_c.parse_flags = samba_config_c_parse_flags
# functions for handling cross-compilation
import Utils, Logs, sys, os, Options, re
import os, sys, re, shlex
import Utils, Logs, Options
from Configure import conf
import shlex
real_Popen = None
......
This diff is collapsed.
# customised version of 'waf dist' for Samba tools
# uses git ls-files to get file lists
import Utils, os, sys, tarfile, stat, Scripting, Logs, Options
from samba_utils import *
import os, sys, tarfile
import Utils, Scripting, Logs, Options
from Configure import conf
from samba_utils import os_path_relpath
dist_dirs = None
dist_files = None
......
# specialist handling of header files for Samba
import Build, re, Task, TaskGen, shutil, sys, Logs
from samba_utils import *
import os, re, sys, fnmatch
import Build, Logs, Utils
from samba_utils import TO_LIST, os_path_relpath
def header_install_path(header, header_path):
......
......@@ -3,9 +3,10 @@
# with all the configure options that affect rpath and shared
# library use
import Options
import os
import Options, Utils
from TaskGen import feature, before, after
from samba_utils import *
from samba_utils import LIB_PATH, MODE_755, install_rpath, build_rpath
@feature('install_bin')
@after('apply_core')
......@@ -224,7 +225,6 @@ def symlink_bin(self):
if self.target.endswith('.inst'):
return
blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
if not self.link_task.outputs or not self.link_task.outputs[0]:
raise Utils.WafError('no outputs found for %s in symlink_bin' % self.name)
binpath = self.link_task.outputs[0].abspath(self.env)
......
......@@ -11,7 +11,7 @@ import Build, Utils, Node
from TaskGen import feature, after, before
import preproc
@feature('cc', 'cxx')
@feature('c', 'cc', 'cxx')
@after('apply_type_vars', 'apply_lib_vars', 'apply_core')
def apply_incpaths(self):
lst = []
......@@ -59,7 +59,7 @@ def apply_incpaths(self):
if node:
self.env.append_value('INC_PATHS', node)
@feature('cc')
@feature('c', 'cc')
@after('apply_incpaths')
def apply_obj_vars_cc(self):
"""after apply_incpaths for INC_PATHS"""
......@@ -165,7 +165,7 @@ def is_this_a_static_lib(self, name):
try:
return cache[name]
except KeyError:
ret = cache[name] = 'cstaticlib' in self.bld.name_to_obj(name, self.env).features
ret = cache[name] = 'cstaticlib' in self.bld.get_tgen_by_name(name).features
return ret
TaskGen.task_gen.is_this_a_static_lib = is_this_a_static_lib
......@@ -187,7 +187,7 @@ def shared_ancestors(self):
return ret
TaskGen.task_gen.shared_ancestors = shared_ancestors
@feature('cc', 'cxx')
@feature('c', 'cc', 'cxx')
@after('apply_link', 'init_cc', 'init_cxx', 'apply_core')
def apply_lib_vars(self):
"""after apply_link because of 'link_task'
......@@ -215,7 +215,7 @@ def apply_lib_vars(self):
if lib_name in seen:
continue
y = self.name_to_obj(lib_name)