[SCM] Samba Shared Repository - branch v3-6-test updated

Günther Deschner gd at samba.org
Tue Apr 5 13:39:04 MDT 2011


The branch, v3-6-test has been updated
       via  9c5c43d s3-waf: fix typo in ctdb checks.
       via  b31d77e s3-samr: make getgrgid() failure a little more visible in _samr_CreateDomAlias().
       via  f4e215e s3-idmap: fix the build of idmap_hash on FreeBSD.
       via  7ad3806 rep_parse_prs: remove some dead, unused code.
       via  a9c16fc lib/util/util_pw: share more code between lib/util/util_pw.c and source3/lib/username.c
       via  b77dcd2 lib/util/util_pw: share sys_get{pw,gr} group of calls.
       via  78c4561 lib/util/util_pw: temporary rename of getpwnam_alloc and getpwuid_alloc.
      from  0a4ed25 lib-util: put data_blob back in the public library

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 9c5c43df39da2453ddb05b61c64de349047f973f
Author: Günther Deschner <gd at samba.org>
Date:   Tue Apr 5 14:15:24 2011 +0200

    s3-waf: fix typo in ctdb checks.
    
    Guenther
    
    Autobuild-User: Günther Deschner <gd at samba.org>
    Autobuild-Date: Tue Apr  5 17:20:19 CEST 2011 on sn-devel-104
    (cherry picked from commit a7ba4b5baa18501a99c7b0f0d3eee1c347ed2e68)

commit b31d77e9a635ace5d7cab9cbfb048d9fd99de82e
Author: Günther Deschner <gd at samba.org>
Date:   Thu Mar 31 00:08:57 2011 +0200

    s3-samr: make getgrgid() failure a little more visible in _samr_CreateDomAlias().
    
    Guenther
    
    Autobuild-User: Günther Deschner <gd at samba.org>
    Autobuild-Date: Thu Mar 31 01:00:42 CEST 2011 on sn-devel-104
    (cherry picked from commit 0e46e09122b43ff237ca45173129813a875767bd)

commit f4e215eaddc2a31dde173a1bb11e6d4638cbea8f
Author: Günther Deschner <gd at samba.org>
Date:   Thu Mar 31 00:08:19 2011 +0200

    s3-idmap: fix the build of idmap_hash on FreeBSD.
    
    Guenther
    (cherry picked from commit e54f292a4f4e9ea9726479333883d63035efc8d4)

commit 7ad38067dabad5bb189e4433f9dd45e1c37443b1
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 30 23:17:25 2011 +0200

    rep_parse_prs: remove some dead, unused code.
    
    Guenther
    (cherry picked from commit 5fcb4d328ce28e6c4f413f2b31d70e07818c0527)

commit a9c16fcef30551aa236f512ae1f6e5e958a8295f
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 2 16:11:00 2011 +0100

    lib/util/util_pw: share more code between lib/util/util_pw.c and source3/lib/username.c
    
    Guenther
    (cherry picked from commit 96487959e90b1aeec071d94e7f2c744af17fb5d0)

commit b77dcd2d8870edf5ce7c03106d76d6aa318a0564
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 2 16:06:32 2011 +0100

    lib/util/util_pw: share sys_get{pw,gr} group of calls.
    
    Guenther
    (cherry picked from commit 64421129b672d0ce55c5aa235e5038dd2ea1b32b)

commit 78c456123e4fa1a36c8a296d89690f4e4f37ffa8
Author: Günther Deschner <gd at samba.org>
Date:   Wed Mar 2 16:31:01 2011 +0100

    lib/util/util_pw: temporary rename of getpwnam_alloc and getpwuid_alloc.
    
    Guenther
    (cherry picked from commit f4868ab6467ad7e6fae78bd14b83aeae68026769)

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

