summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/m4/rewrite.m42
-rw-r--r--source4/heimdal_build/config.h5
-rw-r--r--source4/lib/replace/config.m42
-rw-r--r--source4/lib/replace/replace.c106
-rw-r--r--source4/ntvfs/unixuid/config.m457
5 files changed, 35 insertions, 137 deletions
diff --git a/source4/build/m4/rewrite.m4 b/source4/build/m4/rewrite.m4
index 792b4bcba6..ecde4ae329 100644
--- a/source4/build/m4/rewrite.m4
+++ b/source4/build/m4/rewrite.m4
@@ -121,7 +121,7 @@ AC_HAVE_DECL(snprintf, [#include <stdio.h>])
AC_FUNC_MEMCMP
-AC_CHECK_FUNCS(dlopen dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strtoull strtouq strerror chroot)
+AC_CHECK_FUNCS(dlopen dlsym dlerror waitpid getcwd strdup strndup strnlen strerror chroot)
AC_CHECK_FUNCS(bzero memset strlcpy strlcat)
AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid pipe crypt16 getauthuid)
AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h
index 5ce029e83c..c3737cb75e 100644
--- a/source4/heimdal_build/config.h
+++ b/source4/heimdal_build/config.h
@@ -45,4 +45,9 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg }
#include "lib/replace/replace.h"
#endif
+/* we need to tell roken about the functions that Samba replaces in lib/replace */
+#ifndef HAVE_SETEUID
+#define HAVE_SETEUID 1
+#endif
+
#endif
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index 8c85663d3b..33dc33a50b 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -14,3 +14,5 @@ exit(1);}],
if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
fi
+
+AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq seteuid)
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index 9ef3999769..ae70634215 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -340,75 +340,6 @@ duplicate a string
#endif /* REPLACE_INET_NTOA */
#endif
-#ifndef HAVE_STRTOUL
-#ifndef ULONG_MAX
-#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
-#endif
-
-/*
- * Convert a string to an unsigned long integer.
- * Taken from libg++ - libiberty code.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
- unsigned long strtoul(const char *nptr, char **endptr, int base)
-{
- const char *s = nptr;
- unsigned long acc;
- int c;
- unsigned long cutoff;
- int neg = 0, any, cutlim;
-
- /*
- * See strtol for comments as to the logic used.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
- cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base);
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = ULONG_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *) (any ? s - 1 : nptr);
- return (acc);
-}
-#endif /* HAVE_STRTOUL */
-
#ifndef HAVE_SETLINEBUF
int setlinebuf(FILE *stream)
{
@@ -511,17 +442,23 @@ int get_time_zone(time_t t)
{
#ifdef HAVE_STRTOUQ
return strtouq(str, endptr, base);
+#elif defined(HAVE___STRTOULL)
+ return __strtoull(str, endptr, base);
#else
- unsigned long long int v;
- if (sscanf(str, "%lli", &v) != 1) {
- errno = EINVAL;
- return 0;
- }
- if (endptr) {
- /* try to get endptr right - uggh */
- strtoul(str, endptr, base);
- }
- return v;
+# error "You need a strtoull function"
+#endif
+}
+#endif
+
+#ifndef HAVE_STRTOLL
+ long long int strtoll(const char *str, char **endptr, int base)
+{
+#ifdef HAVE_STRTOQ
+ return strtoq(str, endptr, base);
+#elif defined(HAVE___STRTOLL)
+ return __strtoll(str, endptr, base);
+#else
+# error "You need a strtoll function"
#endif
}
#endif
@@ -567,3 +504,14 @@ int sys_waitpid(pid_t pid,int *status,int options)
return wait4(pid, status, options, NULL);
#endif /* USE_WAITPID */
}
+
+#ifndef HAVE_SETEUID
+ int seteuid(uid_t euid)
+{
+#ifdef HAVE_SETRESUID
+ return setresuid(-1, euid, -1);
+#else
+# error "You need a seteuid function"
+#endif
+}
+#endif
diff --git a/source4/ntvfs/unixuid/config.m4 b/source4/ntvfs/unixuid/config.m4
deleted file mode 100644
index 2c6777f68e..0000000000
--- a/source4/ntvfs/unixuid/config.m4
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-################################################
-# look for a method of setting the effective uid
-seteuid=no;
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETRESUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
-if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
-fi
-fi
-
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETREUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
-if test x"$samba_cv_USE_SETREUID" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
-fi
-fi
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETEUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
-if test x"$samba_cv_USE_SETEUID" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
-fi
-fi
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETUIDX 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
- samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
-if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
- seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
-fi
-fi