From 3b63333cf272fae301e22e9a021f0bbf60d1c413 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 21:47:22 +0100 Subject: Allocate one 0-byte in asprintf replacement when len==0 Some S3 code depends on this. (cherry picked from commit dc3d5e16452bf30055638ba3cfe99097fb557156) (This used to be commit 842d144b4fb0981250157f72956e732709663107) --- source4/lib/replace/snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/snprintf.c b/source4/lib/replace/snprintf.c index 9f8a7657e5..a174dcffed 100644 --- a/source4/lib/replace/snprintf.c +++ b/source4/lib/replace/snprintf.c @@ -1264,7 +1264,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list, VA_COPY(ap2, ap); ret = vsnprintf(NULL, 0, format, ap2); va_end(ap2); - if (ret <= 0) return ret; + if (ret < 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; -- cgit From cbc5e58b8f8d6a7ec34f17e263b88a3e7e39b095 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:52:36 +0100 Subject: libreplace: combine SOCKET_LIBS and NSL_LIBS to LIBREPLACE_NETWORK_LIBS But keep the old ones untill the callers are fixed. metze (This used to be commit e7115dcc8a0a4f420de7a901e3a21d4f35a6fcf9) --- source4/lib/replace/socket.m4 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index c0c8f93e81..ab948c1445 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -7,10 +7,10 @@ dnl only looks in /etc/hosts), so we only look for -lsocket if we need dnl it. AC_CHECK_FUNCS(connect) if test x"$ac_cv_func_connect" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect) - AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) dnl We can't just call AC_CHECK_FUNCS(connect) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || @@ -24,9 +24,9 @@ fi AC_CHECK_FUNCS(gethostbyname) if test x"$ac_cv_func_gethostbyname" = x"no"; then - AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname) - AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, dnl because the value has been cached. if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || @@ -38,3 +38,5 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" +NSL_LIBS="" -- cgit From 1ef171f6e00470276b65289878d0006dc9b7f97f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:53:59 +0100 Subject: libreplace: use LIBREPLACE_NETWORK_LIBS within some configure checks ...instead of using SOCKET_LIBS and NSL_LIBS. metze (This used to be commit cef2e8d748756f61c248ad6660e85dd1ac36308a) --- source4/lib/replace/configure.ac | 2 +- source4/lib/replace/getifaddrs.m4 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 298f5a67f9..02dc08bf72 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -21,7 +21,7 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi -LIBS="$SOCKET_LIBS $NSL_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" AC_SUBST(LIBS) AC_SUBST(LDFLAGS) diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index f4cf4e48a2..927bc677db 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -34,10 +34,10 @@ fi ################## # look for a method of finding the list of network interfaces # -# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS" +# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" # old_LIBS=$LIBS -LIBS="$NSL_LIBS $SOCKET_LIBS" +LIBS="${LIBREPLACE_NETWORK_LIBS}" SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$libreplacedir" iface=no; -- cgit From 23c35481fa0e0168d89c91c8bc3cb8d3cf82c213 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:55:05 +0100 Subject: libreplace: for samba4 create LIBREPLACE_NETWORK as EXT_LIB metze (This used to be commit 79037c31334e271a718fcac234148038814b591e) --- source4/lib/replace/samba.m4 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index a2e04f53b1..e62c3d3cd1 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -3,6 +3,9 @@ AC_LIBREPLACE_BROKEN_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) +SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) +SMB_ENABLE(LIBREPLACE_NETWORK) + # remove leading ./ LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'` -- cgit From 7a5438ae111416ce33ffd8f0468fd031ae58577a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 15:01:34 +0100 Subject: libreplace: remove unused SOCKET_LIBS and NSL_LIBS metze (This used to be commit 62bb177a6e4a3e1f949b78c7cd7583f2e1271739) --- source4/lib/replace/socket.m4 | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4 index ab948c1445..984f81f15f 100644 --- a/source4/lib/replace/socket.m4 +++ b/source4/lib/replace/socket.m4 @@ -37,6 +37,3 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then [Whether the system has gethostbyname()]) fi fi - -SOCKET_LIBS="${LIBREPLACE_NETWORK_LIBS}" -NSL_LIBS="" -- cgit From 58dfb0ff3cb9a75e8caad89819f586b64df05f8a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 14 Mar 2008 15:53:38 +0100 Subject: libreplace: put inet_aton.c under LGPL instead of GPL. Michael (This used to be commit cca5d6626fe395f08fd4c8b2344e4e43646cb987) --- source4/lib/replace/inet_aton.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_aton.c b/source4/lib/replace/inet_aton.c index 3eb58f000c..c6b3bb11a7 100644 --- a/source4/lib/replace/inet_aton.c +++ b/source4/lib/replace/inet_aton.c @@ -3,18 +3,22 @@ * replacement functions * Copyright (C) Michael Adam 2008 * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL * - * This program is distributed in the hope that it will be useful, + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . */ #include "replace.h" -- cgit From 87b48a812683794935db950446e9fb1db8e3da48 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 12:16:47 +0100 Subject: libreplace: replace inet_ntoa() when it is missing ...not only replace it when it is broken. This moves the defintion of rep_inet_ntoa from replace.c to inet_ntoa.c and adds configure checks for existence of inet_ntoa(). Checks are moved to an include file of its own. NOTE: The original rep_inet_ntoa in replace.c was wrapped into a "#ifndef WITH_PTHREADS" but the prototype in replace.h and the define in system/network.h were not. I removed that ifndef since the inet_ntoa() function is usually not thread safe anyways, since it returns a pointer to a static buffer. So whoever calls inet_ntoa() should be aware that it is not thread safe anyways. Michael (This used to be commit 974c0c45ad42644348e0b55454715b12158f1028) --- source4/lib/replace/inet_ntoa.c | 39 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/inet_ntoa.m4 | 19 ++++++++++++++++++ source4/lib/replace/libreplace.m4 | 19 +----------------- source4/lib/replace/replace.c | 14 ------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/system/network.h | 2 +- 6 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 source4/lib/replace/inet_ntoa.c create mode 100644 source4/lib/replace/inet_ntoa.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c new file mode 100644 index 0000000000..f3e733fa61 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.c @@ -0,0 +1,39 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Andrew Tridgell 2003 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +/** + * NOTE: this is not thread safe, but it can't be, either + * since it returns a pointer to static memory. + */ +char *rep_inet_ntoa(struct in_addr ip) +{ + uint8_t *p = (uint8_t *)&ip.s_addr; + static char buf[18]; + slprintf(buf, 17, "%d.%d.%d.%d", + (int)p[0], (int)p[1], (int)p[2], (int)p[3]); + return buf; +} diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 new file mode 100644 index 0000000000..c1de4134d9 --- /dev/null +++ b/source4/lib/replace/inet_ntoa.m4 @@ -0,0 +1,19 @@ +AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) + +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +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);}], + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index e6e7198abf..3da2a90a99 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -120,24 +120,6 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) fi -AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ -AC_TRY_RUN([ -#include -#include -#include -#include -#ifdef HAVE_ARPA_INET_H -#include -#endif -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);}], - libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) -if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then - AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) -fi - AC_HAVE_TYPE([socklen_t],[#include ]) AC_HAVE_TYPE([sa_family_t],[#include ]) AC_HAVE_TYPE([struct addrinfo], [#include ]) @@ -348,6 +330,7 @@ m4_include(socket.m4) m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index b2a240e8ab..c16bded963 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -295,20 +295,6 @@ char *rep_strdup(const char *s) } #endif /* HAVE_STRDUP */ -#ifndef WITH_PTHREADS -/* REWRITE: not thread safe */ -#ifdef REPLACE_INET_NTOA -char *rep_inet_ntoa(struct in_addr ip) -{ - uint8_t *p = (uint8_t *)&ip.s_addr; - static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", - (int)p[0], (int)p[1], (int)p[2], (int)p[3]); - return buf; -} -#endif /* REPLACE_INET_NTOA */ -#endif - #ifndef HAVE_SETLINEBUF void rep_setlinebuf(FILE *stream) { diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 00c8230e6b..383536da65 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -325,7 +325,7 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif -#ifdef REPLACE_INET_NTOA +#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) #define inet_ntoa rep_inet_ntoa /* prototype is in "system/network.h" */ #endif diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 8c606c8f2d..7c2377301b 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -88,7 +88,7 @@ typedef int socklen_t; #endif -#ifdef REPLACE_INET_NTOA +#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA) /* define is in "replace.h" */ char *rep_inet_ntoa(struct in_addr ip); #endif -- cgit From 4500b95c89b6b692bd2842e902367663ac2351ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 13:10:22 +0100 Subject: libreplace: remove trailing white spaces. Michael (This used to be commit 1f9ca7eed965904f67cf78fbac007432b8a057fd) --- source4/lib/replace/inet_ntoa.c | 2 +- source4/lib/replace/inet_ntoa.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/inet_ntoa.c b/source4/lib/replace/inet_ntoa.c index f3e733fa61..e3b80ebef8 100644 --- a/source4/lib/replace/inet_ntoa.c +++ b/source4/lib/replace/inet_ntoa.c @@ -33,7 +33,7 @@ char *rep_inet_ntoa(struct in_addr ip) { uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; - slprintf(buf, 17, "%d.%d.%d.%d", + slprintf(buf, 17, "%d.%d.%d.%d", (int)p[0], (int)p[1], (int)p[2], (int)p[3]); return buf; } diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4 index c1de4134d9..5aaa9350c5 100644 --- a/source4/lib/replace/inet_ntoa.m4 +++ b/source4/lib/replace/inet_ntoa.m4 @@ -11,7 +11,7 @@ AC_TRY_RUN([ #endif 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); } + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then -- cgit From 4d16e17e04c6fd62ebfa36085bcf38d2507737e6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 16:31:15 +0100 Subject: libreplace: remove duplicate entry of inet_ntoa from README. Michael (This used to be commit 98ee8c84300757d778733a458c6ca3e6022b40ea) --- source4/lib/replace/README | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index aae1ccb56f..43f7b08572 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -15,7 +15,6 @@ rename initgroups memmove strdup -inet_ntoa setlinebuf vsyslog timegm -- cgit From 7fb3963032ce8f6b7f5c652dd69d3315cae897ea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:42:43 +0100 Subject: Check the return value of fgets (cherry picked from commit b8aaa9a69fd6217ce0387ef8e84f316706186d70) (This used to be commit 8f58d39c0c621e9da85308d721a146352cc4939e) --- source4/lib/replace/getpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index d91d029f6a..57e28eb981 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt) buf[0] = 0; if (!gotintr) { in_fd = fileno(in); - fgets(buf, bufsize, in); + if (fgets(buf, bufsize, in) == NULL) { + buf[0] = 0; + return buf; + } } nread = strlen(buf); if (nread) { -- cgit From 6f6d38d24a69aec614e443c6a5cd0d6ed6b1b70e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 22:27:05 +0100 Subject: Fix Coverity ID 554 (cherry picked from commit 471b1b0c58bc2def5d2fe9d98401def34724d447) (This used to be commit effda48a2670325fed56e158539417c6f95381b8) --- source4/lib/replace/getpass.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 57e28eb981..73333b9021 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,6 +187,9 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; + if (in && in != stdin) { + fclose(in); + } return buf; } } -- cgit From 1268be9f88a1716c9b01b10fef0de5428ef65b3c Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Thu, 28 Feb 2008 11:58:05 -0600 Subject: Fix macro name (no 's' in ifr_addr). Interface detection on Solaris still failing due to items pointed out here: http://lists.samba.org/archive/samba-technical/2007-November/056701.html (cherry picked from commit 37c87acc9d48c1fb5d4806374ca8e992300db1ff) (This used to be commit 5757d8dfe9e6cf7b662acdf5c3d825f0021822c0) --- source4/lib/replace/system/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index 7c2377301b..f943a7fd87 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -310,7 +310,7 @@ struct addrinfo { /* Needed for some systems that don't define it (Solaris). */ #ifndef ifr_netmask -#define ifr_netmask ifr_addrs +#define ifr_netmask ifr_addr #endif #ifdef SOCKET_WRAPPER -- cgit From 124f82efe13a453a3f5857c1e25584536147c3dc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:20:47 +0100 Subject: libreplace: move rep_socketpair() to its own module. Prototype is now in system/network.h, implementation in socketpair.c, and check in socketpair.m4. Now the last networking function has vanished from replace.c. Michael (This used to be commit 94ac8a25be15b55f66eff96fdddc2fdc71a43b1e) --- source4/lib/replace/libreplace.m4 | 3 ++- source4/lib/replace/replace.c | 22 ----------------- source4/lib/replace/replace.h | 2 +- source4/lib/replace/socketpair.c | 46 ++++++++++++++++++++++++++++++++++++ source4/lib/replace/socketpair.m4 | 1 + source4/lib/replace/system/network.h | 5 ++++ 6 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 source4/lib/replace/socketpair.c create mode 100644 source4/lib/replace/socketpair.m4 (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 3da2a90a99..8e17258918 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -158,7 +158,7 @@ fi AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) -AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair) +AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) AC_CHECK_FUNCS(isatty) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) @@ -334,6 +334,7 @@ m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(repdir.m4) m4_include(getifaddrs.m4) +m4_include(socketpair.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index c16bded963..a6a8c0b6ed 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -585,25 +585,3 @@ int rep_unsetenv(const char *name) return 0; } #endif - -#ifndef HAVE_SOCKETPAIR -int rep_socketpair(int d, int type, int protocol, int sv[2]) -{ - if (d != AF_UNIX) { - errno = EAFNOSUPPORT; - return -1; - } - - if (protocol != 0) { - errno = EPROTONOSUPPORT; - return -1; - } - - if (type != SOCK_STREAM) { - errno = EOPNOTSUPP; - return -1; - } - - return pipe(sv); -} -#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 383536da65..5fe79394eb 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -212,7 +212,7 @@ int rep_dlclose(void *handle); #ifndef HAVE_SOCKETPAIR #define socketpair rep_socketpair -int rep_socketpair(int d, int type, int protocol, int sv[2]); +/* prototype is in system/network.h */ #endif #ifndef PRINTF_ATTRIBUTE diff --git a/source4/lib/replace/socketpair.c b/source4/lib/replace/socketpair.c new file mode 100644 index 0000000000..c775730952 --- /dev/null +++ b/source4/lib/replace/socketpair.c @@ -0,0 +1,46 @@ +/* + * Unix SMB/CIFS implementation. + * replacement routines for broken systems + * Copyright (C) Jelmer Vernooij 2006 + * Copyright (C) Michael Adam 2008 + * + * ** NOTE! The following LGPL license applies to the replace + * ** library. This does NOT imply that all of Samba is released + * ** under the LGPL + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "replace.h" +#include "system/network.h" + +int rep_socketpair(int d, int type, int protocol, int sv[2]) +{ + if (d != AF_UNIX) { + errno = EAFNOSUPPORT; + return -1; + } + + if (protocol != 0) { + errno = EPROTONOSUPPORT; + return -1; + } + + if (type != SOCK_STREAM) { + errno = EOPNOTSUPP; + return -1; + } + + return pipe(sv); +} diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4 new file mode 100644 index 0000000000..7088334cda --- /dev/null +++ b/source4/lib/replace/socketpair.m4 @@ -0,0 +1 @@ +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h index f943a7fd87..a5fb813aa1 100644 --- a/source4/lib/replace/system/network.h +++ b/source4/lib/replace/system/network.h @@ -143,6 +143,11 @@ int rep_getifaddrs(struct ifaddrs **); void rep_freeifaddrs(struct ifaddrs *); #endif +#ifndef HAVE_SOCKETPAIR +/* define is in "replace.h" */ +int rep_socketpair(int d, int type, int protocol, int sv[2]); +#endif + /* * Some systems have getaddrinfo but not the * defines needed to use it. -- cgit From a310b0b84369da95c059ddb6ae90a524062eadd5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 18 Mar 2008 17:50:23 +0100 Subject: libreplace: replace.c does not need system/network.h anymore. Michael (This used to be commit 2d3c2f34f33338ff422047dae9cc262522689328) --- source4/lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace') diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index a6a8c0b6ed..6930f9b079 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -27,7 +27,6 @@ #include "system/time.h" #include "system/passwd.h" #include "system/syslog.h" -#include "system/network.h" #include "system/locale.h" #include "system/wait.h" -- cgit