Avoid a race condition in glibc between AIO and setresuid().
[samba.git] / source / configure.in
index 9980d18f43904e741516b451c55265d067680279..dcdad47c3fd807961c1e2be1f81abec054c39f5d 100644 (file)
@@ -9,9 +9,20 @@ AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
 
-SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
-if test -n "${SAMBA_VERSION_SVN_REVISION}";then
-       echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
+SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then
+       echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}"
+fi
+SAMBA_VERSION_GIT_COMMIT_DATE=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then
+       echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}"
+fi
+SAMBA_VERSION_GIT_COMMIT_TIME=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then
+       echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
+
+       # just to keep the build-farm gui happy for now...
+       echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
 fi
 
 AC_LIBREPLACE_LOCATION_CHECKS
@@ -233,7 +244,7 @@ done
 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/talloc"
-SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/tdb/include"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/tdb/include"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
 
@@ -259,7 +270,6 @@ dnl Unique-to-Samba variables we'll be playing with.
 AC_SUBST(SAMBA_CPPFLAGS)
 AC_SUBST(SHELL)
 AC_SUBST(LDSHFLAGS)
-AC_SUBST(MODULE_EXPORTS)
 AC_SUBST(SONAMEFLAG)
 AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
@@ -348,35 +358,6 @@ AC_ARG_WITH(selftest-prefix,
   esac
 ])
 
-AC_ARG_ENABLE(launchd,
-[  --enable-launchd        Support running under launchd (default=auto)])
-
-if test x"$enable_launchd" != x"no" ; then
-    AC_CACHE_CHECK([whether to include launchd support],
-       samba_cv_launchd_support,
-       [
-           AC_TRY_COMPILE(
-           [
-#include <launch.h>
-           ],
-           [
-               launchd_msg(NULL);
-               launchd_data_get_fd(NULL);
-           ],
-           samba_cv_launchd_support=yes,
-           samba_cv_launchd_support=no)
-       ])
-
-    if test x"$samba_cv_launchd_support" = x"yes" ; then
-       AC_DEFINE(WITH_LAUNCHD_SUPPORT, 1,
-                   [Whether launchd support should be enabled])
-    else
-       if test x"$enable_launchd" = x"yes" ; then
-           AC_ERROR(launchd support is not available)
-       fi
-    fi
-fi
-
 #################################################
 # set path of samba4's smbtorture
 smbtorture4_path=""
@@ -573,29 +554,7 @@ if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
        PIDL_ARGS="$PIDL_ARGS --uint-enums"
 fi
 
-############################################
-# Check whether we can do automatic dependency tracking
-
-m4_include(m4/substnot.m4)
-m4_include(m4/cond.m4)
-m4_include(m4/make.m4)
-m4_include(m4/depout.m4)
-m4_include(m4/lead-dot.m4)
-m4_include(m4/check_gnu_make.m4)
-m4_include(m4/depend.m4)
-
-# Using the dependency files requires GNU make until someone adds support
-# for Makefile includes for other make implementations.
-CHECK_GNU_MAKE()
-if test "x$_cv_gnu_make_command" != "x" ; then
-    AC_SUBST(MAKE, $_cv_gnu_make_command)
-fi
-
-AM_DEP_TRACK()
-_AM_DEPENDENCIES(CC)
-
-############################################
-# Figure out the flags to support named structure initializers
+dnl Figure out the flags to support named structure initializers
 
 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
 
@@ -641,7 +600,7 @@ AC_SUBST(DYNEXP)
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog rpc_unixinfo rpc_epmapper auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_shutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog rpc_echo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
 
 dnl These are preferably build shared, and static if dlopen() is not available
 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script vfs_readahead"
@@ -863,7 +822,7 @@ main() {
     *darwin*)
        AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 
-       # Add a system specific charset module.
+# Add a system specific charset module.
        default_shared_modules="$default_shared_modules charset_macosxfs"
 
        ;;
@@ -1293,7 +1252,6 @@ AC_CHECK_FUNCS(memalign posix_memalign)
 AC_CHECK_HEADERS(sys/mman.h)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open)
