[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Sat Mar 24 11:51:03 MDT 2012


The branch, master has been updated
       via  55bd279 lib/util: Allow calloc use in util.c, too.
       via  85aa077 adt_tree: Fix return types.
       via  456abea replace: Work around socket wrapper.
       via  10dd5f1 replace: Add system/network.h for ucred struct.
       via  5ba8ada s3-waf: Use samba3-util library instead of lots of tiny libs.
       via  6f1b735 adt_tree: Avoid WERROR.
       via  71d41a0 libreplace: Add getpeereid implementation.
       via  76bb68f util_malloc: Remove unused constant.
       via  32fd6d6 lib/util: Remove dummy wrapper for getgrgid().
       via  2a82c45 lib/util: Remove dummy wrapper for getgrnam().
       via  43f2750 lib/util: Remove dummy wrapper for getpwuid().
       via  818e072 lib/util: Remove dummy wrapper for getpwnam().
       via  3be6258 lib/util: Remove dummy wrappers for setpwent/getpwent/endpwent.
       via  14fdc1c lib/util: Move calloc_array and memalign_array to top-level libutil.
       via  c0c52ac lib/util: Remove prototype for removed sys_memalign.
       via  2d5275f lib/util: Remove trivial wrapper sys_connect() around connect().
       via  2c94446 cli_pipe: Avoid sys_connect.
       via  e7cd529 sock_exec: Avoid sys_connect.
       via  a9c22de util_sock: Avoid sys_connect.
       via  eb3617c ctdb_conn: Avoid sys_connect.
       via  d4c4cb0 replace: Move memalign() from lib/util/system.c to libreplace.
      from  1080483 Improve the Makefile. Use a standard make macro, not a shell command.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 55bd27935fe0bf31945d0137a1673499e7fcb1ad
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 17:16:26 2012 +0100

    lib/util: Allow calloc use in util.c, too.
    
    Autobuild-User: Jelmer Vernooij <jelmer at samba.org>
    Autobuild-Date: Sat Mar 24 18:50:32 CET 2012 on sn-devel-104

commit 85aa07761abbbf1212e244c8b0a835e41834ae16
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 17:11:11 2012 +0100

    adt_tree: Fix return types.

commit 456abea8941dfb6dab6e69a760532426a781d9ba
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 17:05:29 2012 +0100

    replace: Work around socket wrapper.
    
    It's fine to ignore socket wrapper here, as it doesn't deal with unix domain sockets.

commit 10dd5f186fa31b3abfb8c65bfe3c1b31215106e3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 16:50:37 2012 +0100

    replace: Add system/network.h for ucred struct.

commit 5ba8adadd3fdeb00658cdfc071d8499e58e39e3b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 16:42:47 2012 +0100

    s3-waf: Use samba3-util library instead of lots of tiny libs.
    
    The smaller libraries are currently all trivial in size and don't have
    any dependencies other than samba-util.
    
    Having lots of small private libraries is a pain for packaging,
    and there isn't much advantage in this.

commit 6f1b735cc2972ecd3d2acb30ff834273f08628fe
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 16:41:35 2012 +0100

    adt_tree: Avoid WERROR.

commit 71d41a015add73e0fb355dd9713e99febd71d46f
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 16:00:36 2012 +0100

    libreplace: Add getpeereid implementation.

commit 76bb68fd2b9e09eb4c033417f0f1174f18c04797
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:44:33 2012 +0100

    util_malloc: Remove unused constant.

commit 32fd6d639a5f51f1cc5fb0e81356009a2c9df359
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:26:36 2012 +0100

    lib/util: Remove dummy wrapper for getgrgid().

commit 2a82c45f02b9f5683351ccfa1acdf2622938abc9
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:25:48 2012 +0100

    lib/util: Remove dummy wrapper for getgrnam().

commit 43f275008f1d68c6adee461c531d73c65b6b7483
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:25:05 2012 +0100

    lib/util: Remove dummy wrapper for getpwuid().

commit 818e0722e1a730cfa30d911be510641ef23dc446
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:24:15 2012 +0100

    lib/util: Remove dummy wrapper for getpwnam().

commit 3be6258912939fb538d7bcb492483ae2ab52391b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:23:02 2012 +0100

    lib/util: Remove dummy wrappers for setpwent/getpwent/endpwent.

commit 14fdc1c5cd4ca0b3f88b2d407d40ba5be7218085
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:19:09 2012 +0100

    lib/util: Move calloc_array and memalign_array to top-level libutil.

commit c0c52ac1a40db70d8b19cb8d73ed4759b0a4f905
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 15:00:22 2012 +0100

    lib/util: Remove prototype for removed sys_memalign.

commit 2d5275fae0fd4ea73fba78242185a88845bd0666
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:58:09 2012 +0100

    lib/util: Remove trivial wrapper sys_connect() around connect().

commit 2c9444685d6fd535244638cc51871fd25d1eb1d6
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:57:47 2012 +0100

    cli_pipe: Avoid sys_connect.

commit e7cd5291db8df13ca60c081727c7d804308c8737
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:57:33 2012 +0100

    sock_exec: Avoid sys_connect.

commit a9c22de3f44e00564dfb37fb4c7a99b485ffd96e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:51:23 2012 +0100

    util_sock: Avoid sys_connect.

commit eb3617c426b8efc9021c94d2e1b9669eebbe1034
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:48:56 2012 +0100

    ctdb_conn: Avoid sys_connect.

commit d4c4cb06c52f6ded7d55d75201fb2107e76c1586
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Mar 24 14:43:21 2012 +0100

    replace: Move memalign() from lib/util/system.c to libreplace.

-----------------------------------------------------------------------

Summary of changes:
 lib/replace/libreplace.m4                 |    3 +-
 lib/replace/libreplace_network.m4         |   24 ++++++++
 lib/replace/replace.c                     |   62 +++++++++++++++++++++
 lib/replace/replace.h                     |   18 ++++++
 lib/replace/wscript                       |   14 ++++-
 lib/util/samba_util.h                     |   11 ++---
 lib/util/system.c                         |   83 -----------------------------
 lib/util/util.c                           |   29 ++++++++++
 lib/util/util_pw.c                        |   47 +----------------
 lib/util/util_pw.h                        |    7 ---
 source3/auth/token_util.c                 |    8 ++--
 source3/configure.in                      |   25 ---------
 source3/include/adt_tree.h                |    2 +-
 source3/include/proto.h                   |    2 -
 source3/lib/adt_tree.c                    |   12 ++--
 source3/lib/ctdbd_conn.c                  |    4 +-
 source3/lib/sock_exec.c                   |    4 +-
 source3/lib/username.c                    |    4 +-
 source3/lib/util.c                        |    2 +-
 source3/lib/util_malloc.c                 |   35 ------------
 source3/lib/util_sock.c                   |   20 +++++---
 source3/lib/util_unixsids.c               |    2 +-
 source3/passdb/pdb_interface.c            |    2 +-
 source3/registry/reg_cachehook.c          |    5 ++-
 source3/rpc_client/cli_pipe.c             |    4 +-
 source3/rpc_server/rpc_server.c           |    3 +-
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c |    2 +-
 source3/smbd/ntquotas.c                   |    6 +-
 source3/torture/cmd_vfs.c                 |   12 ++--
 source3/winbindd/winbindd_ccache_access.c |    3 +-
 source3/winbindd/winbindd_pam_logoff.c    |    3 +-
 source3/wscript                           |    8 ---
 source3/wscript_build                     |   70 ++++++------------------
 33 files changed, 228 insertions(+), 308 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index e14fada..72de917 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -121,9 +121,10 @@ AC_CHECK_HEADERS(stdarg.h vararg.h)
 AC_CHECK_HEADERS(sys/mount.h mntent.h)
 AC_CHECK_HEADERS(stropts.h)
 AC_CHECK_HEADERS(unix.h)
+AC_CHECK_HEADERS(malloc.h)
 
 AC_CHECK_FUNCS(seteuid setreuid setresuid setegid setregid setresgid)
-AC_CHECK_FUNCS(chroot bzero strerror strerror_r)
+AC_CHECK_FUNCS(chroot bzero strerror strerror_r memalign posix_memalign getpagesize)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid wait4 strlcpy strlcat initgroups memmove strdup)
 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2 dprintf vdprintf)