Summary of changes:
 lib/util/util_pw.c                            |   66 ++++-
 source3/smbd/noquotas.c => lib/util/util_pw.h |   40 ++--
 lib/util/wscript_build                        |    5 +
 source3/Makefile.in                           |    2 +-
 source3/auth/auth_util.c                      |    1 +
 source3/auth/token_util.c                     |    1 +
 source3/include/proto.h                       |    9 -
 source3/lib/system.c                          |   44 ---
 source3/lib/username.c                        |   36 +---
 source3/lib/util.c                            |    1 +
 source3/lib/winbind_util.c                    |    1 +
 source3/passdb/passdb.c                       |    1 +
 source3/passdb/pdb_interface.c                |    1 +
 source3/passdb/pdb_ldap.c                     |    1 +
 source3/passdb/util_unixsids.c                |    1 +
 source3/registry/reg_parse_prs.c              |  401 -------------------------
 source3/registry/reg_parse_prs.h              |   20 --
 source3/rpc_server/samr/srv_samr_nt.c         |    2 +-
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c     |    1 +
 source3/smbd/ntquotas.c                       |    1 +
 source3/torture/cmd_vfs.c                     |    1 +
 source3/utils/smbpasswd.c                     |    1 +
 source3/winbindd/idmap_hash/mapfile.c         |    1 +
 source3/wscript                               |    2 +-
 source3/wscript_build                         |    2 +-
 25 files changed, 104 insertions(+), 538 deletions(-)
 copy source3/smbd/noquotas.c => lib/util/util_pw.h (51%)


Changeset truncated at 500 lines:

diff --git a/lib/util/util_pw.c b/lib/util/util_pw.c
index 11e46ec..c6e4680 100644
--- a/lib/util/util_pw.c
+++ b/lib/util/util_pw.c
@@ -3,7 +3,12 @@
 
    Safe versions of getpw* calls
 
+   Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Jeremy Allison  1998-2005
    Copyright (C) Andrew Bartlett 2002
+   Copyright (C) Timur Bakeyev        2005
+   Copyright (C) Bjoern Jacke    2006-2007
+
    
    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
@@ -20,9 +25,54 @@
 */
 
 #include "includes.h"
+#include "system/passwd.h"
+#include "lib/util/util_pw.h"
+
+/**************************************************************************
+ Wrappers for setpwent(), getpwent() and endpwent()
+****************************************************************************/
 
-static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx, 
-					const struct passwd *from) 
+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)
 {
 	struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
 
@@ -40,7 +90,7 @@ static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx,
 	return ret;
 }
 
-struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name) 
+struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
 {
 	struct passwd *temp;
 
@@ -55,10 +105,14 @@ struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
 		return NULL;
 	}
 
-	return alloc_copy_passwd(mem_ctx, temp);
+	return tcopy_passwd(mem_ctx, temp);
 }
 
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) 
+/****************************************************************************
+ talloc'ed version of getpwuid.
+****************************************************************************/
+
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
 {
 	struct passwd *temp;
 
@@ -73,5 +127,5 @@ struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
 		return NULL;
 	}
 
-	return alloc_copy_passwd(mem_ctx, temp);
+	return tcopy_passwd(mem_ctx, temp);
 }
diff --git a/source3/smbd/noquotas.c b/lib/util/util_pw.h
similarity index 51%
copy from source3/smbd/noquotas.c
copy to lib/util/util_pw.h
index 392b324..2967963 100644
--- a/source3/smbd/noquotas.c
+++ b/lib/util/util_pw.h
@@ -1,7 +1,11 @@
 /*
    Unix SMB/CIFS implementation.
-   No support for quotas :-).
+
+   Safe versions of getpw* calls
+
    Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Jeremy Allison 1997-2001.
+   Copyright (C) Andrew Bartlett 2002
 
    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
@@ -17,21 +21,19 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-
-/*
- * Needed for auto generation of proto.h.
- */
-
-bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize)
-{
-  (*bsize) = 512; /* This value should be ignored */
-
-  /* And just to be sure we set some values that hopefully */
-  /* will be larger that any possible real-world value     */
-  (*dfree) = (uint64_t)-1;
-  (*dsize) = (uint64_t)-1;
-
-  /* As we have select not to use quotas, allways fail */
-  return False;
-}
+#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);
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid);
+
+#endif /* __LIB_UTIL_UTIL_PW_H__ */
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 7c18075..a5985c6 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -86,3 +86,8 @@ bld.SAMBA_SUBSYSTEM('UTIL_RUNCMD',
 	public_deps='tevent'
 	)
 
