r20817: sync lib/replace with samba4
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Jan 2007 19:10:54 +0000 (19:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:09 +0000 (12:17 -0500)
metze

12 files changed:
source/lib/replace/.checker_innocent [new file with mode: 0644]
source/lib/replace/README
source/lib/replace/libreplace.m4
source/lib/replace/libreplace_cc.m4
source/lib/replace/replace.c
source/lib/replace/replace.h
source/lib/replace/snprintf.c
source/lib/replace/system/aio.h [new file with mode: 0644]
source/lib/replace/system/kerberos.h
source/lib/replace/system/wait.h
source/lib/replace/test/os2_delete.c
source/lib/replace/test/testsuite.c

diff --git a/source/lib/replace/.checker_innocent b/source/lib/replace/.checker_innocent
new file mode 100644 (file)
index 0000000..e619176
--- /dev/null
@@ -0,0 +1,4 @@
+>>>MISTAKE21_create_files_6a9e68ada99a97cb
+>>>MISTAKE21_os2_delete_9b2bfa7f38711d09
+>>>MISTAKE21_os2_delete_2fcc29aaa99a97cb
+>>>SECURITY2_os2_delete_9b2bfa7f1c9396ca
index 182a2761162f55c1226ee83d8feb7fc344f2cc74..a313984c8eaae29228a9bea05fc76bef7f1d4639 100644 (file)
@@ -52,6 +52,7 @@ readline (the library)
 inet_ntoa
 strtoll
 strtoull
+socketpair
 
 Types:
 bool
index 1dfc823a68a4517e9a20c7a17efda98415e5179b..3328dea95e86df89a8f63c02c33a0d6b37d294d4 100644 (file)
@@ -62,6 +62,7 @@ AC_FUNC_MEMCMP
 AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
 
 AC_CHECK_HEADERS(stdbool.h sys/select.h)
+AC_CHECK_HEADERS(setjmp.h)
 
 AC_CHECK_TYPE(bool, 
 [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
@@ -147,7 +148,7 @@ AC_TRY_COMPILE([
 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 innetgr initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair)
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
 AC_HAVE_DECL(errno, [#include <errno.h>])
index b8b74036e533beb4eeb2bc2e251d8f8c85d208df..74c53cad998a8f3b3c1fde3310d522ad4a7c0475 100644 (file)
@@ -140,23 +140,27 @@ fi
 
 ############################################
 # check if the compiler can do immediate structures
-AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
-    AC_TRY_COMPILE([
-#include <stdio.h>],
-[
-   typedef struct {unsigned x;} FOOBAR;
-   #define X_FOOBAR(x) ((FOOBAR) { x })
-   #define FOO_ONE X_FOOBAR(1)
-   FOOBAR f = FOO_ONE;   
-   static const struct {
-       FOOBAR y; 
-       } f2[] = {
-               {FOO_ONE}
-       };   
-],
-       samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
-if test x"$samba_cv_immediate_structures" = x"yes"; then
-   AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
+AC_SUBST(libreplace_cv_immediate_structures)
+AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
+       AC_TRY_COMPILE([
+               #include <stdio.h>
+       ],[
+               typedef struct {unsigned x;} FOOBAR;
+               #define X_FOOBAR(x) ((FOOBAR) { x })
+               #define FOO_ONE X_FOOBAR(1)
+               FOOBAR f = FOO_ONE;   
+               static const struct {
+                       FOOBAR y; 
+               } f2[] = {
+                       {FOO_ONE}
+               };   
+       ],
+       libreplace_cv_immediate_structures=yes,
+       libreplace_cv_immediate_structures=no,
+       libreplace_cv_immediate_structures=cross)
+])
+if test x"$libreplace_cv_immediate_structures" = x"yes"; then
+       AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
 fi
 
 AC__LIBREPLACE_ONLY_CC_CHECKS_END
index e7f47d7d521d946b31f6a2576b1b7d277549c6c8..9e6c75bd3587a8bb1f3c7731701992d1c9561c0c 100644 (file)
@@ -590,3 +590,24 @@ int rep_setenv(const char *name, const char *value, int overwrite)
 }
 #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
index 7a79f335e2790dda2c238ba7d125e625c94fd1bb..d75394aa1fcd3772910d625b218eee668892e6e8 100644 (file)
@@ -209,6 +209,10 @@ void *rep_dlsym(void *handle, const char *symbol);
 int rep_dlclose(void *handle);
 #endif
 
+#ifndef HAVE_SOCKETPAIR
+#define socketpair rep_socketpair
+int rep_socketpair(int d, int type, int protocol, int sv[2]);
+#endif
 
 #ifndef PRINTF_ATTRIBUTE
 #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
index fcbcdb17e9ed829a20bce4a29328ffb52b651e81..b38d8dad34af66543946640439f364411fb401b6 100644 (file)
@@ -540,7 +540,7 @@ static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in
                        printf("parameter at position %d not used\n", pnum+1);
 #endif
                        /* eat the parameter */
-                       (void)va_arg (args, int);
+                       va_arg (args, int);
                        continue;
                }
                for (i = 1; i < clist[pnum].num; i++) {
diff --git a/source/lib/replace/system/aio.h b/source/lib/replace/system/aio.h
new file mode 100644 (file)
index 0000000..e1b9d83
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _system_aio_h
+#define _system_aio_h
+/* 
+   Unix SMB/CIFS implementation.
+
+   AIO system include wrappers
+
+   Copyright (C) Andrew Tridgell 2006
+   
+   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 2 of the License, or
+   (at your option) any later version.
+   
+   This program 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.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#if HAVE_LIBAIO_H
+#include <libaio.h>
+#endif
+
+#endif
index b24196fc252deec212425f7deb285f83f99afa5b..1617b96aad1a8014767579277ed1a09403435094 100644 (file)
 #define KRB5_PRINC_REALM_RETURNS_REALM 1
 
 #include "heimdal/lib/krb5/krb5.h"
-#include "heimdal/lib/gssapi/gssapi.h"
 #include "heimdal/lib/com_err/com_err.h"
 #endif
 
index 47e3e84bb119e55e8aebf083924e89720804fcae..3855f7ae724e2c588a1d51e6982d1bfe0fd259ce 100644 (file)
@@ -36,6 +36,8 @@
 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
 #endif
 
+#ifdef HAVE_SETJMP_H
 #include <setjmp.h>
+#endif
 
 #endif
index b2bce7e7ff79ea47bfd642732e116eb378cd3af6..c8abfccff9bdbd111bdedc1ff49f6e22e93ea690 100644 (file)
@@ -20,9 +20,8 @@
 #define TESTDIR "test.dir"
 
 static int test_readdir_os2_delete_ret;
-int test_readdir_os2_delete(void);
 
-#define FAILED(d) (fprintf(stderr, "Failed for %s - %d = %s\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
+#define FAILED(d) (printf("failure: readdir [\nFailed for %s - %d = %s\n]\n", d, errno, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
 
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
@@ -108,7 +107,7 @@ int test_readdir_os2_delete(void)
        }
        closedir(d);
 
-       printf("Deleted %d files of %d\n", total_deleted, NUM_FILES);
+       fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES);
 
        rmdir(TESTDIR) == 0 || FAILED("rmdir");
 
index c10a220d7b5d511e97653ed22a89a0a32e57779b..8a9fb9ab876d6343165591a26f3554b39302b11f 100644 (file)
@@ -57,26 +57,29 @@ static int test_ftruncate(void)
        struct stat st;
        int fd;
        const int size = 1234;
-       printf("testing ftruncate\n");
+       printf("test: ftruncate\n");
        unlink(TESTFILE);
        fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
        if (fd == -1) {
-               printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno));
+               printf("failure: ftruncate [\n"
+                          "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno));
                return false;
        }
        if (ftruncate(fd, size) != 0) {
-               printf("ftruncate failed - %s\n", strerror(errno));
+               printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
                return false;
        }
        if (fstat(fd, &st) != 0) {
-               printf("fstat failed - %s\n", strerror(errno));
+               printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
                return false;
        }
        if (st.st_size != size) {
-               printf("ftruncate gave wrong size %d - expected %d\n",
+               printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
                       (int)st.st_size, size);
                return false;
        }
+       unlink(TESTFILE);
+       printf("success: ftruncate\n");
        return true;
 }
 
@@ -98,13 +101,14 @@ static int test_strlcpy(void)
                { NULL, 0 }
        };
        int i;
-       printf("testing strlcpy\n");
+       printf("test: strlcpy\n");
        for (i=0;tests[i].src;i++) {
                if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
-                       printf("strlcpy test %d failed\n", i);
+                       printf("failure: strlcpy [\ntest %d failed\n]\n", i);
                        return false;
                }
        }
+       printf("success: strlcpy\n");
        return true;
 }
 
@@ -146,8 +150,9 @@ static int test_strdup(void)
 
 static int test_setlinebuf(void)
 {
-       printf("testing setlinebuf\n");
+       printf("test: setlinebuf\n");
        setlinebuf(stdout);
+       printf("success: setlinebuf\n");
        return true;
 }
 
@@ -233,10 +238,11 @@ extern int test_readdir_os2_delete(void);
 
 static int test_readdir(void)
 {
-       printf("testing readdir\n");
+       printf("test: readdir\n");
        if (test_readdir_os2_delete() != 0) {
                return false;
        }
+       printf("success: readdir\n");
        return true;
 }
 
@@ -371,9 +377,48 @@ static int test_MAX(void)
        return true;
 }
 
-struct torture_context;
+static int test_socketpair(void)
+{
+       int sock[2];
+       char buf[20];
+
+       printf("test: socketpair\n");
+
+       if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
+               printf("failure: socketpair [\n"
+                          "socketpair() failed\n"
+                          "]\n");
+               return false;
+       }
+
+       if (write(sock[1], "automatisch", 12) == -1) {
+               printf("failure: socketpair [\n"
+                          "write() failed: %s\n"
+                          "]\n", strerror(errno));
+               return false;
+       }
+
+       if (read(sock[0], buf, 12) == -1) {
+               printf("failure: socketpair [\n"
+                          "read() failed: %s\n"
+                          "]\n", strerror(errno));
+               return false;
+       }
+
+       if (strcmp(buf, "automatisch") != 0) {
+               printf("failure: socketpair [\n"
+                          "expected: automatisch, got: %s\n"
+                          "]\n", buf);
+               return false;
+       }
+
+       printf("success: socketpair\n");
 
-static bool torture_local_replace(struct torture_context *torture)
+       return true;
+}
+
+struct torture_context;
+bool torture_local_replace(struct torture_context *ctx)
 {
        bool ret = true;
        ret &= test_ftruncate();
@@ -419,17 +464,17 @@ static bool torture_local_replace(struct torture_context *torture)
        ret &= test_FUNCTION();
        ret &= test_MIN();
        ret &= test_MAX();
+       ret &= test_socketpair();
 
        return ret;
 }
 
 #if _SAMBA_BUILD_<4
-int main(void)
+int main()
 {
-       if (!torture_local_replace(NULL)) {
-               printf("ERROR: TESTSUITE FAILED\n");
-               return -1;
-       }
-       return 0;
+       bool ret = torture_local_replace(NULL);
+       if (ret) 
+               return 0;
+       return -1;
 }
 #endif