diff --git a/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4
index eadcc6b..bb2a843 100644
--- a/lib/replace/libreplace_network.m4
+++ b/lib/replace/libreplace_network.m4
@@ -473,6 +473,30 @@ fi
 LIBS=$old_LIBS
 CPPFLAGS="$libreplace_SAVE_CPPFLAGS"
 
+AC_CACHE_CHECK([for SO_PEERCRED],libreplace_cv_HAVE_PEERCRED,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+[struct ucred cred;
+ socklen_t cred_len;
+ int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
+],
+libreplace_cv_HAVE_PEERCRED=yes,libreplace_cv_HAVE_PEERCRED=no,libreplace_cv_HAVE_PEERCRED=cross)])
+if test x"$libreplace_cv_HAVE_PEERCRED" = x"yes"; then
+    AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
+fi
+
+AC_CACHE_CHECK([for getpeereid],libreplace_cv_HAVE_GETPEEREID,[
+AC_TRY_LINK([#include <sys/types.h>
+#include <unistd.h>],
+[uid_t uid; gid_t gid; int ret;
+ ret = getpeereid(0, &uid, &gid);
+],
+libreplace_cv_HAVE_GETPEEREID=yes,libreplace_cv_HAVE_GETPEEREID=no)])
+if test x"$libreplace_cv_HAVE_GETPEEREID" = xyes; then
+   AC_DEFINE(HAVE_GETPEEREID,1,
+	     [Whether we have getpeereid to get socket credentials])
+fi
+
 LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}"
 
 echo "LIBREPLACE_NETWORK_CHECKS: END"
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index d9a96ff..03fae90 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -27,6 +27,7 @@
 
 #include "system/filesys.h"
 #include "system/time.h"