+bld.SAMBA_SUBSYSTEM('UTIL_PW',
+	source='util_pw.c',
+	local_include=False,
+	public_deps='talloc'
+	)
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 2b89545..75faa0c 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -424,7 +424,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
 		   ../lib/util/tevent_werror.o \
 		   ../lib/util/smb_threads.o ../lib/util/util_id.o \
 		   ../lib/util/blocking.o ../lib/util/rfc1738.o \
-		   ../lib/util/select.o
+		   ../lib/util/select.o ../lib/util/util_pw.o
 
 CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
 			 ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index c75b12e..688aac4 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -27,6 +27,7 @@
 #include "../lib/crypto/arcfour.h"
 #include "rpc_client/init_lsa.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index 4942740..f88511d 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -29,6 +29,7 @@
 #include "memcache.h"
 #include "../librpc/gen_ndr/netlogon.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 /****************************************************************************
  Check for a SID in an struct security_token
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9d82b13..92469a5 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -885,13 +885,6 @@ void sys_srandom(unsigned int seed);
 int groups_max(void);
 int sys_getgroups(int setlen, gid_t *gidset);
 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
-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);
 int sys_popen(const char *command);
 int sys_pclose(int fd);
 ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
@@ -991,9 +984,7 @@ bool nt_time_is_set(const NTTIME *nt);
 
 /* The following definitions come from lib/username.c  */
 
-struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
 void flush_pwnam_cache(void);
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
 
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 092287a..d1a1403 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1346,50 +1346,6 @@ int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset)
 }
 
 /**************************************************************************
- 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);
-}
-
-/**************************************************************************
  Extract a command into an arg list.
 ****************************************************************************/
 
diff --git a/source3/lib/username.c b/source3/lib/username.c
index 4e77bee..40e284a 100644
--- a/source3/lib/username.c
+++ b/source3/lib/username.c
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "memcache.h"
+#include "../lib/util/util_pw.h"
 
 /* internal functions */
 static struct passwd *uname_string_combinations(char *s, TALLOC_CTX *mem_ctx,
@@ -57,26 +58,6 @@ static struct passwd *getpwnam_alloc_cached(TALLOC_CTX *mem_ctx, const char *nam
 }
 
 /****************************************************************************
- talloc copy a struct passwd.
-****************************************************************************/
-
-struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from)
-{
-	struct passwd *ret = TALLOC_P(mem_ctx, struct passwd);
-	if (!ret) {
-		return NULL;
-	}
-	ret->pw_name = talloc_strdup(ret, from->pw_name);
-	ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
-	ret->pw_uid = from->pw_uid;
-	ret->pw_gid = from->pw_gid;
-	ret->pw_gecos = talloc_strdup(ret, from->pw_gecos);
-	ret->pw_dir = talloc_strdup(ret, from->pw_dir);
-	ret->pw_shell = talloc_strdup(ret, from->pw_shell);
-	return ret;
-}
-
-/****************************************************************************
  Flush all cached passwd structs.
 ****************************************************************************/
 
@@ -86,21 +67,6 @@ void flush_pwnam_cache(void)
 }
 
 /****************************************************************************
- talloc'ed version of getpwuid.
-****************************************************************************/
-
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
-{
-	struct passwd *temp = sys_getpwuid(uid);
-
-	if (!temp) {
-		return NULL;
-	}
-
-	return tcopy_passwd(mem_ctx, temp);
-}
-
-/****************************************************************************
  Get a users home directory.
 ****************************************************************************/
 