-AC_CHECK_FUNCS(makecontext getcontext setcontext swapcontext)
 
 # Find a method of generating a stack trace
 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
@@ -1428,33 +1386,23 @@ AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
 case "$host_os" in
     *linux*)
        # glibc <= 2.3.2 has a broken getgrouplist
-    AC_CACHE_CHECK([for a broken Linux getgrouplist API],
-           linux_getgrouplist_ok,
-           [
-               AC_TRY_RUN([
+       AC_TRY_RUN([
 #include <unistd.h>
 #include <sys/utsname.h>
-
-                   main() {
-                          /* glibc up to 2.3 has a broken getgrouplist */
+main() {
+       /* glibc up to 2.3 has a broken getgrouplist */
 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
-                          int libc_major = __GLIBC__;
-                          int libc_minor = __GLIBC_MINOR__;
+       int libc_major = __GLIBC__;
+       int libc_minor = __GLIBC_MINOR__;
 
-                          if (libc_major < 2)
-                                 exit(1);
-                          if ((libc_major == 2) && (libc_minor <= 3))
-                                 exit(1);
+       if (libc_major < 2)
+              exit(1);
+       if ((libc_major == 2) && (libc_minor <= 3))
+              exit(1);
 #endif
-                          exit(0);
-                   }
-
-               ],
-               [linux_getgrouplist_ok=yes],
-               [linux_getgrouplist_ok=no],
-               [linux_getgrouplist_ok=cross])
-       ])
-
+       exit(0);
+}
+], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
        if test x"$linux_getgrouplist_ok" = x"yes"; then
           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
        fi
@@ -1653,6 +1601,14 @@ case "$host_os" in
   ;;
 esac
 
+########################################################
+# Check if attropen() is present if this is Solaris
+case "$host_os" in
+  *solaris*)
+       AC_CHECK_FUNCS(attropen)
+  ;;
+esac
+
 ########################################################
 # Do xattr functions take additional options like on Darwin?
 if test x"$ac_cv_func_getxattr" = x"yes" ; then
@@ -1724,21 +1680,19 @@ BLDSHARED="false"
 # these are the defaults, good for lots of systems
 HOST_OS="$host_os"
 LDSHFLAGS="-shared"
-MODULE_EXPORTS=""
 SONAMEFLAG="#"
 SHLD="\${CC} \${CFLAGS}"
 PICFLAG="${PIE_CFLAGS}"
 SHLIBEXT="so"
 
-
 # this bit needs to be modified for each OS that supports share libs
 # You need to specify how to create a shared library and
-# how to compile C code to produce PIC object files
+  # how to compile C code to produce PIC object files
 
-AC_MSG_CHECKING([ability to build shared libraries])
+  AC_MSG_CHECKING([ability to build shared libraries])
 
-# and these are for particular systems
-case "$host_os" in
+  # and these are for particular systems
+  case "$host_os" in
                *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
                        BLDSHARED="true"
                        if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
@@ -1813,8 +1767,10 @@ case "$host_os" in
                        ;;
                *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                        BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-G,-bexpall,-bbigtoc"
-                       DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
+                       # use expfull to export underscored symbols
+                       # add rtl to LDSHFLAGS to fix /lib/crt0.o warning
+                       LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc,-brtl"
+                       DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
                        PICFLAG="-O2"
                        # as AIX code is always position independent...
                        # .po will just create compile warnings, use po.o:
@@ -1904,26 +1860,20 @@ case "$host_os" in
                *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
                        BLDSHARED="true"
                        LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
-                       MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/modules/exports.darwin"
                        SHLIBEXT="dylib"
-                       # Since gcc doesn't fail on unrecognised options, the
-                       # PIE test incorrectly succeeds. Darwin gcc does not
-                       # actually support the PIE stuff.
-                       PIE_LDFLAGS=
-                       PIE_CFLAGS=
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
 
                *)
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
-esac
+  esac
 
 if test "$enable_shared" != "yes"; then
        BLDSHARED=false
 fi
 
-AC_MSG_RESULT($BLDSHARED)
+  AC_MSG_RESULT($BLDSHARED)
 
 AC_MSG_CHECKING([LDFLAGS])
 AC_MSG_RESULT([$LDFLAGS])