+#include "system/network.h"
 #include "system/passwd.h"
 #include "system/syslog.h"
 #include "system/locale.h"
@@ -828,3 +829,64 @@ int rep_clock_gettime(clockid_t clk_id, struct timespec *tp)
 	return 0;
 }
 #endif
+
+#ifndef HAVE_MEMALIGN
+void *rep_memalign( size_t align, size_t size )
+{
+#if defined(HAVE_POSIX_MEMALIGN)
+	void *p = NULL;
+	int ret = posix_memalign( &p, align, size );
+	if ( ret == 0 )
+		return p;
+
+	return NULL;
+#else
+	/* On *BSD systems memaligns doesn't exist, but memory will
+	 * be aligned on allocations of > pagesize. */
+#if defined(SYSCONF_SC_PAGESIZE)
+	size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
+#elif defined(HAVE_GETPAGESIZE)
+	size_t pagesize = (size_t)getpagesize();
+#else
+	size_t pagesize = (size_t)-1;
+#endif
+	if (pagesize == (size_t)-1) {
+		DEBUG(0,("memalign functionality not available on this platform!\n"));
+		return NULL;
+	}
+	if (size < pagesize) {
+		size = pagesize;
+	}
+	return malloc(size);
+#endif
+}
+#endif
+
+#ifndef HAVE_GETPEEREID
+int rep_getpeereid(int s, uid_t *uid, gid_t *gid)
+{
+#if defined(HAVE_PEERCRED)
+	struct ucred cred;
+	socklen_t cred_len = sizeof(struct ucred);
+	int ret;
+
+#undef getsockopt
+	ret = getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void *)&cred, &cred_len);
+	if (ret != 0) {
+		return -1;
+	}
+
+	if (cred_len != sizeof(struct ucred)) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	*uid = cred.uid;
+	*gid = cred.gid;
+	return 0;
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
+}
+#endif
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 7112414..f2b1952 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -56,6 +56,10 @@
 #include <inttypes.h>
 #endif
 
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #ifndef __PRI64_PREFIX
 # if __WORDSIZE == 64
 #  define __PRI64_PREFIX	"l"
@@ -108,6 +112,10 @@
 #include <bsd/string.h>
 #endif
 
+#ifdef HAVE_BSD_UNISTD_H
+#include <bsd/unistd.h>
+#endif
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -157,6 +165,11 @@ void *rep_memmem(const void *haystack, size_t haystacklen,
 		 const void *needle, size_t needlelen);
 #endif
 
+#ifndef HAVE_MEMALIGN
+#define memalign rep_memalign
+void *rep_memalign(size_t boundary, size_t size);
+#endif
+
 #ifndef HAVE_MKTIME
 #define mktime rep_mktime
 /* prototype is in "system/time.h" */
@@ -817,4 +830,9 @@ char *rep_getpass(const char *prompt);
 #endif
 #endif
 
+#ifndef HAVE_GETPEEREID
+#define getpeereid rep_getpeereid
+int rep_getpeereid(int s, uid_t *uid, gid_t *gid);
+#endif
+
 #endif /* _LIBREPLACE_REPLACE_H */
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 63944c3..025dda4 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -69,7 +69,7 @@ def configure(conf):
     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
-    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
+    conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
 
     conf.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t comparison_fn_t')