diff --git a/source3/lib/util.c b/source3/lib/util.c
index b6128fe..0034fbf 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -25,6 +25,7 @@
 #include "popt_common.h"
 #include "secrets.h"
 #include "ctdbd_conn.h"
+#include "../lib/util/util_pw.h"
 
 extern char *global_clobber_region_function;
 extern unsigned int global_clobber_region_line;
diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c
index 57cb3a9..ad1ccf5 100644
--- a/source3/lib/winbind_util.c
+++ b/source3/lib/winbind_util.c
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 #if defined(WITH_WINBIND)
 
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index fdc4bdc..ecf7278 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -26,6 +26,7 @@
 #include "../libcli/auth/libcli_auth.h"
 #include "secrets.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 8cdaaaa..046ca65 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -26,6 +26,7 @@
 #include "memcache.h"
 #include "nsswitch/winbind_client.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 07c56eb..0ac9a97 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -48,6 +48,7 @@
 #include "secrets.h"
 #include "idmap_cache.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c
index 00cab22..cf85a5d 100644
--- a/source3/passdb/util_unixsids.c
+++ b/source3/passdb/util_unixsids.c
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
 
 bool sid_check_is_unix_users(const struct dom_sid *sid)
 {
diff --git a/source3/registry/reg_parse_prs.c b/source3/registry/reg_parse_prs.c
index d831f19..023fd0c 100644
--- a/source3/registry/reg_parse_prs.c
+++ b/source3/registry/reg_parse_prs.c
@@ -98,16 +98,6 @@ void prs_mem_free(prs_struct *ps)
 }
 
 /*******************************************************************
- Clear the memory in a parse structure.
- ********************************************************************/
-
-void prs_mem_clear(prs_struct *ps)
-{
-	if (ps->buffer_size)
-		memset(ps->data_p, '\0', (size_t)ps->buffer_size);
-}
-
-/*******************************************************************
  Allocate memory when unmarshalling... Always zero clears.
  ********************************************************************/
 
@@ -137,55 +127,6 @@ TALLOC_CTX *prs_get_mem_context(prs_struct *ps)
 }
 
 /*******************************************************************
- Hand some already allocated memory to a prs_struct.
- If "is_dynamic" is true, this is a talloc_steal.
- If "is_dynamic" is false, just make ps->data_p a pointer to
- the unwritable memory.
- ********************************************************************/
-
-void prs_give_memory(prs_struct *ps, char *buf, uint32 size, bool is_dynamic)
-{
-	ps->is_dynamic = is_dynamic;
-	if (ps->is_dynamic && buf) {
-		talloc_steal(ps->mem_ctx, buf);
-	}
-	ps->data_p = buf;
-	ps->buffer_size = size;
-}
-
-/*******************************************************************
- Set a prs_struct to exactly a given size. Will grow or tuncate if neccessary.
- ********************************************************************/
-
-bool prs_set_buffer_size(prs_struct *ps, uint32 newsize)
-{
-	if (newsize > ps->buffer_size)
-		return prs_force_grow(ps, newsize - ps->buffer_size);
-
-	if (newsize < ps->buffer_size) {
-		ps->buffer_size = newsize;
-
-		/* newsize == 0 acts as a free and set pointer to NULL */
-		if (newsize == 0) {
-			TALLOC_FREE(ps->data_p);
-		} else {
-			ps->data_p = talloc_realloc(ps->mem_ctx,
-						ps->data_p,
-						char,
-						newsize);
-
-			if (ps->data_p == NULL) {
-				DEBUG(0,("prs_set_buffer_size: Realloc failure for size %u.\n",
-					(unsigned int)newsize));
-				return False;
-			}
-		}
-	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list