@@ -2007,6 +1957,14 @@ if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
 fi
 
 
+AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
+AC_TRY_RUN([#include <time.h>
+main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
+samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
+if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
+    AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
+fi
+
 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
 AC_TRY_RUN([#include <stdio.h>
 #include <sys/stat.h>
@@ -2178,13 +2136,13 @@ if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
 fi
 
 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
+AC_TRY_LINK([
 #include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
-           samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
+#include <unistd.h>], [struct timeval tv; return gettimeofday(&tv, NULL);],
+           samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,
+          samba_cv_HAVE_GETTIMEOFDAY_TZ=no)])
 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
-    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
+    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday takes a tz argument])
 fi
 
 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
@@ -2196,12 +2154,12 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
 
     AC_LIBTESTFUNC(rt, clock_gettime,
            [
-               AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
-                   [Whether clock_gettime is available])
-               SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
-               SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
-               SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
-           ])
+                           AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+                               [Whether clock_gettime is available])
+                           SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+                           SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+                           SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
+                       ])
 
 fi
 
@@ -2585,7 +2543,7 @@ fi
 
 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h)
-AC_CHECK_FUNC(inotify_init)
+AC_CHECK_FUNCS(inotify_init)
 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
 ],
 samba_cv_HAVE_INOTIFY=yes,
