summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/events/events_signal.c2
-rw-r--r--source4/lib/ldb/Makefile.in2
-rw-r--r--source4/lib/ldb/common/ldb.c2
-rw-r--r--source4/lib/ldb/include/ldb_includes.h1
-rw-r--r--source4/lib/ldb/include/ldb_private.h2
-rw-r--r--source4/lib/ldb/ldb.i34
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c6
-rw-r--r--source4/lib/ldb/ldb_wrap.c65
-rw-r--r--source4/lib/ldb/rules.mk2
-rw-r--r--source4/lib/ldb/tests/sample_module.c2
-rwxr-xr-xsource4/lib/ldb/tests/test-soloading.sh2
-rw-r--r--source4/lib/messaging/messaging.c2
-rw-r--r--source4/lib/registry/registry_wrap.c26
-rw-r--r--source4/lib/replace/README2
-rw-r--r--source4/lib/replace/configure.ac3
-rw-r--r--source4/lib/replace/getifaddrs.m411
-rw-r--r--source4/lib/replace/getpass.c8
-rw-r--r--source4/lib/replace/inet_aton.c33
-rw-r--r--source4/lib/replace/inet_aton.m41
-rw-r--r--source4/lib/replace/inet_ntoa.c39
-rw-r--r--source4/lib/replace/inet_ntoa.m419
-rw-r--r--source4/lib/replace/libreplace.m423
-rw-r--r--source4/lib/replace/replace.c37
-rw-r--r--source4/lib/replace/replace.h9
-rw-r--r--source4/lib/replace/samba.m43
-rw-r--r--source4/lib/replace/snprintf.c2
-rw-r--r--source4/lib/replace/socket.m415
-rw-r--r--source4/lib/replace/socketpair.c46
-rw-r--r--source4/lib/replace/socketpair.m41
-rw-r--r--source4/lib/replace/system/network.h14
-rw-r--r--source4/lib/replace/test/os2_delete.c9
-rw-r--r--source4/lib/socket/config.m444
-rw-r--r--source4/lib/socket/config.mk6
-rw-r--r--source4/lib/socket_wrapper/config.mk2
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c79
-rw-r--r--source4/lib/util/config.mk4
36 files changed, 332 insertions, 226 deletions
diff --git a/source4/lib/events/events_signal.c b/source4/lib/events/events_signal.c
index aec34339c3..c0771cbe01 100644
--- a/source4/lib/events/events_signal.c
+++ b/source4/lib/events/events_signal.c
@@ -257,7 +257,7 @@ int common_event_check_signal(struct event_context *ev)
for (j=0;j<count;j++) {
/* note the use of the sig_info array as a
ring buffer */
- int ofs = (counter.count + j) % SA_INFO_QUEUE_COUNT;
+ int ofs = ((count-1) + j) % SA_INFO_QUEUE_COUNT;
se->handler(ev, se, i, 1,
(void*)&sig_state->sig_info[i][ofs],
se->private_data);
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index d88f82b726..a53c5542da 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -121,7 +121,7 @@ distclean:: clean
rm -f Makefile
realdistclean:: distclean
- rm -f configure.in include/config.h.in
+ rm -f configure include/config.h.in
check:: test @PYTHON_CHECK_TARGET@
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 3c9ef3ff69..b51c288993 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -65,7 +65,7 @@ static struct backends_list_entry {
#ifdef HAVE_LDB_LDAP
#define LDAP_INIT &ldb_ldap_backend_ops, \
- &ldb_ildap_backend_ops, \
+ &ldb_ldapi_backend_ops, \
&ldb_ldaps_backend_ops,
#else
#define LDAP_INIT
diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h
index e2bcca2b04..cc9b46ac1f 100644
--- a/source4/lib/ldb/include/ldb_includes.h
+++ b/source4/lib/ldb/include/ldb_includes.h
@@ -18,7 +18,6 @@
#include "replace.h"
#include "system/filesys.h"
-#include "system/network.h"
#include "system/time.h"
#include "talloc.h"
#include "ldb.h"
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 880aafd593..ea8533bc38 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -200,7 +200,7 @@ extern const struct ldb_module_ops ldb_ranged_results_module_ops;
extern const struct ldb_backend_ops ldb_tdb_backend_ops;
extern const struct ldb_backend_ops ldb_sqlite3_backend_ops;
extern const struct ldb_backend_ops ldb_ldap_backend_ops;
-extern const struct ldb_backend_ops ldb_ildap_backend_ops;
+extern const struct ldb_backend_ops ldb_ldapi_backend_ops;
extern const struct ldb_backend_ops ldb_ldaps_backend_ops;
int ldb_match_msg(struct ldb_context *ldb,
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 0d9679d21e..e01a1107d2 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -257,12 +257,19 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
int ret;
struct ldb_dn *odn;
if (ldb_ctx != NULL && PyString_Check(object)) {
- *dn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
+ odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
+ if (!odn) {
+ return SWIG_ERROR;
+ }
+ *dn = odn;
return 0;
}
ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn,
SWIG_POINTER_EXCEPTION);
*dn = ldb_dn_copy(mem_ctx, odn);
+ if (odn && !*dn) {
+ return SWIG_ERROR;
+ }
return ret;
}
@@ -462,6 +469,8 @@ typedef struct ldb_ldif ldb_ldif;
#ifdef SWIGPYTHON
%{
+static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0);
+
static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap)
{
char *text;
@@ -557,22 +566,29 @@ PyObject *PyExc_LdbError;
};
%typemap(in,numinputs=1) ldb_msg *add_msg {
- int dict_pos, msg_pos;
- PyObject *key, *value;
+ Py_ssize_t dict_pos, msg_pos;
ldb_msg_element *msgel;
+ PyObject *key, *value;
if (PyDict_Check($input)) {
+ PyObject *dn_value = PyDict_GetItemString($input, "dn");
$1 = ldb_msg_new(NULL);
$1->elements = talloc_zero_array($1, struct ldb_message_element, PyDict_Size($input));
msg_pos = dict_pos = 0;
- while (PyDict_Next($input, &dict_pos, &key, &value)) {
- if (!strcmp(PyString_AsString(key), "dn")) {
- /* using argp0 (magic SWIG value) here is a hack */
- if (ldb_dn_from_pyobject($1, value, argp1, &$1->dn) != 0) {
+ if (dn_value) {
+ /* using argp1 (magic SWIG value) here is a hack */
+ if (ldb_dn_from_pyobject($1, dn_value, argp1, &$1->dn) != 0) {
SWIG_exception(SWIG_TypeError, "unable to import dn object");
}
- } else {
- msgel = ldb_msg_element_from_pyobject($1->elements, value, 0, PyString_AsString(key));
+ if ($1->dn == NULL) {
+ SWIG_exception(SWIG_TypeError, "dn set but not found");
+ }
+ }
+
+ while (PyDict_Next($input, &dict_pos, &key, &value)) {
+ char *key_str = PyString_AsString(key);
+ if (strcmp(key_str, "dn") != 0) {
+ msgel = ldb_msg_element_from_pyobject($1->elements, value, 0, key_str);
if (msgel == NULL) {
SWIG_exception(SWIG_TypeError, "unable to import element");
}
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 3f6ff3fd5b..a4534c549a 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -826,17 +826,17 @@ failed:
return -1;
}
-_PUBLIC_ struct ldb_backend_ops ldb_ldap_backend_ops = {
+const struct ldb_backend_ops ldb_ldap_backend_ops = {
.name = "ldap",
.connect_fn = lldb_connect
};
-_PUBLIC_ struct ldb_backend_ops ldb_ldapi_backend_ops = {
+const struct ldb_backend_ops ldb_ldapi_backend_ops = {
.name = "ldapi",
.connect_fn = lldb_connect
};
-_PUBLIC_ struct ldb_backend_ops ldb_ldaps_backend_ops = {
+const struct ldb_backend_ops ldb_ldaps_backend_ops = {
.name = "ldaps",
.connect_fn = lldb_connect
};
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index cf05048b02..082c6d9cad 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2471,7 +2471,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_ldb_module_ops swig_types[9]
#define SWIGTYPE_p_ldb_result swig_types[10]
#define SWIGTYPE_p_ldb_val swig_types[11]
-#define SWIGTYPE_p_long_long swig_types[12]
+#define SWIGTYPE_p_long swig_types[12]
#define SWIGTYPE_p_p_char swig_types[13]
#define SWIGTYPE_p_p_ldb_control swig_types[14]
#define SWIGTYPE_p_p_ldb_result swig_types[15]
@@ -2480,11 +2480,10 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_unsigned_char swig_types[18]
#define SWIGTYPE_p_unsigned_int swig_types[19]
#define SWIGTYPE_p_unsigned_long swig_types[20]
-#define SWIGTYPE_p_unsigned_long_long swig_types[21]
-#define SWIGTYPE_p_unsigned_short swig_types[22]
-#define SWIGTYPE_p_void swig_types[23]
-static swig_type_info *swig_types[25];
-static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
+#define SWIGTYPE_p_unsigned_short swig_types[21]
+#define SWIGTYPE_p_void swig_types[22]
+static swig_type_info *swig_types[24];
+static swig_module_info swig_module = {swig_types, 23, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2713,12 +2712,19 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
int ret;
struct ldb_dn *odn;
if (ldb_ctx != NULL && PyString_Check(object)) {
- *dn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
+ odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
+ if (!odn) {
+ return SWIG_ERROR;
+ }
+ *dn = odn;
return 0;
}
ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn,
SWIG_POINTER_EXCEPTION);
*dn = ldb_dn_copy(mem_ctx, odn);
+ if (odn && !*dn) {
+ return SWIG_ERROR;
+ }
return ret;
}
@@ -2992,6 +2998,8 @@ SWIGINTERN PyObject *ldb_msg___iter__(ldb_msg *self){
return PyObject_GetIter(ldb_msg_list_elements(self));
}
+static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0);
+
static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap)
{
char *text;
@@ -4708,22 +4716,29 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
}
arg1 = (ldb *)(argp1);
{
- int dict_pos, msg_pos;
- PyObject *key, *value;
+ Py_ssize_t dict_pos, msg_pos;
ldb_msg_element *msgel;
+ PyObject *key, *value;
if (PyDict_Check(obj1)) {
+ PyObject *dn_value = PyDict_GetItemString(obj1, "dn");
arg2 = ldb_msg_new(NULL);
arg2->elements = talloc_zero_array(arg2, struct ldb_message_element, PyDict_Size(obj1));
msg_pos = dict_pos = 0;
+ if (dn_value) {
+ /* using argp1 (magic SWIG value) here is a hack */
+ if (ldb_dn_from_pyobject(arg2, dn_value, argp1, &arg2->dn) != 0) {
+ SWIG_exception(SWIG_TypeError, "unable to import dn object");
+ }
+ if (arg2->dn == NULL) {
+ SWIG_exception(SWIG_TypeError, "dn set but not found");
+ }
+ }
+
while (PyDict_Next(obj1, &dict_pos, &key, &value)) {
- if (!strcmp(PyString_AsString(key), "dn")) {
- /* using argp0 (magic SWIG value) here is a hack */
- if (ldb_dn_from_pyobject(arg2, value, argp1, &arg2->dn) != 0) {
- SWIG_exception(SWIG_TypeError, "unable to import dn object");
- }
- } else {
- msgel = ldb_msg_element_from_pyobject(arg2->elements, value, 0, PyString_AsString(key));
+ char *key_str = PyString_AsString(key);
+ if (strcmp(key_str, "dn") != 0) {
+ msgel = ldb_msg_element_from_pyobject(arg2->elements, value, 0, key_str);
if (msgel == NULL) {
SWIG_exception(SWIG_TypeError, "unable to import element");
}
@@ -5696,7 +5711,7 @@ static PyMethodDef SwigMethods[] = {
static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_void_enum_ldb_debug_level_p_q_const__char_va_list__void = {"_p_f_p_void_enum_ldb_debug_level_p_q_const__char_va_list__void", "void (*)(void *,enum ldb_debug_level,char const *,va_list)", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int *|int_least32_t *|int32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_context *|ldb *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
@@ -5705,16 +5720,15 @@ static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element",
static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_long = {"_p_long", "intptr_t *|int_least64_t *|int_fast32_t *|int_fast64_t *|int64_t *|long *|int_fast16_t *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_ldb_control = {"_p_p_ldb_control", "struct ldb_control **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_ldb_result = {"_p_p_ldb_result", "struct ldb_result **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "unsigned long *|time_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uint_least32_t *|uint32_t *|unsigned int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "uintptr_t *|uint_least64_t *|uint_fast32_t *|uint_fast64_t *|uint64_t *|unsigned long *|time_t *|uint_fast16_t *|uintmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -5731,7 +5745,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_ldb_module_ops,
&_swigt__p_ldb_result,
&_swigt__p_ldb_val,
- &_swigt__p_long_long,
+ &_swigt__p_long,
&_swigt__p_p_char,
&_swigt__p_p_ldb_control,
&_swigt__p_p_ldb_result,
@@ -5740,7 +5754,6 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_unsigned_char,
&_swigt__p_unsigned_int,
&_swigt__p_unsigned_long,
- &_swigt__p_unsigned_long_long,
&_swigt__p_unsigned_short,
&_swigt__p_void,
};
@@ -5757,7 +5770,7 @@ static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_messa
static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_ldb_control[] = { {&_swigt__p_p_ldb_control, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_ldb_result[] = { {&_swigt__p_p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
@@ -5766,7 +5779,6 @@ static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0
static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -5783,7 +5795,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_ldb_module_ops,
_swigc__p_ldb_result,
_swigc__p_ldb_val,
- _swigc__p_long_long,
+ _swigc__p_long,
_swigc__p_p_char,
_swigc__p_p_ldb_control,
_swigc__p_p_ldb_result,
@@ -5792,7 +5804,6 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_unsigned_char,
_swigc__p_unsigned_int,
_swigc__p_unsigned_long,
- _swigc__p_unsigned_long_long,
_swigc__p_unsigned_short,
_swigc__p_void,
};
diff --git a/source4/lib/ldb/rules.mk b/source4/lib/ldb/rules.mk
index 534ba016ab..ff5dc02742 100644
--- a/source4/lib/ldb/rules.mk
+++ b/source4/lib/ldb/rules.mk
@@ -7,7 +7,7 @@ ctags:
.SUFFIXES: _wrap.c .i
.i_wrap.c:
- [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -python -keyword $<
+ [ "$(SWIG)" = "no" ] || $(SWIG) -O -Wall -python -keyword $<
.SUFFIXES: .1 .1.xml .3 .3.xml .xml .html .c .o
diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c
index 98d8e865dd..1a9e72c907 100644
--- a/source4/lib/ldb/tests/sample_module.c
+++ b/source4/lib/ldb/tests/sample_module.c
@@ -32,7 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req)
return ldb_next_request(mod, req);
}
-_PUBLIC_ const struct ldb_module_ops ldb_sample_module_ops = {
+const struct ldb_module_ops ldb_sample_module_ops = {
.name = "sample",
.add = sample_add,
};
diff --git a/source4/lib/ldb/tests/test-soloading.sh b/source4/lib/ldb/tests/test-soloading.sh
index c42c9b22ba..da6d57541e 100755
--- a/source4/lib/ldb/tests/test-soloading.sh
+++ b/source4/lib/ldb/tests/test-soloading.sh
@@ -19,7 +19,7 @@ fi
cat <<EOF | $VALGRIND ldbadd || exit 1
dn: @MODULES
-@LIST: sample_module
+@LIST: sample
EOF
cat <<EOF | $VALGRIND ldbadd || exit 1
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 6a879ab962..29d6e00247 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -462,6 +462,8 @@ NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
rec->retries = 0;
rec->msg = msg;
rec->header = (struct messaging_header *)rec->packet.data;
+ /* zero padding */
+ ZERO_STRUCTP(rec->header);
rec->header->version = MESSAGING_VERSION;
rec->header->msg_type = msg_type;
rec->header->from = msg->server_id;
diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c
index c5741b7e2c..51c255e9f7 100644
--- a/source4/lib/registry/registry_wrap.c
+++ b/source4/lib/registry/registry_wrap.c
@@ -2950,7 +2950,7 @@ SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
}
result = reg_open_local(arg1,arg2,arg3,arg4);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3001,7 +3001,7 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key_by_name(PyObject *SWIGUNUSEDPA
arg3 = (struct registry_key **)(argp3);
result = reg_get_predefined_key_by_name(arg1,(char const *)arg2,arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3044,7 +3044,7 @@ SWIGINTERN PyObject *_wrap_reg_key_del_abs(PyObject *SWIGUNUSEDPARM(self), PyObj
arg2 = (char *)(buf2);
result = reg_key_del_abs(arg1,(char const *)arg2);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3095,7 +3095,7 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key(PyObject *SWIGUNUSEDPARM(self)
arg3 = (struct registry_key **)(argp3);
result = reg_get_predefined_key(arg1,arg2,arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3136,7 +3136,7 @@ SWIGINTERN PyObject *_wrap_reg_diff_apply(PyObject *SWIGUNUSEDPARM(self), PyObje
arg2 = (char *)(buf2);
result = reg_diff_apply(arg1,(char const *)arg2);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3194,7 +3194,7 @@ SWIGINTERN PyObject *_wrap_reg_generate_diff(PyObject *SWIGUNUSEDPARM(self), PyO
}
result = reg_generate_diff(arg1,arg2,(struct reg_diff_callbacks const *)arg3,arg4);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3260,7 +3260,7 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_0(PyObject *SWIGUNUSEDPARM(self)
}
result = reg_mount_hive(arg1,arg2,arg3,(char const **)arg4);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3373,7 +3373,7 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_1(PyObject *SWIGUNUSEDPARM(self)
arg3 = (char *)(buf3);
result = reg_mount_hive__SWIG_1(arg1,arg2,(char const *)arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3524,7 +3524,7 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
}
result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3601,7 +3601,7 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
}
result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3642,7 +3642,7 @@ SWIGINTERN PyObject *_wrap_create_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *
arg2 = (char *)(buf2);
result = reg_create_directory(arg1,(char const *)arg2,arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3683,7 +3683,7 @@ SWIGINTERN PyObject *_wrap_open_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg2 = (char *)(buf2);
result = reg_open_directory(arg1,(char const *)arg2,arg3);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
@@ -3750,7 +3750,7 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
}
result = reg_open_samba(arg1,arg2,arg3,arg4,arg5);
if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", (&result)->v, win_errstr(result));
+ PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
SWIG_fail;
} else if (resultobj == NULL) {
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index 268a1b15cf..43f7b08572 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -15,7 +15,6 @@ rename
initgroups
memmove
strdup
-inet_ntoa
setlinebuf
vsyslog
timegm
@@ -52,6 +51,7 @@ readline (the library)
inet_ntoa
inet_ntop
inet_pton
+inet_aton
strtoll
strtoull
socketpair
diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac
index f5e054f476..02dc08bf72 100644
--- a/source4/lib/replace/configure.ac
+++ b/source4/lib/replace/configure.ac
@@ -21,6 +21,9 @@ if test "$ac_cv_prog_gcc" = yes; then
CFLAGS="$CFLAGS -Wno-format-y2k"
fi
+LIBS="${LIBREPLACE_NETWORK_LIBS}"
+AC_SUBST(LIBS)
+
AC_SUBST(LDFLAGS)
AC_OUTPUT(Makefile)
diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4
index 6cca155de3..927bc677db 100644
--- a/source4/lib/replace/getifaddrs.m4
+++ b/source4/lib/replace/getifaddrs.m4
@@ -34,10 +34,12 @@ fi
##################
# look for a method of finding the list of network interfaces
#
-# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS"
+# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
#
old_LIBS=$LIBS
-LIBS="$NSL_LIBS $SOCKET_LIBS"
+LIBS="${LIBREPLACE_NETWORK_LIBS}"
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$libreplacedir"
iface=no;
##################
# look for a method of finding the list of network interfaces
@@ -79,7 +81,6 @@ AC_TRY_RUN([
libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
- old_LIBS="$old_LIBS $LIBS"
fi
fi
@@ -100,7 +101,6 @@ AC_TRY_RUN([
libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
- old_LIBS="$old_LIBS $LIBS"
fi
fi
@@ -120,8 +120,9 @@ AC_TRY_RUN([
libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
- old_LIBS="$old_LIBS $LIBS"
fi
fi
LIBS=$old_LIBS
+CPPFLAGS="$SAVE_CPPFLAGS"
+
diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c
index d91d029f6a..73333b9021 100644
--- a/source4/lib/replace/getpass.c
+++ b/source4/lib/replace/getpass.c
@@ -185,7 +185,13 @@ char *rep_getpass(const char *prompt)
buf[0] = 0;
if (!gotintr) {
in_fd = fileno(in);
- fgets(buf, bufsize, in);
+ if (fgets(buf, bufsize, in) == NULL) {
+ buf[0] = 0;
+ if (in && in != stdin) {
+ fclose(in);
+ }
+ return buf;
+ }
}
nread = strlen(buf);
if (nread) {
diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c
new file mode 100644
index 0000000000..c6b3bb11a7
--- /dev/null
+++ b/source4/lib/replace/inet_aton.c
@@ -0,0 +1,33 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * replacement functions
+ * Copyright (C) Michael Adam <obnox@samba.org> 2008
+ *
+ * ** NOTE! The following LGPL license applies to the replace
+ * ** 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
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "system/network.h"
+
+/**
+ * We know that we have inet_pton from earlier libreplace checks.
+ */
+int rep_inet_aton(const char *src, struct in_addr *dst)
+{
+ return (inet_pton(AF_INET, src, dst) > 0) ? 1 : 0;
+}
diff --git a/source4/lib/replace/inet_aton.m4 b/source4/lib/replace/inet_aton.m4
new file mode 100644
index 0000000000..853688ef6b
--- /dev/null
+++ b/source4/lib/replace/inet_aton.m4
@@ -0,0 +1 @@
+AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"])
diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c
new file mode 100644
index 0000000000..e3b80ebef8
--- /dev/null
+++ b/source4/lib/replace/inet_ntoa.c
@@ -0,0 +1,39 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * replacement routines for broken systems
+ * Copyright (C) Andrew Tridgell 2003
+ * Copyright (C) Michael Adam 2008
+ *
+ * ** NOTE! The following LGPL license applies to the replace
+ * ** 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
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "system/network.h"
+
+/**
+ * NOTE: this is not thread safe, but it can't be, either
+ * since it returns a pointer to static memory.
+ */
+char *rep_inet_ntoa(struct in_addr ip)
+{
+ uint8_t *p = (uint8_t *)&ip.s_addr;
+ static char buf[18];
+ slprintf(buf, 17, "%d.%d.%d.%d",
+ (int)p[0], (int)p[1], (int)p[2], (int)p[3]);
+ return buf;
+}
diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4
new file mode 100644
index 0000000000..5aaa9350c5
--- /dev/null
+++ b/source4/lib/replace/inet_ntoa.m4
@@ -0,0 +1,19 @@
+AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"])
+
+AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
+AC_TRY_RUN([
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+main() { struct in_addr ip; ip.s_addr = 0x12345678;
+if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
+ strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
+exit(1);}],
+ libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
+if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
+ AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
+fi
diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4
index e0cc57f4c8..8e17258918 100644
--- a/source4/lib/replace/libreplace.m4
+++ b/source4/lib/replace/libreplace.m4
@@ -120,24 +120,6 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
fi
-AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
-AC_TRY_RUN([
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-main() { struct in_addr ip; ip.s_addr = 0x12345678;
-if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
- strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
-exit(1);}],
- libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
-if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
- AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
-fi
-
AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
@@ -176,7 +158,7 @@ fi
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
AC_CHECK_FUNCS(isatty)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
@@ -347,9 +329,12 @@ m4_include(timegm.m4)
m4_include(socket.m4)
m4_include(inet_ntop.m4)
m4_include(inet_pton.m4)
+m4_include(inet_aton.m4)
+m4_include(inet_ntoa.m4)
m4_include(getaddrinfo.m4)
m4_include(repdir.m4)
m4_include(getifaddrs.m4)
+m4_include(socketpair.m4)
AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])])
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index b2a240e8ab..6930f9b079 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -27,7 +27,6 @@
#include "system/time.h"
#include "system/passwd.h"
#include "system/syslog.h"
-#include "system/network.h"
#include "system/locale.h"
#include "system/wait.h"
@@ -295,20 +294,6 @@ char *rep_strdup(const char *s)
}
#endif /* HAVE_STRDUP */
-#ifndef WITH_PTHREADS
-/* REWRITE: not thread safe */
-#ifdef REPLACE_INET_NTOA
-char *rep_inet_ntoa(struct in_addr ip)
-{
- uint8_t *p = (uint8_t *)&ip.s_addr;
- static char buf[18];
- slprintf(buf, 17, "%d.%d.%d.%d",
- (int)p[0], (int)p[1], (int)p[2], (int)p[3]);
- return buf;
-}
-#endif /* REPLACE_INET_NTOA */
-#endif
-
#ifndef HAVE_SETLINEBUF
void rep_setlinebuf(FILE *stream)
{
@@ -599,25 +584,3 @@ int rep_unsetenv(const char *name)
return 0;
}
#endif
-
-#ifndef HAVE_SOCKETPAIR
-int rep_socketpair(int d, int type, int protocol, int sv[2])
-{
- if (d != AF_UNIX) {
- errno = EAFNOSUPPORT;
- return -1;
- }
-
- if (protocol != 0) {
- errno = EPROTONOSUPPORT;
- return -1;
- }
-
- if (type != SOCK_STREAM) {
- errno = EOPNOTSUPP;
- return -1;
- }
-
- return pipe(sv);
-}
-#endif
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 0d16f4ffd0..5fe79394eb 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -212,7 +212,7 @@ int rep_dlclose(void *handle);
#ifndef HAVE_SOCKETPAIR
#define socketpair rep_socketpair
-int rep_socketpair(int d, int type, int protocol, int sv[2]);
+/* prototype is in system/network.h */
#endif
#ifndef PRINTF_ATTRIBUTE
@@ -325,7 +325,7 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset);
ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset);
#endif
-#ifdef REPLACE_INET_NTOA
+#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
#define inet_ntoa rep_inet_ntoa
/* prototype is in "system/network.h" */
#endif
@@ -340,6 +340,11 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
/* prototype is in "system/network.h" */
#endif
+#ifndef HAVE_INET_ATON
+#define inet_aton rep_inet_aton
+/* prototype is in "system/network.h" */
+#endif
+
#ifndef HAVE_CONNECT
#define connect rep_connect
/* prototype is in "system/network.h" */
diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4
index a2e04f53b1..e62c3d3cd1 100644
--- a/source4/lib/replace/samba.m4
+++ b/source4/lib/replace/samba.m4
@@ -3,6 +3,9 @@ AC_LIBREPLACE_BROKEN_CHECKS
SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}])
SMB_ENABLE(LIBREPLACE_EXT)
+SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}])
+SMB_ENABLE(LIBREPLACE_NETWORK)
+
# remove leading ./
LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c
index 9f8a7657e5..a174dcffed 100644
--- a/source4/lib/replace/snprintf.c
+++ b/source4/lib/replace/snprintf.c
@@ -1264,7 +1264,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
VA_COPY(ap2, ap);
ret = vsnprintf(NULL, 0, format, ap2);
va_end(ap2);
- if (ret <= 0) return ret;
+ if (ret < 0) return ret;
(*ptr) = (char *)malloc(ret+1);
if (!*ptr) return -1;
diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4
index c0c8f93e81..984f81f15f 100644
--- a/source4/lib/replace/socket.m4
+++ b/source4/lib/replace/socket.m4
@@ -7,10 +7,10 @@ dnl only looks in /etc/hosts), so we only look for -lsocket if we need
dnl it.
AC_CHECK_FUNCS(connect)
if test x"$ac_cv_func_connect" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect)
+ AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
dnl We can't just call AC_CHECK_FUNCS(connect) here,
dnl because the value has been cached.
if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
@@ -24,9 +24,9 @@ fi
AC_CHECK_FUNCS(gethostbyname)
if test x"$ac_cv_func_gethostbyname" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
dnl because the value has been cached.
if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
@@ -37,4 +37,3 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then
[Whether the system has gethostbyname()])
fi
fi
-
diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c
new file mode 100644
index 0000000000..c775730952
--- /dev/null
+++ b/source4/lib/replace/socketpair.c
@@ -0,0 +1,46 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * replacement routines for broken systems
+ * Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2006
+ * Copyright (C) Michael Adam <obnox@samba.org> 2008
+ *
+ * ** NOTE! The following LGPL license applies to the replace
+ * ** 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
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "system/network.h"
+
+int rep_socketpair(int d, int type, int protocol, int sv[2])
+{
+ if (d != AF_UNIX) {
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+
+ if (protocol != 0) {
+ errno = EPROTONOSUPPORT;
+ return -1;
+ }
+
+ if (type != SOCK_STREAM) {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+ return pipe(sv);
+}
diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4
new file mode 100644
index 0000000000..7088334cda
--- /dev/null
+++ b/source4/lib/replace/socketpair.m4
@@ -0,0 +1 @@
+AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"])
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
index 410c6d7cca..a5fb813aa1 100644
--- a/source4/lib/replace/system/network.h
+++ b/source4/lib/replace/system/network.h
@@ -88,7 +88,7 @@
typedef int socklen_t;
#endif
-#ifdef REPLACE_INET_NTOA
+#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
/* define is in "replace.h" */
char *rep_inet_ntoa(struct in_addr ip);
#endif
@@ -103,6 +103,11 @@ int rep_inet_pton(int af, const char *src, void *dst);
const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
#endif
+#ifndef HAVE_INET_ATON
+/* define is in "replace.h" */
+int rep_inet_aton(const char *src, struct in_addr *dst);
+#endif
+
#ifndef HAVE_CONNECT
/* define is in "replace.h" */
int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
@@ -138,6 +143,11 @@ int rep_getifaddrs(struct ifaddrs **);
void rep_freeifaddrs(struct ifaddrs *);
#endif
+#ifndef HAVE_SOCKETPAIR
+/* define is in "replace.h" */
+int rep_socketpair(int d, int type, int protocol, int sv[2]);
+#endif
+
/*
* Some systems have getaddrinfo but not the
* defines needed to use it.
@@ -305,7 +315,7 @@ struct addrinfo {
/* Needed for some systems that don't define it (Solaris). */
#ifndef ifr_netmask
-#define ifr_netmask ifr_addrs
+#define ifr_netmask ifr_addr
#endif
#ifdef SOCKET_WRAPPER
diff --git a/source4/lib/replace/test/os2_delete.c b/source4/lib/replace/test/os2_delete.c
index c6ef180017..b45c135355 100644
--- a/source4/lib/replace/test/os2_delete.c
+++ b/source4/lib/replace/test/os2_delete.c
@@ -39,8 +39,15 @@ static void create_files(void)
int i;
for (i=0;i<NUM_FILES;i++) {
char fname[40];
+ int fd;
sprintf(fname, TESTDIR "/test%u.txt", i);
- close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
+ fd = open(fname, O_CREAT|O_RDWR, 0600);
+ if (fd < 0) {
+ FAILED("open");
+ }
+ if (close(fd) != 0) {
+ FAILED("close");
+ }
}
}
diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4
index a713090c6d..b40002b321 100644
--- a/source4/lib/socket/config.m4
+++ b/source4/lib/socket/config.m4
@@ -11,50 +11,6 @@ if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
fi
-# The following test taken from the cvs sources
-# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
-# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
-# libsocket.so which has a bad implementation of gethostbyname (it
-# only looks in /etc/hosts), so we only look for -lsocket if we need
-# it.
-AC_CHECK_FUNCS(connect)
-if test x"$ac_cv_func_connect" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect)
- AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect)
- SMB_ENABLE(EXT_SOCKET,YES)
- dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
- dnl has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_inet_connect" = x"yes"; then
- AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
- else
- AC_MSG_ERROR([no connect() function available!])
- fi
-fi
-
-SMB_EXT_LIB(EXT_SOCKET,[${SOCKET_LIBS}],[${SOCKET_CFLAGS}],[${SOCKET_CPPFLAGS}],[${SOCKET_LDFLAGS}])
-
-AC_CHECK_FUNCS(gethostbyname)
-if test x"$ac_cv_func_gethostbyname" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname)
- SMB_ENABLE(EXT_NSL,YES)
- dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, because the value
- dnl has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" != x"yes" &&
- test x"$ac_cv_lib_ext_nsl_gethostbyname" != x"yes" &&
- test x"$ac_cv_lib_ext_socket_gethostbyname" != x"yes"; then
- AC_MSG_ERROR([no gethostbyname() function available!])
- fi
-fi
-
-SMB_EXT_LIB(EXT_NSL,[${NSL_LIBS}],[],[],[])
-
############################################
# check for unix domain sockets
AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk
index 354b1b5198..2400190175 100644
--- a/source4/lib/socket/config.mk
+++ b/source4/lib/socket/config.mk
@@ -2,7 +2,7 @@
# Start SUBSYSTEM LIBNETIF
[SUBSYSTEM::LIBNETIF]
PRIVATE_PROTO_HEADER = netif_proto.h
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL EXT_SOCKET EXT_NSL
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBREPLACE_NETWORK
# End SUBSYSTEM LIBNETIF
##############################
@@ -13,7 +13,7 @@ LIBNETIF_OBJ_FILES = $(addprefix lib/socket/, interface.o netif.o)
[MODULE::socket_ip]
SUBSYSTEM = samba-socket
OUTPUT_TYPE = MERGED_OBJ
-PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL LIBSAMBA-ERRORS
+PRIVATE_DEPENDENCIES = LIBSAMBA-ERRORS LIBREPLACE_NETWORK
# End MODULE socket_ip
################################################
@@ -24,7 +24,7 @@ socket_ip_OBJ_FILES = lib/socket/socket_ip.o
[MODULE::socket_unix]
SUBSYSTEM = samba-socket
OUTPUT_TYPE = MERGED_OBJ
-PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL
+PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK
# End MODULE socket_unix
################################################
diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk
index f7e874d8e2..75d3ade28b 100644
--- a/source4/lib/socket_wrapper/config.mk
+++ b/source4/lib/socket_wrapper/config.mk
@@ -1,7 +1,7 @@
##############################
# Start SUBSYSTEM SOCKET_WRAPPER
[SUBSYSTEM::SOCKET_WRAPPER]
-PRIVATE_DEPENDENCIES = EXT_SOCKET
+PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK
# End SUBSYSTEM SOCKET_WRAPPER
##############################
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index 644365a665..86d9f7a312 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -64,6 +64,7 @@
#include <unistd.h>
#include <string.h>
#include <stdio.h>
+#include <stdint.h>
#endif
@@ -624,67 +625,67 @@ enum swrap_packet_type {
};
struct swrap_file_hdr {
- unsigned long magic;
- unsigned short version_major;
- unsigned short version_minor;
- long timezone;
- unsigned long sigfigs;
- unsigned long frame_max_len;
+ uint32_t magic;
+ uint16_t version_major;
+ uint16_t version_minor;
+ int32_t timezone;
+ uint32_t sigfigs;
+ uint32_t frame_max_len;
#define SWRAP_FRAME_LENGTH_MAX 0xFFFF
- unsigned long link_type;
+ uint32_t link_type;
};
#define SWRAP_FILE_HDR_SIZE 24
struct swrap_packet {
struct {
- unsigned long seconds;
- unsigned long micro_seconds;
- unsigned long recorded_length;
- unsigned long full_length;
+ uint32_t seconds;
+ uint32_t micro_seconds;
+ uint32_t recorded_length;
+ uint32_t full_length;
} frame;
#define SWRAP_PACKET__FRAME_SIZE 16
struct {
struct {
- unsigned char ver_hdrlen;
- unsigned char tos;
- unsigned short packet_length;
- unsigned short identification;
- unsigned char flags;
- unsigned char fragment;
- unsigned char ttl;
- unsigned char protocol;
- unsigned short hdr_checksum;
- unsigned long src_addr;
- unsigned long dest_addr;
+ uint8_t ver_hdrlen;
+ uint8_t tos;
+ uint16_t packet_length;
+ uint16_t identification;
+ uint8_t flags;
+ uint8_t fragment;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t hdr_checksum;
+ uint32_t src_addr;
+ uint32_t dest_addr;
} hdr;
#define SWRAP_PACKET__IP_HDR_SIZE 20
union {
struct {
- unsigned short source_port;
- unsigned short dest_port;
- unsigned long seq_num;
- unsigned long ack_num;
- unsigned char hdr_length;
- unsigned char control;
- unsigned short window;
- unsigned short checksum;
- unsigned short urg;
+ uint16_t source_port;
+ uint16_t dest_port;
+ uint32_t seq_num;
+ uint32_t ack_num;
+ uint8_t hdr_length;
+ uint8_t control;
+ uint16_t window;
+ uint16_t checksum;
+ uint16_t urg;
} tcp;
#define SWRAP_PACKET__IP_P_TCP_SIZE 20
struct {
- unsigned short source_port;
- unsigned short dest_port;
- unsigned short length;
- unsigned short checksum;
+ uint16_t source_port;
+ uint16_t dest_port;
+ uint16_t length;
+ uint16_t checksum;
} udp;
#define SWRAP_PACKET__IP_P_UDP_SIZE 8
struct {
- unsigned char type;
- unsigned char code;
- unsigned short checksum;
- unsigned long unused;
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ uint32_t unused;
} icmp;
#define SWRAP_PACKET__IP_P_ICMP_SIZE 8
} p;
diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk
index b0978ca5f5..3afe398a8f 100644
--- a/source4/lib/util/config.mk
+++ b/source4/lib/util/config.mk
@@ -2,7 +2,8 @@
PUBLIC_DEPENDENCIES = \
LIBTALLOC LIBCRYPTO \
SOCKET_WRAPPER EXT_NSL \
- CHARSET EXECINFO DYNCONFIG
+ CHARSET EXECINFO DYNCONFIG \
+ LIBREPLACE_NETWORK
LIBSAMBA-UTIL_OBJ_FILES = $(addprefix lib/util/, \
xfile.o \
@@ -37,7 +38,6 @@ PUBLIC_HEADERS += $(addprefix lib/util/, util.h \
[SUBSYSTEM::ASN1_UTIL]
PRIVATE_PROTO_HEADER = asn1_proto.h
-
ASN1_UTIL_OBJ_FILES = lib/util/asn1.o
PUBLIC_HEADERS += lib/util/asn1.h