broken strndup on AIX 5.1

Doug VanLeuven roamdad at sonic.net
Sun Aug 22 17:09:07 GMT 2004


Simo Sorce wrote:

>On Sun, 2004-08-22 at 18:02, Simo Sorce wrote:
>  
>
>>So strndup and strnlen are broken in AIX 5.5.1 ?
>>    
>>
>
>Sorry, forgot to add:
>if you can write a reliable test that show they are broken then we can
>include that in configure and use samba internal strndup and strnlen
>functions instead of the AIX ones.
>
>Simo.
>  
>
So you don't think I'm completely lame,  the following patches are how I 
resolved
the broken strndup & strnlen issue on AIX (right or wrong)
I resolved the broken strndup & strnlen just by skipping the tests for 
aix so I get the builtins.

It also addresses 3 issues
1. The security model was enhanced in AIX 5.2.  The version method does 
not exist in 5.1.  This only affects one definition in 
winbind_nss_aix.c, but requires additional aix version tests.  Easy to 
add an additional test for 5.3.
2. The linker was redesigned.  Supposedly in AIX 4.3.3, but I don't have 
that available to test.  The -G option was introduced to assist linking 
shared modules.  Using the old options will panic samba and winbind when 
loading dynamic modules.
3.  -nostartfiles when using gcc to invoke the linker on shared modules 
to avoid duplicate symbols.

--- configure.in.orig   2004-08-19 18:17:50.000000000 -0700
+++ configure.in        2004-08-22 07:51:03.000000000 -0700
@@ -958,7 +958,13 @@
    EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
fi

-AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup 
strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link 
mknod mknod64)
+# use built-in strnlen & strndup on aix
+case "$host_os" in
+*aix*) ;;
+*) AC_CHECK_FUNCS(strndup strnlen) ;;
+esac
+
+AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup 
strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset 
strlcpy strlcat setpgid)
AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob 
strpbrk pipe crypt16 getauthuid)
AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr 
setnetgrent getnetgrent endnetgrent)
@@ -1197,12 +1203,25 @@
                       ;;
               *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                       BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
+                       case "$host_os" in
+                       *aix4*|*aix3*)
+                               
LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
+                               ;;
+                       *)      LDSHFLAGS="-Wl,-G,-bexpall,-bnoentry"
+                               case `uname -r` in
+                                  0|1) ;;
+                                  *)   AC_DEFINE(AIX52,1,[Whether the 
host os is aix 5.2 or later])
+                                       ;;
+                               esac
+                               ;;
+                       esac
                       DYNEXP="-Wl,-brtl,-bexpall"
                       PICFLAGS="-O2"
                       if test "${GCC}" != "yes"; then
                               ## for funky AIX compiler using strncpy()
                               CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT 
-qmaxmem=32000"
+                       else
+                               LDSHFLAGS="-nostartfiles $LDSHFLAGS"
                       fi

                       AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size 
of a block])

--- nsswitch/winbind_nss_aix.c.orig     2004-08-22 07:51:59.000000000 -0700
+++ nsswitch/winbind_nss_aix.c  2004-08-22 07:39:29.000000000 -0700
@@ -977,7 +977,9 @@
{
       ZERO_STRUCTP(methods);

+#ifdef AIX52
       methods->method_version = SECMETHOD_VERSION_520;
+#endif

       methods->method_getgrgid           = wb_aix_getgrgid;
       methods->method_getgrnam           = wb_aix_getgrnam;


More information about the samba-technical mailing list