From: Andrew Tridgell Date: Wed, 29 Jul 1998 07:02:06 +0000 (+0000) Subject: test for a broken inet_ntoa and replace it if necessary (for X-Git-Tag: samba-4.0.0alpha6~801^2~21999 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=a957abd1fd1bd891354abb1a3590627ae06a45e9 test for a broken inet_ntoa and replace it if necessary (for IRIX+gcc-2.8.1) (This used to be commit ddffbcbcb1284b6ead5f7f7b6665ba2456c0071a) --- diff --git a/source3/acconfig.h b/source3/acconfig.h index 411ce38955b..53a58880eef 100644 --- a/source3/acconfig.h +++ b/source3/acconfig.h @@ -48,4 +48,6 @@ #undef WITH_AUTOMOUNT #undef HAVE_PAM_AUTHENTICATE #undef HAVE_BROKEN_GETGROUPS +#undef REPLACE_INET_NTOA + diff --git a/source3/configure b/source3/configure index 7d01e478c14..01791be8d48 100755 --- a/source3/configure +++ b/source3/configure @@ -3718,16 +3718,49 @@ fi -echo $ac_n "checking for root ... $ac_c" +echo $ac_n "checking for broken inet_ntoa ... $ac_c" if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < +#include +#include +#include +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);} +EOF +if { (eval echo configure:3739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + echo yes;cat >> confdefs.h <<\EOF +#define REPLACE_INET_NTOA 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo no +fi +rm -fr conftest* +fi + + +echo $ac_n "checking for root ... $ac_c" +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;cat >> confdefs.h <<\EOF #define HAVE_ROOT 1 @@ -3749,14 +3782,14 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;netmask=yes;cat >> confdefs.h <<\EOF #define HAVE_NETMASK_IFCONF 1 @@ -3778,14 +3811,14 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3822: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;netmask=yes;cat >> confdefs.h <<\EOF #define HAVE_NETMASK_IFREQ 1 @@ -3808,14 +3841,14 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;netmask=yes;cat >> confdefs.h <<\EOF #define HAVE_NETMASK_AIX 1 @@ -3837,11 +3870,11 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo no else @@ -3862,11 +3895,11 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;cat >> confdefs.h <<\EOF #define HAVE_SHARED_MMAP 1 @@ -3887,11 +3920,11 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;cat >> confdefs.h <<\EOF #define HAVE_FCNTL_LOCK 1 @@ -3912,11 +3945,11 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then echo yes;cat >> confdefs.h <<\EOF #define HAVE_SYSV_IPC 1 @@ -3935,7 +3968,7 @@ fi ################################################# # check for the AFS filesystem echo $ac_n "checking whether to use AFS""... $ac_c" 1>&6 -echo "configure:3939: checking whether to use AFS" >&5 +echo "configure:3972: checking whether to use AFS" >&5 # Check whether --with-afs or --without-afs was given. if test "${with_afs+set}" = set; then withval="$with_afs" @@ -3961,7 +3994,7 @@ fi ################################################# # check for the DFS auth system echo $ac_n "checking whether to use DFS auth""... $ac_c" 1>&6 -echo "configure:3965: checking whether to use DFS auth" >&5 +echo "configure:3998: checking whether to use DFS auth" >&5 # Check whether --with-dfs or --without-dfs was given. if test "${with_dfs+set}" = set; then withval="$with_dfs" @@ -3986,7 +4019,7 @@ fi ################################################# # check for automount support echo $ac_n "checking whether to use AUTOMOUNT""... $ac_c" 1>&6 -echo "configure:3990: checking whether to use AUTOMOUNT" >&5 +echo "configure:4023: checking whether to use AUTOMOUNT" >&5 # Check whether --with-automount or --without-automount was given. if test "${with_automount+set}" = set; then withval="$with_automount" @@ -4011,7 +4044,7 @@ fi ################################################# # check for a LDAP password database echo $ac_n "checking whether to use LDAP password database""... $ac_c" 1>&6 -echo "configure:4015: checking whether to use LDAP password database" >&5 +echo "configure:4048: checking whether to use LDAP password database" >&5 # Check whether --with-ldap or --without-ldap was given. if test "${with_ldap+set}" = set; then withval="$with_ldap" @@ -4036,7 +4069,7 @@ fi ################################################# # check for a NISPLUS password database echo $ac_n "checking whether to use NISPLUS password database""... $ac_c" 1>&6 -echo "configure:4040: checking whether to use NISPLUS password database" >&5 +echo "configure:4073: checking whether to use NISPLUS password database" >&5 # Check whether --with-nisplus or --without-nisplus was given. if test "${with_nisplus+set}" = set; then withval="$with_nisplus" @@ -4061,7 +4094,7 @@ fi ################################################# # check for the secure socket layer echo $ac_n "checking whether to use SSL""... $ac_c" 1>&6 -echo "configure:4065: checking whether to use SSL" >&5 +echo "configure:4098: checking whether to use SSL" >&5 # Check whether --with-ssl or --without-ssl was given. if test "${with_ssl+set}" = set; then withval="$with_ssl" @@ -4086,7 +4119,7 @@ fi ################################################# # check for experimental mmap support echo $ac_n "checking whether to use MMAP""... $ac_c" 1>&6 -echo "configure:4090: checking whether to use MMAP" >&5 +echo "configure:4123: checking whether to use MMAP" >&5 # Check whether --with-mmap or --without-mmap was given. if test "${with_mmap+set}" = set; then withval="$with_mmap" @@ -4111,7 +4144,7 @@ fi ################################################# # check for syslog logging echo $ac_n "checking whether to use syslog logging""... $ac_c" 1>&6 -echo "configure:4115: checking whether to use syslog logging" >&5 +echo "configure:4148: checking whether to use syslog logging" >&5 # Check whether --with-syslog or --without-syslog was given. if test "${with_syslog+set}" = set; then withval="$with_syslog" @@ -4137,7 +4170,7 @@ fi ################################################# # these tests are taken from the GNU fileutils package echo "checking how to get filesystem space usage" 1>&6 -echo "configure:4141: checking how to get filesystem space usage" >&5 +echo "configure:4174: checking how to get filesystem space usage" >&5 space=no # Perform only the link test since it seems there are no variants of the @@ -4149,12 +4182,12 @@ space=no if test $space = no; then # SVR4 echo $ac_n "checking statvfs function (SVR4)""... $ac_c" 1>&6 -echo "configure:4153: checking statvfs function (SVR4)" >&5 +echo "configure:4186: checking statvfs function (SVR4)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_statvfs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4162,7 +4195,7 @@ int main() { struct statvfs fsd; statvfs (0, &fsd); ; return 0; } EOF -if { (eval echo configure:4166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:4199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* fu_cv_sys_stat_statvfs=yes else @@ -4187,7 +4220,7 @@ fi if test $space = no; then # DEC Alpha running OSF/1 echo $ac_n "checking for 3-argument statfs function (DEC OSF/1)""... $ac_c" 1>&6 -echo "configure:4191: checking for 3-argument statfs function (DEC OSF/1)" >&5 +echo "configure:4224: checking for 3-argument statfs function (DEC OSF/1)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs3_osf1'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4195,7 +4228,7 @@ else fu_cv_sys_stat_statfs3_osf1=no else cat > conftest.$ac_ext < @@ -4208,7 +4241,7 @@ else exit (statfs (".", &fsd, sizeof (struct statfs))); } EOF -if { (eval echo configure:4212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then fu_cv_sys_stat_statfs3_osf1=yes else @@ -4235,7 +4268,7 @@ fi if test $space = no; then # AIX echo $ac_n "checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)""... $ac_c" 1>&6 -echo "configure:4239: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5 +echo "configure:4272: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_bsize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4243,7 +4276,7 @@ else fu_cv_sys_stat_statfs2_bsize=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then fu_cv_sys_stat_statfs2_bsize=yes else @@ -4289,7 +4322,7 @@ fi if test $space = no; then # SVR3 echo $ac_n "checking for four-argument statfs (AIX-3.2.5, SVR3)""... $ac_c" 1>&6 -echo "configure:4293: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5 +echo "configure:4326: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs4'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4297,7 +4330,7 @@ else fu_cv_sys_stat_statfs4=no else cat > conftest.$ac_ext < #include @@ -4307,7 +4340,7 @@ else exit (statfs (".", &fsd, sizeof fsd, 0)); } EOF -if { (eval echo configure:4311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then fu_cv_sys_stat_statfs4=yes else @@ -4334,7 +4367,7 @@ fi if test $space = no; then # 4.4BSD and NetBSD echo $ac_n "checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)""... $ac_c" 1>&6 -echo "configure:4338: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5 +echo "configure:4371: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_fsize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4342,7 +4375,7 @@ else fu_cv_sys_stat_statfs2_fsize=no else cat > conftest.$ac_ext < #ifdef HAVE_SYS_PARAM_H @@ -4358,7 +4391,7 @@ else exit (statfs (".", &fsd)); } EOF -if { (eval echo configure:4362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then fu_cv_sys_stat_statfs2_fsize=yes else @@ -4385,7 +4418,7 @@ fi if test $space = no; then # Ultrix echo $ac_n "checking for two-argument statfs with struct fs_data (Ultrix)""... $ac_c" 1>&6 -echo "configure:4389: checking for two-argument statfs with struct fs_data (Ultrix)" >&5 +echo "configure:4422: checking for two-argument statfs with struct fs_data (Ultrix)" >&5 if eval "test \"`echo '$''{'fu_cv_sys_stat_fs_data'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4393,7 +4426,7 @@ else fu_cv_sys_stat_fs_data=no else cat > conftest.$ac_ext < #ifdef HAVE_SYS_PARAM_H @@ -4413,7 +4446,7 @@ else exit (statfs (".", &fsd) != 1); } EOF -if { (eval echo configure:4417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then fu_cv_sys_stat_fs_data=yes else diff --git a/source3/configure.in b/source3/configure.in index 5cdc3425d60..a7cba676881 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -217,6 +217,19 @@ AC_TRY_RUN([#include "tests/getgroups.c"], echo no) +echo $ac_n "checking for broken inet_ntoa ... $ac_c" +AC_TRY_RUN([ +#include +#include +#include +#include +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);}], + echo yes;AC_DEFINE(REPLACE_INET_NTOA), + echo no) + echo $ac_n "checking for root ... $ac_c" AC_TRY_RUN([main() { exit(getuid() != 0); }], echo yes;AC_DEFINE(HAVE_ROOT), diff --git a/source3/include/config.h.in b/source3/include/config.h.in index dbbd5431a25..142c554da6f 100644 --- a/source3/include/config.h.in +++ b/source3/include/config.h.in @@ -105,6 +105,7 @@ #undef WITH_AUTOMOUNT #undef HAVE_PAM_AUTHENTICATE #undef HAVE_BROKEN_GETGROUPS +#undef REPLACE_INET_NTOA /* The number of bytes in a int. */ #undef SIZEOF_INT diff --git a/source3/include/includes.h b/source3/include/includes.h index 2a420f76ed1..a4547a6b4a6 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -408,6 +408,9 @@ union semun { #define PASSWORD_LENGTH 8 #endif +#ifdef REPLACE_INET_NTOA +#define inet_ntoa rep_inet_ntoa +#endif #ifndef HAVE_PIPE #define SYNC_DNS 1 diff --git a/source3/lib/replace.c b/source3/lib/replace.c index 50eac37c832..b4fea3dc313 100644 --- a/source3/lib/replace.c +++ b/source3/lib/replace.c @@ -278,3 +278,18 @@ duplicate a string } #endif +#ifdef REPLACE_INET_NTOA +char *rep_inet_ntoa(struct in_addr ip) +{ + unsigned char *p = (unsigned char *)ip.s_addr; + static char buf[18]; +#if WORDS_BIGENDIAN + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); +#else + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[3], (int)p[2], (int)p[1], (int)p[0]); +#endif + return buf; +} +#endif