@@ -168,12 +168,22 @@ def configure(conf):
     conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
     conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
-    conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq')
+    conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
 
     # libbsd on some platforms provides strlcpy and strlcat
     if not conf.CHECK_FUNCS('strlcpy strlcat'):
         conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
                 checklibc=True)
+    if not conf.CHECK_FUNCS('getpeereid'):
+        conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
+
+    conf.CHECK_CODE('''
+                struct ucred cred;
+                socklen_t cred_len;
+                int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
+                'HAVE_PEERCRED',
+                msg="Checking whether we can use SO_PEERCRED to get socket credentials",
+                headers='sys/types.h sys/socket.h')
 
     #Some OS (ie. freebsd) return EINVAL if the convertion could not be done, it's not what we expect
     #Let's detect those cases
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 13fe831..f989231 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -113,10 +113,6 @@ void CatchChild(void);
 **/
 void CatchChildLeaveStatus(void);
 
-/* The following definitions come from lib/util/system.c  */
-
-void *sys_memalign( size_t align, size_t size );
-
 /**
  * Wrapper for fork used to invalid pid cache.
  **/
@@ -127,8 +123,6 @@ _PUBLIC_ pid_t sys_fork(void);
  **/
 _PUBLIC_ pid_t sys_getpid(void);
 
-_PUBLIC_ int sys_getpeereid( int s, uid_t *uid);
-
 struct sockaddr;
 
 _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
@@ -138,7 +132,6 @@ _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
 			     char *service,
 			     size_t servlen,
 			     int flags);
-_PUBLIC_ int sys_connect(int fd, const struct sockaddr * addr);
 
 /* The following definitions come from lib/util/genrand.c  */
 /**
@@ -756,6 +749,10 @@ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count, bool fre
 
 void *malloc_array(size_t el_size, unsigned int count);
 
+void *memalign_array(size_t el_size, size_t align, unsigned int count);
+
+void *calloc_array(size_t size, size_t nmemb);
+
 /* The following definitions come from lib/util/fsusage.c  */
 
 
diff --git a/lib/util/system.c b/lib/util/system.c
index 8625229..f34fabd 100644
--- a/lib/util/system.c
+++ b/lib/util/system.c
@@ -39,41 +39,6 @@
      expansions/etc make sense to the OS should be acceptable to Samba.
 */
 
-/*******************************************************************
- A wrapper for memalign
-********************************************************************/
-
-void *sys_memalign( size_t align, size_t size )
-{
-#if defined(HAVE_POSIX_MEMALIGN)
-	void *p = NULL;
-	int ret = posix_memalign( &p, align, size );
-	if ( ret == 0 )
-		return p;
-
-	return NULL;
-#elif defined(HAVE_MEMALIGN)
-	return memalign( align, size );
-#else
-	/* On *BSD systems memaligns doesn't exist, but memory will
-	 * be aligned on allocations of > pagesize. */
-#if defined(SYSCONF_SC_PAGESIZE)
-	size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
-#elif defined(HAVE_GETPAGESIZE)
-	size_t pagesize = (size_t)getpagesize();
-#else
-	size_t pagesize = (size_t)-1;
-#endif
-	if (pagesize == (size_t)-1) {
-		DEBUG(0,("memalign functionalaity not available on this platform!\n"));
-		return NULL;
-	}
-	if (size < pagesize) {
-		size = pagesize;
-	}
-	return malloc(size);
-#endif
-}
 
 /**************************************************************************
  Wrapper for fork. Ensures we clear our pid cache.
@@ -106,35 +71,6 @@ _PUBLIC_ pid_t sys_getpid(void)
 }
 
 
-_PUBLIC_ int sys_getpeereid( int s, uid_t *uid)
-{
-#if defined(HAVE_PEERCRED)
-	struct ucred cred;
-	socklen_t cred_len = sizeof(struct ucred);
-	int ret;
-
-	ret = getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void *)&cred, &cred_len);
-	if (ret != 0) {
-		return -1;
-	}
-
-	if (cred_len != sizeof(struct ucred)) {
-		errno = EINVAL;
-		return -1;
-	}
-
-	*uid = cred.uid;
-	return 0;
-#else
-#if defined(HAVE_GETPEEREID)
-	gid_t gid;
-	return getpeereid(s, uid, &gid);
-#endif
-	errno = ENOSYS;
-	return -1;
-#endif
-}
-
 _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
 			     int salen,
 			     char *host,
@@ -158,22 +94,3 @@ _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
 	}
 	return getnameinfo(psa, salen, host, hostlen, service, servlen, flags);
 }
-
-_PUBLIC_ int sys_connect(int fd, const struct sockaddr * addr)
-{
-	socklen_t salen = (socklen_t)-1;
-
-	if (addr->sa_family == AF_INET) {
-	    salen = sizeof(struct sockaddr_in);
-	} else if (addr->sa_family == AF_UNIX) {
-	    salen = sizeof(struct sockaddr_un);
-	}
-#if defined(HAVE_IPV6)
-	else if (addr->sa_family == AF_INET6) {
-	    salen = sizeof(struct sockaddr_in6);
-	}
-#endif
-
-	return connect(fd, addr, salen);
-}
-
diff --git a/lib/util/util.c b/lib/util/util.c
index 960bda0..20466b4 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -34,6 +34,7 @@
 #undef strncasecmp
 #undef strdup
 #undef realloc
+#undef calloc
 
 /**
  * @file
@@ -646,6 +647,34 @@ void *malloc_array(size_t el_size, unsigned int count)
 	return realloc_array(NULL, el_size, count, false);
 }
 
+/****************************************************************************
+ Type-safe memalign
+****************************************************************************/
+
+void *memalign_array(size_t el_size, size_t align, unsigned int count)
+{
+	if (count*el_size >= MAX_MALLOC_SIZE) {
+		return NULL;
+	}
+
+	return memalign(align, el_size*count);
+}
+
+/****************************************************************************
+ Type-safe calloc.
+****************************************************************************/
+
+void *calloc_array(size_t size, size_t nmemb)
+{
+	if (nmemb >= MAX_MALLOC_SIZE/size) {
+		return NULL;
+	}
+	if (size == 0 || nmemb == 0) {
+		return NULL;
+	}
+	return calloc(nmemb, size);
+}
+
 /**
  Trim the specified elements off the front and back of a string.
 **/
diff --git a/lib/util/util_pw.c b/lib/util/util_pw.c
index c6e4680..ab3808f 100644
--- a/lib/util/util_pw.c
+++ b/lib/util/util_pw.c
@@ -28,49 +28,6 @@
 #include "system/passwd.h"
 #include "lib/util/util_pw.h"
 
-/**************************************************************************
- Wrappers for setpwent(), getpwent() and endpwent()
-****************************************************************************/
-
-void sys_setpwent(void)
-{
-	setpwent();
-}
-
-struct passwd *sys_getpwent(void)
-{
-	return getpwent();
-}
-
-void sys_endpwent(void)
-{
-	endpwent();
-}
-
-/**************************************************************************
- Wrappers for getpwnam(), getpwuid(), getgrnam(), getgrgid()
-****************************************************************************/
-
-struct passwd *sys_getpwnam(const char *name)
-{
-	return getpwnam(name);
-}
-
-struct passwd *sys_getpwuid(uid_t uid)
-{
-	return getpwuid(uid);
-}
-
-struct group *sys_getgrnam(const char *name)
-{
-	return getgrnam(name);
-}
-
-struct group *sys_getgrgid(gid_t gid)
-{
-	return getgrgid(gid);
-}
-
 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
 			    const struct passwd *from)
 {
@@ -94,7 +51,7 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
 {
 	struct passwd *temp;
 
-	temp = sys_getpwnam(name);
+	temp = getpwnam(name);
 	
 	if (!temp) {
 #if 0
@@ -116,7 +73,7 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
 {
 	struct passwd *temp;
 
-	temp = sys_getpwuid(uid);
+	temp = getpwuid(uid);
 	
 	if (!temp) {
 #if 0
diff --git a/lib/util/util_pw.h b/lib/util/util_pw.h
index 2967963..fae4da9 100644
--- a/lib/util/util_pw.h
+++ b/lib/util/util_pw.h
@@ -24,13 +24,6 @@
 #ifndef __LIB_UTIL_UTIL_PW_H__
 #define __LIB_UTIL_UTIL_PW_H__
 
-void sys_setpwent(void);
-struct passwd *sys_getpwent(void);
-void sys_endpwent(void);
-struct passwd *sys_getpwnam(const char *name);
-struct passwd *sys_getpwuid(uid_t uid);
-struct group *sys_getgrnam(const char *name);
-struct group *sys_getgrgid(gid_t gid);
 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
 			    const struct passwd *from);
 struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name);
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index 87f57b6..4a88a6b 100644


-- 
Samba Shared Repository


More information about the samba-cvs mailing list