[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1956-g68bb2d2

Günther Deschner gd at samba.org
Tue Jun 2 11:12:30 GMT 2009


The branch, master has been updated
       via  68bb2d2e8027294a9958cf04aeb072a940642847 (commit)
       via  8684911bdae2dfd1d8bf2e9057d5acb7b856ef3f (commit)
       via  81e820c1aa15fb27c55cebc758bb151501e9bb4d (commit)
       via  9a7a97856a4cb017680edef455ceb8c1da2708ee (commit)
       via  94f2ef4f72aefd774931fe58215107c72fb1bde2 (commit)
      from  84090c95a5851d71bf61388281547041f9c0b277 (commit)

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


- Log -----------------------------------------------------------------
commit 68bb2d2e8027294a9958cf04aeb072a940642847
Author: Günther Deschner <gd at samba.org>
Date:   Tue Jun 2 12:18:59 2009 +0200

    torture: minor fixes to torture macro text output.
    
    Guenther

commit 8684911bdae2dfd1d8bf2e9057d5acb7b856ef3f
Author: Günther Deschner <gd at samba.org>
Date:   Sun May 31 02:20:29 2009 +0200

    nss_wrapper: resort calls to move public calls to the end.
    
    Guenther

commit 81e820c1aa15fb27c55cebc758bb151501e9bb4d
Author: Günther Deschner <gd at samba.org>
Date:   Sun May 31 01:01:13 2009 +0200

    nss_wrapper: add nwrap_ops function pointer table.
    
    Guenther

commit 9a7a97856a4cb017680edef455ceb8c1da2708ee
Author: Günther Deschner <gd at samba.org>
Date:   Sun May 31 00:54:56 2009 +0200

    nss_wrapper: make sure to return after calling real_{set,end}{gr,pw}ent.
    
    Guenther

commit 94f2ef4f72aefd774931fe58215107c72fb1bde2
Author: Günther Deschner <gd at samba.org>
Date:   Sun May 31 00:50:42 2009 +0200

    nss_wrapper: fix typo while checking for getgrid_r support.
    
    Metze, this has been in here for a long time, please check.
    
    Guenther

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

Summary of changes:
 lib/nss_wrapper/nss_wrapper.c |  479 ++++++++++++++++++++++++-----------------
 lib/torture/torture.h         |    4 +-
 2 files changed, 288 insertions(+), 195 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c
index d7f7b0b..318cfa8 100644
--- a/lib/nss_wrapper/nss_wrapper.c
+++ b/lib/nss_wrapper/nss_wrapper.c
@@ -61,8 +61,8 @@
 #ifndef HAVE_GETGRNAM_R
 #define getgrnam_r(name, grdst, buf, buflen, grdstp)	ENOSYS
 #endif
-#ifndef HAVE_GETGRUID_R
-#define getgrgid_r(uid, grdst, buf, buflen, grdstp)	ENOSYS
+#ifndef HAVE_GETGRGID_R
+#define getgrgid_r(gid, grdst, buf, buflen, grdstp)	ENOSYS
 #endif
 #ifndef HAVE_GETGRENT_R
 #define getgrent_r(grdst, buf, buflen, grdstp)		ENOSYS
@@ -139,6 +139,88 @@
 #define NWRAP_VERBOSE(args)
 #endif
 
+struct nwrap_ops {
+	const char *name;
+	struct passwd *	(*getpwnam)(const char *name);
+	int		(*getpwnam_r)(const char *name, struct passwd *pwdst,
+				      char *buf, size_t buflen, struct passwd **pwdstp);
+	struct passwd *	(*getpwuid)(uid_t uid);
+	int		(*getpwuid_r)(uid_t uid, struct passwd *pwdst,
+				      char *buf, size_t buflen, struct passwd **pwdstp);
+	void		(*setpwent)(void);
+	struct passwd *	(*getpwent)(void);
+	int		(*getpwent_r)(struct passwd *pwdst, char *buf,
+				      size_t buflen, struct passwd **pwdstp);
+	void		(*endpwent)(void);
+	int		(*initgroups)(const char *user, gid_t group);
+	struct group *	(*getgrnam)(const char *name);
+	int		(*getgrnam_r)(const char *name, struct group *grdst,
+				      char *buf, size_t buflen, struct group **grdstp);
+	struct group *	(*getgrgid)(gid_t gid);
+	int		(*getgrgid_r)(gid_t gid, struct group *grdst,
+				      char *buf, size_t buflen, struct group **grdstp);
+	void		(*setgrent)(void);
+	struct group *	(*getgrent)(void);
+	int		(*getgrent_r)(struct group *grdst, char *buf,
+				      size_t buflen, struct group **grdstp);
+	void		(*endgrent)(void);
+	int		(*getgrouplist)(const char *user, gid_t group, gid_t *groups, int *ngroups);
+};
+
+static struct passwd *nwrap_files_getpwnam(const char *name);
+static int nwrap_files_getpwnam_r(const char *name, struct passwd *pwdst,
+				  char *buf, size_t buflen, struct passwd **pwdstp);
+static struct passwd *nwrap_files_getpwuid(uid_t uid);
+static int nwrap_files_getpwuid_r(uid_t uid, struct passwd *pwdst,
+				  char *buf, size_t buflen, struct passwd **pwdstp);
+static void nwrap_files_setpwent(void);
+static struct passwd *nwrap_files_getpwent(void);
+static int nwrap_files_getpwent_r(struct passwd *pwdst, char *buf,
+				  size_t buflen, struct passwd **pwdstp);
+static void nwrap_files_endpwent(void);
+static int nwrap_files_initgroups(const char *user, gid_t group);
+static struct group *nwrap_files_getgrnam(const char *name);
+static int nwrap_files_getgrnam_r(const char *name, struct group *grdst,
+				  char *buf, size_t buflen, struct group **grdstp);
+static struct group *nwrap_files_getgrgid(gid_t gid);
+static int nwrap_files_getgrgid_r(gid_t gid, struct group *grdst,
+				  char *buf, size_t buflen, struct group **grdstp);
+static void nwrap_files_setgrent(void);
+static struct group *nwrap_files_getgrent(void);
+static int nwrap_files_getgrent_r(struct group *grdst, char *buf,
+				  size_t buflen, struct group **grdstp);
+static void nwrap_files_endgrent(void);
+static int nwrap_files_getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups);
+
+struct nwrap_ops nwrap_files_ops = {
+	.name		= "files",
+	.getpwnam	= nwrap_files_getpwnam,
+	.getpwnam_r	= nwrap_files_getpwnam_r,
+	.getpwuid	= nwrap_files_getpwuid,
+	.getpwuid_r	= nwrap_files_getpwuid_r,
+	.setpwent	= nwrap_files_setpwent,
+	.getpwent	= nwrap_files_getpwent,
+	.getpwent_r	= nwrap_files_getpwent_r,
+	.endpwent	= nwrap_files_endpwent,
+	.initgroups	= nwrap_files_initgroups,
+	.getgrnam	= nwrap_files_getgrnam,
+	.getgrnam_r	= nwrap_files_getgrnam_r,
+	.getgrgid	= nwrap_files_getgrgid,
+	.getgrgid_r	= nwrap_files_getgrgid_r,
+	.setgrent	= nwrap_files_setgrent,
+	.getgrent	= nwrap_files_getgrent,
+	.getgrent_r	= nwrap_files_getgrent_r,
+	.endgrent	= nwrap_files_endgrent,
+	.getgrouplist	= nwrap_files_getgrouplist
+};
+
+struct nwrap_main {
+	struct nwrap_ops *ops;
+};
+
+struct nwrap_main *nwrap_main_global;
+struct nwrap_main __nwrap_main_global;
+
 struct nwrap_cache {
 	const char *path;
 	int fd;
@@ -184,6 +266,10 @@ static void nwrap_init(void)
 	if (initialized) return;
 	initialized = true;
 
+	nwrap_main_global = &__nwrap_main_global;
+
+	nwrap_main_global->ops = &nwrap_files_ops;
+
 	nwrap_pw_global.cache = &__nwrap_cache_pw;
 
 	nwrap_pw_global.cache->path = getenv("NSS_WRAPPER_PASSWD");
@@ -801,15 +887,6 @@ static struct passwd *nwrap_files_getpwnam(const char *name)
 	return NULL;
 }
 
