Commit 369e25d4 authored by Jelmer Vernooij's avatar Jelmer Vernooij

Imported Upstream version 1.1.17

parent 06d6b6b9
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
......@@ -597,9 +597,12 @@ def apply_vnum(self):
path = self.install_path
if not path: return
bld.install_as(path + os.sep + name3, node, env=self.env)
bld.symlink_as(path + os.sep + name2, name3)
bld.symlink_as(path + os.sep + libname, name3)
if self.env.DEST_OS == 'openbsd':
bld.install_as(path + os.sep + name2, node, env=self.env, chmod=self.link_task.chmod)
else:
bld.install_as(path + os.sep + name3, node, env=self.env)
bld.symlink_as(path + os.sep + name2, name3)
bld.symlink_as(path + os.sep + libname, name3)
# the following task is just to enable execution from the build dir :-/
self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])
......
......@@ -73,6 +73,19 @@ def parse_flags(line, uselib, env):
app('CCFLAGS_' + uselib, x)
app('CXXFLAGS_' + uselib, x)
app('LINKFLAGS_' + uselib, x)
#
# 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.
#
elif x.startswith('-Wl,-R'):
app('RPATH_' + uselib, x[6:])
elif x.startswith('-Wl,-rpath,'):
app('RPATH_' + uselib, x[11:])
elif x.startswith('-Wl'):
app('LINKFLAGS_' + uselib, x)
elif x.startswith('-m') or x.startswith('-f'):
......
......@@ -98,12 +98,27 @@ def check_perl_ext_devel(conf):
conf.env.EXTUTILS_TYPEMAP = read_out('print "$Config{privlib}/ExtUtils/typemap"')
conf.env.perlext_PATTERN = '%s.' + read_out('print $Config{dlext}')[0]
if getattr(Options.options, 'perlarchdir', None):
conf.env.ARCHDIR_PERL = Options.options.perlarchdir
if getattr(Options.options, 'perl_vendorarch_dir', None):
conf.env.PERL_VENDORARCH_DIR = Options.options.perl_vendorarch_dir
else:
conf.env.ARCHDIR_PERL = read_out('print $Config{sitearch}')[0]
conf.env.PERL_VENDORARCH_DIR = read_out('print $Config{vendorarch}')[0]
if getattr(Options.options, 'perl_vendorlib_dir', None):
conf.env.PERL_VENDORLIB_DIR = Options.options.perl_vendorlib_dir
else:
conf.env.PERL_VENDORLIB_DIR = read_out('print $Config{vendorlib}')[0]
def set_options(opt):
opt.add_option("--with-perl-binary", type="string", dest="perlbinary", help = 'Specify alternate perl binary', default=None)
opt.add_option("--with-perl-archdir", type="string", dest="perlarchdir", help = 'Specify directory where to install arch specific files', default=None)
opt.add_option("--with-perl-vendorarch",
type="string",
dest="perl_vendorarch_dir",
help = ('Specify directory where to install arch specific files'),
default=None)
opt.add_option("--with-perl-vendorlib",
type="string",
dest="perl_vendorlib_dir",
help = ('Specify directory where to install vendor specific files'),
default=None)
......@@ -10,6 +10,7 @@ import TaskGen, Utils, Options
from Logs import debug, warn, info
from TaskGen import extension, before, after, feature
from Configure import conf
from config_c import parse_flags
EXT_PY = ['.py']
FRAG_2 = '''
......@@ -192,6 +193,19 @@ MACOSX_DEPLOYMENT_TARGET = %r
""" % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS,
python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET))
# Allow some python overrides from env vars for cross-compiling
os_env = dict(os.environ)
override_python_LDFLAGS = os_env.get('python_LDFLAGS', None)
if override_python_LDFLAGS is not None:
conf.log.write("python_LDFLAGS override from environment = %r\n" % (override_python_LDFLAGS))
python_LDFLAGS = override_python_LDFLAGS
override_python_LIBDIR = os_env.get('python_LIBDIR', None)
if override_python_LIBDIR is not None:
conf.log.write("python_LIBDIR override from environment = %r\n" % (override_python_LIBDIR))
python_LIBDIR = override_python_LIBDIR
if python_MACOSX_DEPLOYMENT_TARGET:
conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
conf.environ['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
......@@ -213,7 +227,7 @@ MACOSX_DEPLOYMENT_TARGET = %r
env.append_value('LINKFLAGS_PYEMBED', lib)
if Options.platform != 'darwin' and python_LDFLAGS:
env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS.split())
parse_flags(python_LDFLAGS, 'PYEMBED', env)
result = False
name = 'python' + env['PYTHON_VERSION']
......
......@@ -495,6 +495,14 @@ def CONFIG_SET(conf, option):
if v == ():
return False
return True
@conf
def CONFIG_RESET(conf, option):
if option not in conf.env:
return
del conf.env[option]
Build.BuildContext.CONFIG_RESET = CONFIG_RESET
Build.BuildContext.CONFIG_SET = CONFIG_SET
Build.BuildContext.CONFIG_GET = CONFIG_GET
......@@ -559,7 +567,7 @@ int foo()
if set_target:
SET_TARGET_TYPE(conf, lib, 'EMPTY')
else:
conf.define('HAVE_LIB%s' % lib.upper().replace('-','_'), 1)
conf.define('HAVE_LIB%s' % lib.upper().replace('-','_').replace('.','_'), 1)
conf.env['LIB_' + lib.upper()] = lib
if set_target:
conf.SET_TARGET_TYPE(lib, 'SYSLIB')
......@@ -635,16 +643,32 @@ def SAMBA_CONFIG_H(conf, path=None):
return
if Options.options.debug:
conf.ADD_CFLAGS('-g',
testflags=True)
conf.ADD_CFLAGS('-g', testflags=True)
if Options.options.developer:
conf.env.DEVELOPER_MODE = True
conf.ADD_CFLAGS('-g', testflags=True)
conf.ADD_CFLAGS('-Wall', testflags=True)
conf.ADD_CFLAGS('-Wshadow', testflags=True)
conf.ADD_CFLAGS('-Wmissing-prototypes', testflags=True)
conf.ADD_CFLAGS('-Wcast-align -Wcast-qual', testflags=True)
conf.ADD_CFLAGS('-fno-common', testflags=True)
conf.ADD_CFLAGS('-Werror=address', testflags=True)
# we add these here to ensure that -Wstrict-prototypes is not set during configure
conf.ADD_CFLAGS('-Wall -g -Wshadow -Werror=strict-prototypes -Wstrict-prototypes -Werror=pointer-arith -Wpointer-arith -Wcast-align -Werror=write-strings -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wmissing-prototypes -fno-common -Werror=address',
conf.ADD_CFLAGS('-Werror=strict-prototypes -Wstrict-prototypes',
testflags=True)
conf.ADD_CFLAGS('-Werror=write-strings -Wwrite-strings',
testflags=True)
conf.ADD_CFLAGS('-Werror-implicit-function-declaration',
testflags=True)
conf.ADD_CFLAGS('-Werror=pointer-arith -Wpointer-arith',
testflags=True)
conf.ADD_CFLAGS('-Werror=declaration-after-statement -Wdeclaration-after-statement',
testflags=True)
conf.ADD_CFLAGS('-Wcast-qual', testflags=True)
conf.env.DEVELOPER_MODE = True
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
# This check is because for ldb_search(), a NULL format string
# is not an error, but some compilers complain about that.
if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], '''
......@@ -661,7 +685,7 @@ int main(void) {
conf.env['EXTRA_CFLAGS'].extend(TO_LIST("-Werror=format"))
if Options.options.picky_developer:
conf.ADD_CFLAGS('-Werror', testflags=True)
conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror', testflags=True)
if Options.options.fatal_errors:
conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
......@@ -686,7 +710,7 @@ def CONFIG_PATH(conf, name, default):
conf.env[name] = conf.env['PREFIX'] + default
@conf
def ADD_CFLAGS(conf, flags, testflags=False):
def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
'''add some CFLAGS to the command line
optionally set testflags to ensure all the flags work
'''
......@@ -696,9 +720,16 @@ def ADD_CFLAGS(conf, flags, testflags=False):
if CHECK_CFLAGS(conf, f):
ok_flags.append(f)
flags = ok_flags
if not 'EXTRA_CFLAGS' in conf.env:
conf.env['EXTRA_CFLAGS'] = []
conf.env['EXTRA_CFLAGS'].extend(TO_LIST(flags))
if not name in conf.env:
conf.env[name] = []
conf.env[name].extend(TO_LIST(flags))
@conf
def ADD_CFLAGS(conf, flags, testflags=False):
'''add some CFLAGS to the command line
optionally set testflags to ensure all the flags work
'''
ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags)
@conf
def ADD_LDFLAGS(conf, flags, testflags=False):
......@@ -728,14 +759,17 @@ def ADD_EXTRA_INCLUDES(conf, includes):
def CURRENT_CFLAGS(bld, target, cflags, hide_symbols=False):
def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=True, hide_symbols=False):
'''work out the current flags. local flags are added first'''
ret = TO_LIST(cflags)
if not 'EXTRA_CFLAGS' in bld.env:
list = []
else:
list = bld.env['EXTRA_CFLAGS'];
ret = TO_LIST(cflags)
ret.extend(list)
if not allow_warnings and 'PICKY_CFLAGS' in bld.env:
list = bld.env['PICKY_CFLAGS'];
ret.extend(list)
if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
ret.append('-fvisibility=hidden')
return ret
......
......@@ -70,14 +70,23 @@ def minimum_library_version(conf, libname, default):
@conf
def LIB_MAY_BE_BUNDLED(conf, libname):
return ('NONE' not in conf.env.BUNDLED_LIBS and
'!%s' % libname not in conf.env.BUNDLED_LIBS)
if libname in conf.env.BUNDLED_LIBS:
return True
if '!%s' % libname in conf.env.BUNDLED_LIBS:
return False
if 'NONE' in conf.env.BUNDLED_LIBS:
return False
return True
@conf
def LIB_MUST_BE_BUNDLED(conf, libname):
return ('ALL' in conf.env.BUNDLED_LIBS or
libname in conf.env.BUNDLED_LIBS)
if libname in conf.env.BUNDLED_LIBS:
return True
if '!%s' % libname in conf.env.BUNDLED_LIBS:
return False
if 'ALL' in conf.env.BUNDLED_LIBS:
return True
return False
@conf
def LIB_MUST_BE_PRIVATE(conf, libname):
......@@ -102,54 +111,18 @@ def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
This only tries using pkg-config
'''
if conf.LIB_MUST_BE_BUNDLED(libname):
return False
found = 'FOUND_SYSTEMLIB_%s' % libname
if found in conf.env:
return conf.env[found]
# 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
if minversion != '0.0.0':
msg += ' >= %s' % minversion
if pkg is None:
pkg = libname
if conf.check_cfg(package=pkg,
args='"%s >= %s" --cflags --libs' % (pkg, minversion),
msg=msg, uselib_store=libname.upper()):
conf.SET_TARGET_TYPE(libname, 'SYSLIB')
conf.env[found] = True
if implied_deps:
conf.SET_SYSLIB_DEPS(libname, implied_deps)
return True
conf.env[found] = False
if not conf.LIB_MAY_BE_BUNDLED(libname):
Logs.error('ERROR: System library %s of version %s not found, and bundling disabled' % (libname, minversion))
sys.exit(1)
return False
return conf.CHECK_BUNDLED_SYSTEM(libname,
minversion=minversion,
onlyif=onlyif,
implied_deps=implied_deps,
pkg=pkg)
@runonce
@conf
def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
checkfunctions=None, headers=None,
checkfunctions=None, headers=None, checkcode=None,
onlyif=None, implied_deps=None,
require_headers=True):
require_headers=True, pkg=None, set_target=True):
'''check if a library is available as a system library.
this first tries via pkg-config, then if that fails
tries by testing for a specified function in the specified lib
......@@ -160,14 +133,25 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
if found in conf.env:
return conf.env[found]
def check_functions_headers():
def check_functions_headers_code():
'''helper function for CHECK_BUNDLED_SYSTEM'''
if checkfunctions is None:
return True
if require_headers and headers and not conf.CHECK_HEADERS(headers, lib=libname):
return False
return conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers,
empty_decl=False, set_target=False)
if checkfunctions is not None:
ok = conf.CHECK_FUNCS_IN(checkfunctions, libname, headers=headers,
empty_decl=False, set_target=False)
if not ok:
return False
if checkcode is not None:
define='CHECK_BUNDLED_SYSTEM_%s' % libname.upper()
ok = conf.CHECK_CODE(checkcode, lib=libname,
headers=headers, local_include=False,
msg=msg, define=define)
conf.CONFIG_RESET(define)
if not ok:
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
......@@ -187,22 +171,28 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
if minversion != '0.0.0':
msg += ' >= %s' % minversion
uselib_store=libname.upper()
if pkg is None:
pkg = libname
# try pkgconfig first
if (conf.check_cfg(package=libname,
args='"%s >= %s" --cflags --libs' % (libname, minversion),
msg=msg) and
check_functions_headers()):
conf.SET_TARGET_TYPE(libname, 'SYSLIB')
if (conf.check_cfg(package=pkg,
args='"%s >= %s" --cflags --libs' % (pkg, minversion),
msg=msg, uselib_store=uselib_store) and
check_functions_headers_code()):
if set_target:
conf.SET_TARGET_TYPE(libname, 'SYSLIB')
conf.env[found] = True
if implied_deps:
conf.SET_SYSLIB_DEPS(libname, implied_deps)
return True
if checkfunctions is not None:
if check_functions_headers():
if check_functions_headers_code():
conf.env[found] = True
if implied_deps:
conf.SET_SYSLIB_DEPS(libname, implied_deps)
conf.SET_TARGET_TYPE(libname, 'SYSLIB')
if set_target:
conf.SET_TARGET_TYPE(libname, 'SYSLIB')
return True
conf.env[found] = False
if not conf.LIB_MAY_BE_BUNDLED(libname):
......
......@@ -224,7 +224,8 @@ def add_init_functions(self):
sname = sname.replace('/','_')
cflags.append('-DSTATIC_%s_MODULES=%s' % (sname, sentinel))
if sentinel == 'NULL':
cflags.append('-DSTATIC_%s_MODULES_PROTO=' % sname)
proto = "extern void __%s_dummy_module_proto(void)" % (sname)
cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (sname, proto))
self.ccflags = cflags
return
......@@ -238,12 +239,14 @@ def add_init_functions(self):
if init_fn_list == []:
cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinel))
if sentinel == 'NULL':
cflags.append('-DSTATIC_%s_MODULES_PROTO' % m)
proto = "extern void __%s_dummy_module_proto(void)" % (m)
cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (m, proto))
else:
cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinel))
proto=''
for f in init_fn_list:
proto = proto + '_MODULE_PROTO(%s)' % f
proto += '_MODULE_PROTO(%s)' % f
proto += "extern void __%s_dummy_module_proto(void)" % (m)
cflags.append('-DSTATIC_%s_MODULES_PROTO=%s' % (m, proto))
self.ccflags = cflags
......
......@@ -59,6 +59,8 @@ def write_build_options_header(fp):
fp.write("#include \"includes.h\"\n")
fp.write("#include \"build_env.h\"\n")
fp.write("#include \"dynconfig/dynconfig.h\"\n")
fp.write("#include \"lib/cluster_support.h\"\n")
fp.write("\n")
fp.write("static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);\n")
fp.write("void build_options(bool screen);\n")
......@@ -129,6 +131,9 @@ def write_build_options_header(fp):
fp.write("\n")
def write_build_options_footer(fp):
fp.write(" /* Output the sizes of the various cluster features */\n")
fp.write(" output(screen, \"\\n%s\", cluster_support_features());\n")
fp.write("\n")
fp.write(" /* Output the sizes of the various types */\n")
fp.write(" output(screen, \"\\nType sizes:\\n\");\n")
fp.write(" output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));\n")
......
......@@ -63,6 +63,7 @@ def SAMBA_PYTHON(bld, name,
target_type='PYTHON',
install_path='${PYTHONARCHDIR}',
allow_undefined_symbols=True,
allow_warnings=True,
enabled=enabled)
Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON
......@@ -391,7 +391,7 @@ try:
# Even if hashlib.md5 exists, it may be unusable.
# Try to use MD5 function. In FIPS mode this will cause an exception
# and we'll get to the replacement code
foo = md5.md5('abcd')
foo = md5('abcd')
except:
try:
import md5
......
......@@ -130,6 +130,7 @@ def SAMBA_LIBRARY(bld, libname, source,
private_library=False,
grouping_library=False,
allow_undefined_symbols=False,
allow_warnings=True,
enabled=True):
'''define a Samba library'''
......@@ -176,6 +177,7 @@ def SAMBA_LIBRARY(bld, libname, source,
autoproto_extra_source=autoproto_extra_source,
depends_on = depends_on,
hide_symbols = hide_symbols,
allow_warnings = allow_warnings,
pyembed = pyembed,
pyext = pyext,
local_include = local_include,
......@@ -348,6 +350,8 @@ def SAMBA_BINARY(bld, binname, source,
if bld.env['ENABLE_PIE'] == True:
pie_cflags += ' -fPIE'
pie_ldflags.extend(TO_LIST('-pie'))
if bld.env['ENABLE_RELRO'] == True:
pie_ldflags.extend(TO_LIST('-Wl,-z,relro,-z,now'))
# first create a target for building the object files for this binary
# by separating in this way, we avoid recompiling the C files
......@@ -413,7 +417,8 @@ def SAMBA_MODULE(bld, modname, source,
enabled=True,
pyembed=False,
manpages=None,
allow_undefined_symbols=False
allow_undefined_symbols=False,
allow_warnings=True
):
'''define a Samba module.'''
......@@ -433,6 +438,7 @@ def SAMBA_MODULE(bld, modname, source,
cflags=cflags,
local_include=local_include,
global_include=global_include,
allow_warnings=allow_warnings,
enabled=enabled)
bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
......@@ -479,7 +485,8 @@ def SAMBA_MODULE(bld, modname, source,
install_path="${MODULESDIR}/%s" % subsystem,
pyembed=pyembed,
manpages=manpages,
allow_undefined_symbols=allow_undefined_symbols
allow_undefined_symbols=allow_undefined_symbols,
allow_warnings=allow_warnings
)
......@@ -511,6 +518,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
vars=None,
subdir=None,
hide_symbols=False,
allow_warnings=True,
pyext=False,
pyembed=False):
'''define a Samba subsystem'''
......@@ -546,7 +554,9 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
features = features,
source = source,
target = modname,
samba_cflags = CURRENT_CFLAGS(bld, modname, cflags, hide_symbols=hide_symbols),
samba_cflags = CURRENT_CFLAGS(bld, modname, cflags,
allow_warnings=allow_warnings,
hide_symbols=hide_symbols),
depends_on = depends_on,
samba_deps = TO_LIST(deps),
samba_includes = includes,
......@@ -804,7 +814,7 @@ def MANPAGES(bld, manpages, install):
bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
Build.BuildContext.MANPAGES = MANPAGES
def SAMBAMANPAGES(bld, manpages):
def SAMBAMANPAGES(bld, manpages, extra_source=None):
'''build and install manual pages'''
bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
......@@ -812,13 +822,15 @@ def SAMBAMANPAGES(bld, manpages):
for m in manpages.split():
source = m + '.xml'
if extra_source is not None:
source = [source, extra_source]
bld.SAMBA_GENERATOR(m,
source=source,
target=m,
group='final',
rule='''XML_CATALOG_FILES="${SAMBA_CATALOGS}"
export XML_CATALOG_FILES
${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC[0].abspath(env)}
${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
)
bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
......
......@@ -80,8 +80,10 @@ def set_options(opt):
match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
opt.add_option('--with-gettext',
help='additional directory to search for gettext',
action='store', dest='gettext_location', default='/usr/local',
match = ['Checking for library intl', 'Checking for header libintl.h'])
action='store', dest='gettext_location', default='None')
opt.add_option('--without-gettext',
help=("Disable use of gettext"),
action="store_true", dest='disable_gettext', default=False)
gr = opt.option_group('developer options')
......@@ -322,7 +324,7 @@ def configure(conf):
else:
conf.env.HAVE_LD_VERSION_SCRIPT = False
if sys.platform == "aix5" or sys.platform == "aix6":
if sys.platform.startswith('aix'):
conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
# Might not be needed if ALL_SOURCE is defined
# conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
......
......@@ -254,7 +254,7 @@ int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
if (n2 == 0 && n1 != 0) {
return (int)toupper(*s1);
}
if (n2 == 0 && n2 == 0) {
if (n1 == 0 && n2 == 0) {
return 0;
}
return (int)toupper(*s1) - (int)toupper(*s2);
......
......@@ -112,6 +112,10 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx)
* having to provide their own private one explicitly */
if (ev_ctx == NULL) {
ev_ctx = tevent_context_init(ldb);
if (ev_ctx == NULL) {
talloc_free(ldb);
return NULL;
}
tevent_set_debug(ev_ctx, ldb_tevent_debug, ldb);
tevent_loop_allow_nesting(ev_ctx);
}
......@@ -253,11 +257,12 @@ int ldb_connect(struct ldb_context *ldb, const char *url,
return ret;
}
if (ldb_load_modules(ldb, options) != LDB_SUCCESS) {
ret = ldb_load_modules(ldb, options);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_FATAL,
"Unable to load modules for %s: %s",
url, ldb_errstring(ldb));
return LDB_ERR_OTHER;
return ret;
}
/* set the default base dn */
......@@ -572,8 +577,8 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
struct tevent_context *ev;
int ret;
if (!handle) {
return ldb_error(handle->ldb, LDB_ERR_UNAVAILABLE, NULL);
if (handle == NULL) {
return LDB_ERR_UNAVAILABLE;
}
if (handle->state == LDB_ASYNC_DONE) {
......
......@@ -287,7 +287,7 @@ char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value)
*/
static bool ldb_dn_explode(struct ldb_dn *dn)
{
char *p, *ex_name, *ex_value, *data, *d, *dt, *t;
char *p, *ex_name = NULL, *ex_value = NULL, *data, *d, *dt, *t;
bool trim = true;
bool in_extended = true;
bool in_ex_name = false;
......@@ -298,7 +298,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
bool is_oid = false;
bool escape = false;
unsigned int x;
size_t l;
size_t l = 0;
int ret;
char *parse_dn;
bool is_index;
......
......@@ -554,8 +554,33 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
return ret;
}
if (!ldb_errstring(module->ldb)) {
const char *op;
switch (request->operation) {
case LDB_SEARCH:
op = "LDB_SEARCH";
break;
case LDB_ADD:
op = "LDB_ADD";
break;
case LDB_MODIFY:
op = "LDB_MODIFY";
break;
case LDB_DELETE:
op = "LDB_DELETE";
break;
case LDB_RENAME:
op = "LDB_RENAME";
break;
case LDB_EXTENDED:
op = "LDB_EXTENDED";
break;
default:
op = "request";
break;
}
/* Set a default error string, to place the blame somewhere */
ldb_asprintf_errstring(module->ldb, "error in module %s: %s (%d)", module->ops->name, ldb_strerror(ret), ret);
ldb_asprintf_errstring(module->ldb, "error in module %s: %s during %s (%d)", module->ops->name, ldb_strerror(ret), op, ret);
}
if (!(request->handle->flags & LDB_HANDLE_FLAG_DONE_CALLED)) {
......@@ -876,6 +901,7 @@ static int ldb_modules_load_path(const char *path, const char *version)
} *loaded;