summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/replace/config.m42
-rw-r--r--source4/lib/ldb/replace/replace.c17
2 files changed, 18 insertions, 1 deletions
diff --git a/source4/lib/ldb/replace/config.m4 b/source4/lib/ldb/replace/config.m4
index ebc2568658..2d21d1b315 100644
--- a/source4/lib/ldb/replace/config.m4
+++ b/source4/lib/ldb/replace/config.m4
@@ -5,7 +5,7 @@ AC_CHECK_TYPE(uint64_t, unsigned long long)
AC_CHECK_TYPE(comparison_fn_t,
[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
-AC_CHECK_FUNCS(strerror timegm strnlen)
+AC_CHECK_FUNCS(strerror timegm strnlen setenv)
AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
AC_HAVE_DECL(errno, [#include <errno.h>])
diff --git a/source4/lib/ldb/replace/replace.c b/source4/lib/ldb/replace/replace.c
index 2c2068f8f4..e2df7fe363 100644
--- a/source4/lib/ldb/replace/replace.c
+++ b/source4/lib/ldb/replace/replace.c
@@ -67,3 +67,20 @@
}
#endif
+#ifndef HAVE_SETENV
+ int setenv(const char *name, const char *value, int overwrite)
+{
+ char *p = NULL;
+ int ret = -1;
+
+ asprintf(&p, "%s=%s", name, value);
+
+ if (overwrite || getenv(name)) {
+ if (p) ret = putenv(p);
+ } else {
+ ret = 0;
+ }
+
+ return ret;
+}
+#endif