Commit 6461ad6d authored by Mathieu Parent's avatar Mathieu Parent

New upstream version 2:1.1.27

parent 4a1aed9d
This diff is collapsed.
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 **)
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 **)
# encoding: utf-8
# Thomas Nagy, 2008-2010 (ita)
"""
Execute the tasks with gcc -MD, read the dependencies from the .d file
and prepare the dependency calculation for the next run
"""
import os, re, threading
import Task, Logs, Utils, preproc
from TaskGen import before, after, feature
lock = threading.Lock()
preprocessor_flag = '-MD'
@feature('c', 'cc')
@before('apply_core')
def add_mmd_cc(self):
if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CCFLAGS', preprocessor_flag)
@feature('cxx')
@before('apply_core')
def add_mmd_cxx(self):
if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CXXFLAGS', preprocessor_flag)
def scan(self):
"the scanner does not do anything initially"
nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
names = []
return (nodes, names)
re_o = re.compile("\.o$")
re_src = re.compile("^(\.\.)[\\/](.*)$")
def post_run(self):
# The following code is executed by threads, it is not safe, so a lock is needed...
if getattr(self, 'cached', None):
return Task.Task.post_run(self)
name = self.outputs[0].abspath(self.env)
name = re_o.sub('.d', name)
txt = Utils.readf(name)
#os.unlink(name)
txt = txt.replace('\\\n', '')
lst = txt.strip().split(':')
val = ":".join(lst[1:])
val = val.split()
nodes = []
bld = self.generator.bld
f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
for x in val:
if os.path.isabs(x):
if not preproc.go_absolute:
continue
lock.acquire()
try:
node = bld.root.find_resource(x)
finally:
lock.release()
else:
g = re.search(re_src, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.bldnode.parent.find_resource(x)
finally:
lock.release()
else:
g = re.search(f, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.srcnode.find_resource(x)
finally:
lock.release()
if id(node) == id(self.inputs[0]):
# ignore the source file, it is already in the dependencies
# this way, successful config tests may be retrieved from the cache
continue
if not node:
raise ValueError('could not find %r for %r' % (x, self))
else:
nodes.append(node)
Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
bld.node_deps[self.unique_id()] = nodes
bld.raw_deps[self.unique_id()] = []
try:
del self.cache_sig
except:
pass
Task.Task.post_run(self)
import Constants, Utils
def sig_implicit_deps(self):
try:
return Task.Task.sig_implicit_deps(self)
except Utils.WafError:
return Constants.SIG_NIL
for name in 'cc cxx'.split():
try:
cls = Task.TaskBase.classes[name]
except KeyError:
pass
else:
cls.post_run = post_run
cls.scan = scan
cls.sig_implicit_deps = sig_implicit_deps
......@@ -725,6 +725,7 @@ int main(void) {
if Options.options.picky_developer:
conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True)
conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare', testflags=True)
if Options.options.fatal_errors:
conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
......
......@@ -97,7 +97,18 @@ def SAMBA_PYTHON(bld, name,
# when we support static python modules we'll need to gather
# the list from all the SAMBA_PYTHON() targets
if init_function_sentinel is not None:
cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
cflags += ' -DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
# From https://docs.python.org/2/c-api/arg.html:
# Starting with Python 2.5 the type of the length argument to
# PyArg_ParseTuple(), PyArg_ParseTupleAndKeywords() and PyArg_Parse()
# can be controlled by defining the macro PY_SSIZE_T_CLEAN before
# including Python.h. If the macro is defined, length is a Py_ssize_t
# rather than an int.
# Because <Python.h> if often included before includes.h/config.h
# This must be in the -D compiler options
cflags += ' -DPY_SSIZE_T_CLEAN=1'
source = bld.EXPAND_VARIABLES(source, vars=vars)
......
......@@ -106,6 +106,7 @@ def SAMBA_LIBRARY(bld, libname, source,
includes='',
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
pc_files=None,
vnum=None,
......@@ -145,8 +146,12 @@ def SAMBA_LIBRARY(bld, libname, source,
if pyembed and bld.env['IS_EXTRA_PYTHON']:
public_headers = pc_files = None
if private_library and public_headers:
raise Utils.WafError("private library '%s' must not have public header files" %
libname)
if LIB_MUST_BE_PRIVATE(bld, libname):
private_library=True
private_library = True
if not enabled:
SET_TARGET_TYPE(bld, libname, 'DISABLED')
......@@ -187,6 +192,7 @@ def SAMBA_LIBRARY(bld, libname, source,
includes = includes,
public_headers = public_headers,
public_headers_install = public_headers_install,
private_headers= private_headers,
header_path = header_path,
cflags = cflags,
group = subsystem_group,
......@@ -337,6 +343,7 @@ def SAMBA_BINARY(bld, binname, source,
deps='',
includes='',
public_headers=None,
private_headers=None,
header_path=None,
modules=None,
ldflags=None,
......@@ -539,6 +546,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
includes='',
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
cflags='',
cflags_end=None,
......@@ -631,6 +639,7 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
group='generators', enabled=True,
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
vars=None,
dep_vars=[],
......
......@@ -229,6 +229,11 @@ def configure(conf):
# older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
if Options.options.enable_gccdeps:
# stale file removal - the configuration may pick up the old .pyc file
p = os.path.join(conf.srcdir, 'buildtools/wafsamba/gccdeps.pyc')
if os.path.exists(p):
os.remove(p)
from TaskGen import feature, after
@feature('testd')
@after('apply_core')
......@@ -397,6 +402,22 @@ def configure(conf):
addmain=False,
msg='Checking for library destructor support')
conf.CHECK_CODE('''
void test_attribute(void) __attribute__ (());
void test_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE___ATTRIBUTE__',
addmain=False,
msg='Checking for __attribute__')
if sys.platform.startswith('aix'):
conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
# Might not be needed if ALL_SOURCE is defined
......
......@@ -284,15 +284,17 @@ void ldb_set_errstring(struct ldb_context *ldb, const char *err_string)
void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...)
{
va_list ap;
char *old_err_string = NULL;
if (ldb->err_string) {
talloc_free(ldb->err_string);
old_err_string = ldb->err_string;
}
va_start(ap, format);
ldb->err_string = talloc_vasprintf(ldb, format, ap);
va_end(ap);
TALLOC_FREE(old_err_string);
if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_asprintf/set_errstring: %s",
ldb->err_string);
......@@ -594,7 +596,9 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if ((handle->status != LDB_SUCCESS) &&
(handle->ldb->err_string == NULL)) {
/* if no error string was setup by the backend */
ldb_asprintf_errstring(handle->ldb, "ldb_wait: %s (%d)",
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_ASYNC_DONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
}
......@@ -612,19 +616,21 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if (ret != 0) {
return ldb_operr(handle->ldb);
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
ldb_strerror(handle->status),
handle->status);
}
if (handle->status == LDB_SUCCESS) {
return LDB_SUCCESS;
}
if (handle->ldb->err_string != NULL) {
return handle->status;
}
break;
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_WAIT_NONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
case LDB_WAIT_ALL:
while (handle->state != LDB_ASYNC_DONE) {
......@@ -633,32 +639,38 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
return ldb_operr(handle->ldb);
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the
* backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
ldb_strerror(handle->status),
handle->status);
if (handle->ldb->err_string != NULL) {
return handle->status;
}
return handle->status;
}
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the backend
* if no error string was setup by the
* backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
"ldb_wait from %s with "
"LDB_WAIT_ALL: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
}
}
if (handle->status == LDB_SUCCESS) {
return LDB_SUCCESS;
}
if (handle->ldb->err_string != NULL) {
return handle->status;
}
break;
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_WAIT_ALL,"
" LDB_ASYNC_DONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
}
return LDB_SUCCESS;
......
This diff is collapsed.
......@@ -54,7 +54,7 @@ struct ldb_dn_component {
struct ldb_dn_ext_component {
char *name;
const char *name;
struct ldb_val value;
};
......@@ -171,7 +171,7 @@ struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx,
char *strdn;
va_list ap;
if ( (! mem_ctx) || (! ldb)) return NULL;
if (! ldb) return NULL;
va_start(ap, new_fmt);
strdn = talloc_vasprintf(mem_ctx, new_fmt, ap);
......@@ -408,11 +408,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
goto failed;
}
dn->ext_components[dn->ext_comp_num].name = talloc_strdup(dn->ext_components, ex_name);
if (!dn->ext_components[dn->ext_comp_num].name) {
/* ouch */
goto failed;
}
dn->ext_components[dn->ext_comp_num].name = ext_syntax->name;
ret = ext_syntax->read_fn(dn->ldb, dn->ext_components,
&ex_val, &dn->ext_components[dn->ext_comp_num].value);
if (ret != LDB_SUCCESS) {
......@@ -586,6 +582,12 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
p++;
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above
*/
dn->components[dn->comp_num].value.data = \
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
dn->components[dn->comp_num].value.length = l;
......@@ -708,6 +710,11 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
}
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above.
*/
dn->components[dn->comp_num].value.length = l;
dn->components[dn->comp_num].value.data =
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
......@@ -1901,17 +1908,37 @@ int ldb_dn_set_component(struct ldb_dn *dn, int num,
return LDB_ERR_OTHER;
}
if (num < 0) {
return LDB_ERR_OTHER;
}
if (val.length > val.length + 1) {
return LDB_ERR_OTHER;
}
n = talloc_strdup(dn, name);
if ( ! n) {
return LDB_ERR_OTHER;
}
v.length = val.length;
v.data = (uint8_t *)talloc_memdup(dn, val.data, v.length+1);
/*
* This is like talloc_memdup(dn, v.data, v.length + 1), but
* avoids the over-read
*/
v.data = (uint8_t *)talloc_size(dn, v.length+1);
if ( ! v.data) {
talloc_free(n);
return LDB_ERR_OTHER;
}
memcpy(v.data, val.data, val.length);
/*
* Enforce NUL termination outside the stated length, as is
* traditional in LDB
*/
v.data[v.length] = '\0';
talloc_free(dn->components[num].name);
talloc_free(dn->components[num].value.data);
......@@ -1959,12 +1986,14 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
struct ldb_dn_ext_component *p;
unsigned int i;
struct ldb_val v2;
const struct ldb_dn_extended_syntax *ext_syntax;
if ( ! ldb_dn_validate(dn)) {
return LDB_ERR_OTHER;
}
if (!ldb_dn_extended_syntax_by_name(dn->ldb, name)) {
ext_syntax = ldb_dn_extended_syntax_by_name(dn->ldb, name);
if (ext_syntax == NULL) {
/* We don't know how to handle this type of thing */
return LDB_ERR_INVALID_DN_SYNTAX;
}
......@@ -1975,10 +2004,8 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
dn->ext_components[i].value =
ldb_val_dup(dn->ext_components, val);
dn->ext_components[i].name =
talloc_strdup(dn->ext_components, name);
if (!dn->ext_components[i].name ||
!dn->ext_components[i].value.data) {
dn->ext_components[i].name = ext_syntax->name;
if (!dn->ext_components[i].value.data) {
ldb_dn_mark_invalid(dn);
return LDB_ERR_OPERATIONS_ERROR;
}
......@@ -2139,7 +2166,6 @@ bool ldb_dn_minimise(struct ldb_dn *dn)
*/
for (i = 1; i < dn->ext_comp_num; i++) {
LDB_FREE(dn->ext_components[i].name);
LDB_FREE(dn->ext_components[i].value.data);
}
dn->ext_comp_num = 1;
......
/*
/*
ldb database library
Copyright (C) Andrew Tridgell 2004
......@@ -6,7 +6,7 @@
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
......@@ -39,7 +39,7 @@
#include "system/locale.h"
/*
*/
static int ldb_read_data_file(TALLOC_CTX *mem_ctx, struct ldb_val *value)
{
......@@ -236,7 +236,7 @@ static int fold_string(int (*fprintf_fn)(void *, const char *, ...), void *priva
encode as base64 to a file
*/
static int base64_encode_f(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const char *buf, int len, int start_pos)
{
......@@ -273,9 +273,9 @@ static const struct {
write to ldif, using a caller supplied write method, and only printing secrets if we are not in a trace
*/
static int ldb_ldif_write_trace(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const struct ldb_ldif *ldif,
const struct ldb_ldif *ldif,
bool in_trace)
{
TALLOC_CTX *mem_ctx;
......@@ -324,20 +324,20 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
if (ldif->changetype == LDB_CHANGETYPE_MODIFY) {
switch (msg->elements[i].flags & LDB_FLAG_MOD_MASK) {
case LDB_FLAG_MOD_ADD:
fprintf_fn(private_data, "add: %s\n",
fprintf_fn(private_data, "add: %s\n",
msg->elements[i].name);
break;
case LDB_FLAG_MOD_DELETE:
fprintf_fn(private_data, "delete: %s\n",
fprintf_fn(private_data, "delete: %s\n",
msg->elements[i].name);
break;
case LDB_FLAG_MOD_REPLACE:
fprintf_fn(private_data, "replace: %s\n",
fprintf_fn(private_data, "replace: %s\n",
msg->elements[i].name);
break;
}
}
if (in_trace && secret_attributes && ldb_attr_in_list(secret_attributes, msg->elements[i].name)) {
/* Deliberatly skip printing this password */
ret = fprintf_fn(private_data, "# %s::: REDACTED SECRET ATTRIBUTE\n",
......@@ -348,18 +348,26 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
for (j=0;j<msg->elements[i].num_values;j++) {
struct ldb_val v;
bool use_b64_encode;
bool use_b64_encode = false;
ret = a->syntax->ldif_write_fn(ldb, mem_ctx, &msg->elements[i].values[j], &v);
if (ret != LDB_SUCCESS) {
v = msg->elements[i].values[j];
}
use_b64_encode = !(ldb->flags & LDB_FLG_SHOW_BINARY)
&& ldb_should_b64_encode(ldb, &v);
if (ldb->flags & LDB_FLG_SHOW_BINARY) {
use_b64_encode = false;
} else if (a->flags & LDB_ATTR_FLAG_FORCE_BASE64_LDIF) {
use_b64_encode = true;
} else {
use_b64_encode = ldb_should_b64_encode(ldb, &v);
}
if (ret != LDB_SUCCESS || use_b64_encode) {
ret = fprintf_fn(private_data, "%s:: ",
ret = fprintf_fn(private_data, "%s:: ",
msg->elements[i].name);
CHECK_RET;
ret = base64_encode_f(ldb, fprintf_fn, private_data,
ret = base64_encode_f(ldb, fprintf_fn, private_data,
(char *)v.data, v.length,
strlen(msg->elements[i].name)+3);
CHECK_RET;
......@@ -369,7 +377,7 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
ret = fprintf_fn(private_data, "%s: ", msg->elements[i].name);
CHECK_RET;
if (ldb->flags & LDB_FLG_SHOW_BINARY) {
ret = fprintf_fn(private_data, "%*.*s",
ret = fprintf_fn(private_data, "%*.*s",
v.length, v.length, (char *)v.data);
} else {
ret = fold_string(fprintf_fn, private_data,
......@@ -403,7 +411,7 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
write to ldif, using a caller supplied write method
*/
int ldb_ldif_write(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const struct ldb_ldif *ldif)
{
......@@ -417,7 +425,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
caller frees
*/
static char *next_chunk(struct ldb_context *ldb,
static char *next_chunk(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
int (*fgetc_fn)(void *), void *private_data)
{
size_t alloc_size=0, chunk_size = 0;
......@@ -429,7 +437,7 @@ static char *next_chunk(struct ldb_context *ldb,
if (chunk_size+1 >= alloc_size) {
char *c2;
alloc_size += 1024;
c2 = talloc_realloc(ldb, chunk, char, alloc_size);
c2 = talloc_realloc(mem_ctx, chunk, char, alloc_size);
if (!c2) {
talloc_free(chunk);
errno = ENOMEM;
......@@ -442,15 +450,15 @@ static char *next_chunk(struct ldb_context *ldb,
if (c == '\n') {
in_comment = 0;
}
continue;
continue;
}
/* handle continuation lines - see RFC2849 */
if (c == ' ' && chunk_size > 1 && chunk[chunk_size-1] == '\n') {
chunk_size--;
continue;
}
/* chunks are terminated by a double line-feed */
if (c == '\n' && chunk_size > 0 && chunk[chunk_size-1] == '\n') {
chunk[chunk_size-1] = 0;
......@@ -774,18 +782,17 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
msg->elements = NULL;
msg->num_elements = 0;
chunk = next_chunk(ldb, fgetc_fn, private_data);
chunk = next_chunk(ldb, ldif, fgetc_fn, private_data);
if (!chunk) {
goto failed;
}
talloc_steal(ldif, chunk);
s = chunk;
if (next_attr(ldif, &s, &attr, &value) != 0) {
goto failed;
}
/* first line must be a dn */
if (ldb_attr_cmp(attr, "dn") != 0) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "Error: First line of ldif must be a dn not '%s'",
......@@ -845,7 +852,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
}
continue;
}
el = &msg->elements[msg->num_elements-1];
a = ldb_schema_attribute_by_name(ldb, attr);
......@@ -853,8 +860,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
if (msg->num_elements > 0 && ldb_attr_cmp(attr, el->name) == 0 &&
flags == el->flags) {
/* its a continuation */
el->values =