@@ -2609,13 +2567,13 @@ if test x$enable_fam != xno; then
         # On IRIX, libfam requires libC, but other FAM implementations
        # might not need it.
         AC_CHECK_LIB(fam, FAMOpen2,
-            [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
+            [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam"],
             [samba_cv_HAVE_LIBFAM=no])
 
         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
             samba_fam_xtra=-lC
             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
-                [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
+                [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC"],
                 [samba_cv_HAVE_LIBFAM=no])
             unset samba_fam_xtra
         fi
@@ -2635,6 +2593,8 @@ if test x$enable_fam != xno; then
     fi
 fi
 
+AC_SUBST(SMB_FAM_LIBS)
+
 #################################################
 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
 
@@ -2835,12 +2795,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
 fi
 
 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
-       AC_TRY_RUN([
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
-    return test_readdir_os2_delete();
-}
-],
+       AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
                [samba_cv_HAVE_BROKEN_READDIR=no],
                        [samba_cv_HAVE_BROKEN_READDIR=yes],
                        [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
@@ -2849,10 +2804,7 @@ if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
        AC_TRY_RUN([
 #include "${srcdir-.}/lib/repdir.c"
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
-    return test_readdir_os2_delete();
-],
+#include "${srcdir-.}/tests/os2_delete.c"],
        samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
 fi
 
@@ -2917,30 +2869,32 @@ fi
 ################################################
 # 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_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
 AC_TRY_RUN([
 #define AUTOCONF_TEST 1
-#define USE_SETRESUID 1
+#define USE_SETREUID 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])
+           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
 
-
+# we check for setresuid second as it conflicts with AIO on Linux. 
+# see http://samba.org/~tridge/junkcode/aio_uid.c
 if test $seteuid = no; then
-AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
+AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
 AC_TRY_RUN([
 #define AUTOCONF_TEST 1
-#define USE_SETREUID 1
+#define USE_SETRESUID 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])
+           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
 
@@ -3293,6 +3247,21 @@ if test x"$with_ldap_support" != x"no"; then
   # this test must be before the libldap test
   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
 
+  #######################################################
+  # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
+  # ldap logging and print it out in the samba logs
+  AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
+                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
+                [AC_TRY_COMPILE([#include <lber.h>],
+                                [int val = LBER_OPT_LOG_PRINT_FN;],
+                                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
+                                samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
+
+  if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
+       AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
+                 [Support for LDAP/LBER logging interception])
+  fi
+
   ########################################################
   # now see if we can find the ldap libs in standard paths
   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
@@ -3324,12 +3293,6 @@ if test x"$with_ldap_support" != x"no"; then
     default_shared_modules="$default_shared_modules";
     SMBLDAP="lib/smbldap.o"
     SMBLDAPUTIL="lib/smbldap_util.o"
-    if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
-      AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
-    else
-      AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
-      LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
-    fi
     with_ldap_support=yes
     AC_MSG_CHECKING(whether LDAP support is used)
     AC_MSG_RESULT(yes)
@@ -4000,6 +3963,30 @@ if test x"$with_ads_support" != x"no"; then
   fi
 
 
+  AC_CACHE_CHECK([for krb5_principal_get_realm],
+                samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
+               [Whether the function krb5_principal_get_realm is defined])
+  fi
+
+  AC_CACHE_CHECK([for krb5_princ_realm],
+                samba_cv_HAVE_KRB5_PRINC_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
+      samba_cv_HAVE_KRB5_PRINC_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINC_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
+               [Whether the macro krb5_princ_realm is defined])
+  fi
+
   #
   #
   # Now the decisions whether we can support krb5
@@ -4285,18 +4272,18 @@ if test x"${try_pam}" != x"no";then
                #include <security/pam_appl.h>
                #endif
        ]])
-       if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
+       if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
                if test x"${try_pam}" = x"yes";then
                        AC_MSG_ERROR([--with-pam=yes but security/pam_modules.h not found])
-               fi
+       fi
                create_pam_modules=no
-       fi
+    fi
 
        if test x"$use_pam" = x"yes"; then
-               AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
+    AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
                AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
                AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
-               with_pam_for_crypt=yes
+    with_pam_for_crypt=yes
 
                if test x"$create_pam_modules" = x"yes"; then
                        AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
@@ -5225,6 +5212,7 @@ AC_ARG_WITH(acl-support,
                AC_MSG_RESULT(Using FreeBSD posix ACLs)
                AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
                AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
+               default_static_modules="$default_static_modules vfs_posixacl"
                ;;
        *linux*)
                AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
@@ -5824,6 +5812,7 @@ case "$host_os" in
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
                    nsswitch/winbind_nss_linux.o"
                WINBIND_NSS_EXTRA_LIBS="-lsocket"
+               PAM_WINBIND_EXTRA_LIBS="-lsocket"
                ;;
        *hpux11*)
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
@@ -5848,10 +5837,7 @@ AC_SUBST(WINBIND_NSS_LDSHFLAGS)
 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
-
-if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes"; then
-       NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
-fi
+AC_SUBST(PAM_WINBIND_EXTRA_LIBS)
 
 AC_SUBST(SMB_KRB5_LOCATOR)
 
@@ -5887,6 +5873,10 @@ if test x"$HAVE_WINBIND" = x"no"; then
        WINBIND_WINS_NSS=""
 fi
 
+if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes"; then
+       NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
+fi
+
 if test x"$HAVE_WINBIND" = x"yes"; then
         AC_MSG_RESULT(yes)
        AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
@@ -5966,7 +5956,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then
     FLAGS1="-I\$(srcdir)/popt"
 else
     AC_MSG_RESULT(no)
-    BUILD_POPT=""
+       BUILD_POPT=""
     POPTLIBS="-lpopt"
 fi
 AC_SUBST(BUILD_POPT)
@@ -6055,7 +6045,7 @@ done
 
 dnl Always built these modules static
 MODULE_rpc_spoolss=STATIC
-MODULE_rpc_srvsvc=STATIC
+MODULE_rpc_srv=STATIC
 MODULE_idmap_tdb=STATIC
 MODULE_idmap_passdb=STATIC
 MODULE_idmap_nss=STATIC
@@ -6088,21 +6078,18 @@ SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
 
 
 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_reg.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_svc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_epmapper, \$(RPC_EPMAPPER_OBJ), "bin/librpc_epmapper.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
 
 SMB_MODULE(idmap_ldap, nsswitch/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
@@ -6156,8 +6143,8 @@ SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", V
 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
-SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
@@ -6292,7 +6279,7 @@ AC_SUBST(builddir)
 
 # Stuff the smbd-only libraries at the end of the smbd link
 # path (if we have them).
-SMBD_LIBS="$samba_fam_libs $samba_dmapi_libs"
+SMBD_LIBS="$samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)