s3-nsstest: drastically shrink size and dependencies of nsstest binary.
authorGünther Deschner <gd@samba.org>
Thu, 25 Jun 2009 16:18:50 +0000 (18:18 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 27 Nov 2009 09:47:11 +0000 (10:47 +0100)
The size went down from 6.4M to 104K on my box.

Guenther

source3/Makefile.in
source3/torture/nsstest.c

index 28be9d1ad49490658b9f62d82a928d9e7f9d21fe..6b1b64bb18956ff8793e4cbb117919d9baabe595 100644 (file)
@@ -1062,9 +1062,7 @@ LOCKTEST_OBJ = torture/locktest.o $(PARAM_OBJ) $(LOCKING_OBJ) $(KRBCLIENT_OBJ) \
                $(LIBSMB_OBJ) $(LDB_OBJ) $(LIB_NONSMBD_OBJ) \
                $(LIBNDR_GEN_OBJ0) $(FNAME_UTIL_OBJ)
 
-NSSTEST_OBJ = torture/nsstest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) \
-                 $(LIB_NONSMBD_OBJ) \
-                $(LIBNDR_GEN_OBJ0)
+NSSTEST_OBJ = torture/nsstest.o $(LIBSAMBAUTIL_OBJ)
 
 PDBTEST_OBJ = torture/pdbtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
                $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
@@ -1723,11 +1721,9 @@ bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ $(LIBTALLOC
                $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \
                $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS)
 
-bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB)
+bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ)
        @echo Linking $@
-       @$(CC) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) \
-               $(LIBS) $(KRB5LIBS)  $(LDAP_LIBS) $(POPT_LIBS) \
-               $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS)
+       @$(CC) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS)
 
 bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT)
        @echo Linking $@
index 9832a7b5ac2479a896676a2eea5ab13250fd8726..8bb577e505429cdd164a31eaec6d850cd16f9f76 100644 (file)
 
 #include "includes.h"
 
+#ifdef malloc
+#undef malloc
+#endif
+#ifdef realloc
+#undef realloc
+#endif
+
 static const char *so_path = "/lib/libnss_winbind.so";
 static const char *nss_name = "winbind";
 static int nss_errno;
@@ -180,13 +187,13 @@ static struct group *nss_getgrent(void)
                return NULL;
 
        if (!buf) 
-               buf = SMB_MALLOC_ARRAY(char, buflen);
+               buf = (char *)malloc(buflen);
 
 again: 
        status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = SMB_REALLOC_ARRAY(buf, char, buflen);
+               buf = (char *)realloc(buf, buflen);
                if (!buf) {
                        return NULL;
                }
@@ -219,12 +226,12 @@ static struct group *nss_getgrnam(const char *name)
                return NULL;
 
        if (!buf) 
-               buf = SMB_MALLOC_ARRAY(char, buflen);
+               buf = (char *)malloc(buflen);
 again: 
        status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = SMB_REALLOC_ARRAY(buf, char, buflen);
+               buf = (char *)realloc(buf, buflen);
                if (!buf) {
                        return NULL;
                }
@@ -257,13 +264,13 @@ static struct group *nss_getgrgid(gid_t gid)
                return NULL;
 
        if (!buf) 
-               buf = SMB_MALLOC_ARRAY(char, buflen);
+               buf = (char *)malloc(buflen);
 
 again: 
        status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
        if (status == NSS_STATUS_TRYAGAIN) {
                buflen *= 2;
-               buf = SMB_REALLOC_ARRAY(buf, char, buflen);
+               buf = (char *)realloc(buf, buflen);
                if (!buf) {
                        return NULL;
                }
@@ -369,7 +376,7 @@ static void nss_test_initgroups(char *name, gid_t gid)
        int i;
        NSS_STATUS status;
 
-       groups = SMB_MALLOC_ARRAY(gid_t, size);
+       groups = (gid_t *)malloc(size);
        groups[0] = gid;
 
        status = nss_initgroups(name, gid, &groups, &start, &size);