-_PUBLIC_ struct passwd *nwrap_getpwnam(const char *name)
-{
-	if (!nwrap_enabled()) {
-		return real_getpwnam(name);
-	}
-
-	return nwrap_files_getpwnam(name);
-}
-
 static int nwrap_files_getpwnam_r(const char *name, struct passwd *pwdst,
 				  char *buf, size_t buflen, struct passwd **pwdstp)
 {
@@ -826,16 +903,6 @@ static int nwrap_files_getpwnam_r(const char *name, struct passwd *pwdst,
 	return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
 }
 
-_PUBLIC_ int nwrap_getpwnam_r(const char *name, struct passwd *pwdst,
-			      char *buf, size_t buflen, struct passwd **pwdstp)
-{
-	if (!nwrap_enabled()) {
-		return real_getpwnam_r(name, pwdst, buf, buflen, pwdstp);
-	}
-
-	return nwrap_files_getpwnam_r(name, pwdst, buf, buflen, pwdstp);
-}
-
 static struct passwd *nwrap_files_getpwuid(uid_t uid)
 {
 	int i;
@@ -859,15 +926,6 @@ static struct passwd *nwrap_files_getpwuid(uid_t uid)
 	return NULL;
 }
 
-_PUBLIC_ struct passwd *nwrap_getpwuid(uid_t uid)
-{
-	if (!nwrap_enabled()) {
-		return real_getpwuid(uid);
-	}
-
-	return nwrap_files_getpwuid(uid);
-}
-
 static int nwrap_files_getpwuid_r(uid_t uid, struct passwd *pwdst,
 				  char *buf, size_t buflen, struct passwd **pwdstp)
 {
@@ -884,31 +942,12 @@ static int nwrap_files_getpwuid_r(uid_t uid, struct passwd *pwdst,
 	return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
 }
 
-_PUBLIC_ int nwrap_getpwuid_r(uid_t uid, struct passwd *pwdst,
-			      char *buf, size_t buflen, struct passwd **pwdstp)
-{
-	if (!nwrap_enabled()) {
-		return real_getpwuid_r(uid, pwdst, buf, buflen, pwdstp);
-	}
-
-	return nwrap_files_getpwuid_r(uid, pwdst, buf, buflen, pwdstp);
-}
-
 /* user enum functions */
 static void nwrap_files_setpwent(void)
 {
 	nwrap_pw_global.idx = 0;
 }
 
-_PUBLIC_ void nwrap_setpwent(void)
-{
-	if (!nwrap_enabled()) {
-		real_setpwent();
-	}
-
-	nwrap_files_setpwent();
-}
-
 static struct passwd *nwrap_files_getpwent(void)
 {
 	struct passwd *pw;
@@ -930,15 +969,6 @@ static struct passwd *nwrap_files_getpwent(void)
 	return pw;
 }
 
-_PUBLIC_ struct passwd *nwrap_getpwent(void)
-{
-	if (!nwrap_enabled()) {
-		return real_getpwent();
-	}
-
-	return nwrap_files_getpwent();
-}
-
 static int nwrap_files_getpwent_r(struct passwd *pwdst, char *buf,
 				  size_t buflen, struct passwd **pwdstp)
 {
@@ -955,45 +985,11 @@ static int nwrap_files_getpwent_r(struct passwd *pwdst, char *buf,
 	return nwrap_pw_copy_r(pw, pwdst, buf, buflen, pwdstp);
 }
 
-_PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf,
-			      size_t buflen, struct passwd **pwdstp)
-{
-	if (!nwrap_enabled()) {
-#ifdef SOLARIS_GETPWENT_R
-		struct passwd *pw;
-		pw = real_getpwent_r(pwdst, buf, buflen);
-		if (!pw) {
-			if (errno == 0) {
-				return ENOENT;
-			}
-			return errno;
-		}
-		if (pwdstp) {
-			*pwdstp = pw;
-		}
-		return 0;
-#else
-		return real_getpwent_r(pwdst, buf, buflen, pwdstp);
-#endif
-	}
-
-	return nwrap_files_getpwent_r(pwdst, buf, buflen, pwdstp);
-}
-
 static void nwrap_files_endpwent(void)
 {
 	nwrap_pw_global.idx = 0;
 }
 
-_PUBLIC_ void nwrap_endpwent(void)
-{
-	if (!nwrap_enabled()) {
-		real_endpwent();
-	}
-
-	nwrap_files_endpwent();
-}
-
 /* misc functions */
 static int nwrap_files_initgroups(const char *user, gid_t group)
 {
@@ -1001,15 +997,6 @@ static int nwrap_files_initgroups(const char *user, gid_t group)
 	return EPERM;
 }
 
-_PUBLIC_ int nwrap_initgroups(const char *user, gid_t group)
-{
-	if (!nwrap_enabled()) {
-		return real_initgroups(user, group);
-	}
-
-	return nwrap_files_initgroups(user, group);
-}
-
 /* group functions */
 static struct group *nwrap_files_getgrnam(const char *name)
 {
@@ -1034,15 +1021,6 @@ static struct group *nwrap_files_getgrnam(const char *name)
 	return NULL;
 }
 
-_PUBLIC_ struct group *nwrap_getgrnam(const char *name)
-{
-	if (!nwrap_enabled()) {
-		return real_getgrnam(name);
-	}
-
-	return nwrap_files_getgrnam(name);
-}
-
 static int nwrap_files_getgrnam_r(const char *name, struct group *grdst,
 				  char *buf, size_t buflen, struct group **grdstp)
 {
@@ -1059,16 +1037,6 @@ static int nwrap_files_getgrnam_r(const char *name, struct group *grdst,
 	return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp);
 }
 
-_PUBLIC_ int nwrap_getgrnam_r(const char *name, struct group *grdst,
-			      char *buf, size_t buflen, struct group **grdstp)
-{
-	if (!nwrap_enabled()) {
-		return real_getgrnam_r(name, grdst, buf, buflen, grdstp);
-	}
-
-	return nwrap_files_getgrnam_r(name, grdst, buf, buflen, grdstp);
-}
-
 static struct group *nwrap_files_getgrgid(gid_t gid)
 {
 	int i;
@@ -1092,15 +1060,6 @@ static struct group *nwrap_files_getgrgid(gid_t gid)
 	return NULL;
 }
 
-_PUBLIC_ struct group *nwrap_getgrgid(gid_t gid)
-{
-	if (!nwrap_enabled()) {
-		return real_getgrgid(gid);
-	}
-
-	return nwrap_files_getgrgid(gid);
-}
-
 static int nwrap_files_getgrgid_r(gid_t gid, struct group *grdst,
 				  char *buf, size_t buflen, struct group **grdstp)
 {
@@ -1119,31 +1078,12 @@ static int nwrap_files_getgrgid_r(gid_t gid, struct group *grdst,
 	return ENOENT;
 }
 
-_PUBLIC_ int nwrap_getgrgid_r(gid_t gid, struct group *grdst,
-			      char *buf, size_t buflen, struct group **grdstp)
-{
-	if (!nwrap_enabled()) {
-		return real_getgrgid_r(gid, grdst, buf, buflen, grdstp);
-	}
-
-	return nwrap_files_getgrgid_r(gid, grdst, buf, buflen, grdstp);
-}
-
 /* group enum functions */
 static void nwrap_files_setgrent(void)
 {
 	nwrap_gr_global.idx = 0;
 }
 
-_PUBLIC_ void nwrap_setgrent(void)
-{
-	if (!nwrap_enabled()) {
-		real_setgrent();
-	}
-
-	nwrap_files_setgrent();
-}
-
 static struct group *nwrap_files_getgrent(void)
 {
 	struct group *gr;
@@ -1165,15 +1105,6 @@ static struct group *nwrap_files_getgrent(void)
 	return gr;
 }
 
-_PUBLIC_ struct group *nwrap_getgrent(void)
-{
-	if (!nwrap_enabled()) {
-		return real_getgrent();
-	}
-
-	return nwrap_files_getgrent();
-}
-
 static int nwrap_files_getgrent_r(struct group *grdst, char *buf,
 				  size_t buflen, struct group **grdstp)
 {
@@ -1190,45 +1121,11 @@ static int nwrap_files_getgrent_r(struct group *grdst, char *buf,
 	return nwrap_gr_copy_r(gr, grdst, buf, buflen, grdstp);
 }
 
-_PUBLIC_ int nwrap_getgrent_r(struct group *grdst, char *buf,
-			      size_t buflen, struct group **grdstp)
-{
-	if (!nwrap_enabled()) {
-#ifdef SOLARIS_GETGRENT_R
-		struct group *gr;
-		gr = real_getgrent_r(grdst, buf, buflen);
-		if (!gr) {
-			if (errno == 0) {
-				return ENOENT;
-			}
-			return errno;
-		}
-		if (grdstp) {
-			*grdstp = gr;
-		}
-		return 0;
-#else
-		return real_getgrent_r(grdst, buf, buflen, grdstp);
-#endif
-	}
-
-	return nwrap_files_getgrent_r(grdst, buf, buflen, grdstp);
-}
-
 static void nwrap_files_endgrent(void)
 {
 	nwrap_gr_global.idx = 0;
 }
 
-_PUBLIC_ void nwrap_endgrent(void)
-{
-	if (!nwrap_enabled()) {
-		real_endgrent();
-	}
-
-	nwrap_files_endgrent();
-}
-
 static int nwrap_files_getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups)
 {
 	struct group *grp;
@@ -1297,12 +1194,208 @@ static int nwrap_files_getgrouplist(const char *user, gid_t group, gid_t *groups
 	return count;
 }
 
+/*
+ * PUBLIC interface
+ */
+
+_PUBLIC_ struct passwd *nwrap_getpwnam(const char *name)
+{
+	if (!nwrap_enabled()) {
+		return real_getpwnam(name);
+	}
+
+	return nwrap_main_global->ops->getpwnam(name);
+}
+
+_PUBLIC_ int nwrap_getpwnam_r(const char *name, struct passwd *pwdst,
+			      char *buf, size_t buflen, struct passwd **pwdstp)
+{
+	if (!nwrap_enabled()) {
+		return real_getpwnam_r(name, pwdst, buf, buflen, pwdstp);
+	}
+
+	return nwrap_main_global->ops->getpwnam_r(name, pwdst, buf, buflen, pwdstp);
+}
+
+_PUBLIC_ struct passwd *nwrap_getpwuid(uid_t uid)
+{
+	if (!nwrap_enabled()) {
+		return real_getpwuid(uid);
+	}
+
+	return nwrap_main_global->ops->getpwuid(uid);
+}
+
+_PUBLIC_ int nwrap_getpwuid_r(uid_t uid, struct passwd *pwdst,
+			      char *buf, size_t buflen, struct passwd **pwdstp)
+{
+	if (!nwrap_enabled()) {
+		return real_getpwuid_r(uid, pwdst, buf, buflen, pwdstp);
+	}
+
+	return nwrap_main_global->ops->getpwuid_r(uid, pwdst, buf, buflen, pwdstp);
+}
+
+_PUBLIC_ void nwrap_setpwent(void)
+{
+	if (!nwrap_enabled()) {
+		real_setpwent();
+		return;
+	}
+
+	nwrap_main_global->ops->setpwent();
+}
+
+_PUBLIC_ struct passwd *nwrap_getpwent(void)
+{
+	if (!nwrap_enabled()) {
+		return real_getpwent();
+	}
+
+	return nwrap_main_global->ops->getpwent();
+}
+
+_PUBLIC_ int nwrap_getpwent_r(struct passwd *pwdst, char *buf,
+			      size_t buflen, struct passwd **pwdstp)
+{
+	if (!nwrap_enabled()) {
+#ifdef SOLARIS_GETPWENT_R
+		struct passwd *pw;
+		pw = real_getpwent_r(pwdst, buf, buflen);
+		if (!pw) {
+			if (errno == 0) {
+				return ENOENT;
+			}
+			return errno;
+		}
+		if (pwdstp) {
+			*pwdstp = pw;
+		}
+		return 0;
+#else


-- 
Samba Shared Repository


More information about the samba-cvs mailing list