rpms/nfs-utils-lib/devel libnfsidmap-0.12-set_debug.patch, NONE, 1.1 nfs-utils-lib.spec, 1.1, 1.2

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Fri Jan 20 13:07:43 UTC 2006


Author: steved

Update of /cvs/dist/rpms/nfs-utils-lib/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv20127

Modified Files:
	nfs-utils-lib.spec 
Added Files:
	libnfsidmap-0.12-set_debug.patch 
Log Message:
- Added debugging routines to libnfsidmap


libnfsidmap-0.12-set_debug.patch:
 libnfsidmap.c       |   34 +++++++++++++++++++++++++++++++---
 nfsidmap.h          |    1 +
 nfsidmap_internal.h |    1 +
 nss.c               |   21 ++++++++++++++++++++-
 4 files changed, 53 insertions(+), 4 deletions(-)

--- NEW FILE libnfsidmap-0.12-set_debug.patch ---
--- libnfsidmap-0.12/nss.c.orig	2005-11-01 10:04:45.000000000 -0500
+++ libnfsidmap-0.12/nss.c	2006-01-19 17:03:17.515117000 -0500
@@ -47,6 +47,12 @@
 #include "nfsidmap.h"
 #include "nfsidmap_internal.h"
 #include "cfg.h"
+#include <syslog.h>
+
+static void (*nss_logfunc)(const char *, ...) = NULL;
+static int nss_verbose = 0;
+#define NSS_LOG(FMT, ...) \
+	if (nss_verbose && nss_logfunc) (*nss_logfunc)(FMT, ##__VA_ARGS__)
 
 /*
  * NSS Translation Methods
@@ -159,8 +165,11 @@
 
 	err = EINVAL;
 	localname = strip_domain(name, domain);
-	if (localname == NULL)
+	if (localname == NULL) {
+		NSS_LOG("nss_getpwnam failed: name '%s' does not map" 
+			" into '%s' domain\n", name, domain);
 		goto err_free_buf;
+	}
 
 	err = getpwnam_r(localname, &buf->pwbuf, buf->buf, buflen, &pw);
 	free(localname);
@@ -168,6 +177,9 @@
 		*err_p = 0;
 		return &buf->pwbuf;
 	}
+	NSS_LOG("nss_getpwnam failed: name '%s' not found in '%s' domain\n",
+		localname, domain);
+
 err_free_buf:
 	free(buf);
 err:
@@ -259,6 +271,12 @@
 	return ret;
 }
 
+void nss_set_debug(int verbose, void (*logger)(const char *, ...))
+{
+	if (logger)
+		nss_logfunc = logger;
+	nss_verbose = verbose;	
+}
 
 struct trans_func nss_trans = {
 	.name		= "nsswitch",
@@ -269,4 +287,5 @@
 	.uid_to_name	= nss_uid_to_name,
 	.gid_to_name	= nss_gid_to_name,
 	.gss_princ_to_grouplist = nss_gss_princ_to_grouplist,
+	.set_debug = nss_set_debug,
 };
--- libnfsidmap-0.12/nfsidmap.h.orig	2004-11-14 19:03:05.000000000 -0500
+++ libnfsidmap-0.12/nfsidmap.h	2006-01-19 15:19:01.391867000 -0500
@@ -46,3 +46,4 @@
 int nfs4_name_to_gid(char *name, gid_t *gid);
 int nfs4_gss_princ_to_ids(char *secname, char *princ, uid_t *uid, gid_t *gid);
 int nfs4_gss_princ_to_grouplist(char *secname, char *princ, gid_t *groups, int *ngroups);
+void nfs4_set_debug(int verbose, void (*logger)(const char *, ...));
--- libnfsidmap-0.12/libnfsidmap.c.orig	2004-12-16 11:35:02.000000000 -0500
+++ libnfsidmap-0.12/libnfsidmap.c	2006-01-19 17:04:35.044067000 -0500
@@ -45,10 +45,13 @@
 #include <grp.h>
 #include <netdb.h>
 #include <err.h>
+#include <syslog.h>
+#include <stdarg.h>
 #include "nfsidmap.h"
 #include "nfsidmap_internal.h"
 #include "cfg.h"
 
+
 /* forward declarations */
 int set_trans_method(char *);
 
@@ -57,6 +60,23 @@
 #ifndef PATH_IDMAPDCONF
 #define PATH_IDMAPDCONF "/etc/idmapd.conf"
 #endif
+static void nfs4_log(const char *fmt, ...)
+{
+	va_list vp;
+
+	va_start(vp, fmt);
+	vsyslog(LOG_WARNING, fmt, vp); 
+	va_end(vp);
+}
+static void (*logfunc)(char *, ...) = nfs4_log;
+static int beverbose = 0;
+
+void nfs4_set_debug(int verbose, void (*logger)(const char *, ...))
+{
+	if (logger)
+		logfunc = logger;
+	beverbose = verbose;	
+}
 
 static int domain_from_dns(char **domain)
 {
@@ -92,18 +112,26 @@
 	if (default_domain == NULL) {
 		ret = domain_from_dns(&default_domain);
 		if (ret) {
-			warnx("unable to determine a default nfsv4 domain; "
+			(*logfunc)("Unable to determine a default nfsv4 domain; "
 				" consider specifying one in idmapd.conf\n");
 			return ret;
 		}
 	}
+	if (beverbose)
+		(*logfunc)("default domain: %s\n", default_domain); 
+
 	method = conf_get_str("Translation", "Method");
 	if (method == NULL)
 		method = "nsswitch";
 	if (set_trans_method(method) == -1) {
-		warnx("Error in translation table setup");
+		(*logfunc)("Error in translation table setup");
 		return -1;
 	}
+	if (beverbose)
+		(*logfunc)("translation method: %s\n", method); 
+
+	if (trans->set_debug)
+		trans->set_debug(beverbose, logfunc);
 
 	if (trans->init) {
 		ret = trans->init();
@@ -124,7 +152,7 @@
 		return default_domain;
 	ret = domain_from_dns(&default_domain);
 	if (ret) {
-		warnx("unable to determine a default nfsv4 domain; "
+		(*logfunc)("Unable to determine a default nfsv4 domain; "
 			" consider specifying one in idmapd.conf\n");
 		default_domain = "";
 	}
--- libnfsidmap-0.12/nfsidmap_internal.h.orig	2004-12-20 12:23:26.000000000 -0500
+++ libnfsidmap-0.12/nfsidmap_internal.h	2006-01-19 15:52:45.110420000 -0500
@@ -46,6 +46,7 @@
 	int (*uid_to_name)(uid_t uid, char *domain, char *name, size_t len);
 	int (*gid_to_name)(gid_t gid, char *domain, char *name, size_t len);
 	int (*gss_princ_to_grouplist)(char *secname, char *princ, gid_t *groups, int *ngroups);
+	void (*set_debug)(int verbose, void (*logger)(const char *, ...));
 };
 
 typedef enum {


Index: nfs-utils-lib.spec
===================================================================
RCS file: /cvs/dist/rpms/nfs-utils-lib/devel/nfs-utils-lib.spec,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nfs-utils-lib.spec	6 Jan 2006 22:45:21 -0000	1.1
+++ nfs-utils-lib.spec	20 Jan 2006 13:07:35 -0000	1.2
@@ -1,7 +1,7 @@
 Summary: Network File System Support Library
 Name: nfs-utils-lib
 Version: 1.0.8
-Release: 1
+Release: 2
 URL: http://www.citi.umich.edu/projects/nfsv4/linux/
 License: GPL
 
@@ -22,6 +22,8 @@
 Requires(pre): /sbin/ldconfig
 PreReq: libgssapi
 
+Patch1: libnfsidmap-0.12-set_debug.patch
+
 %description
 Support libaries that are needed by the commands and 
 daemons the nfs-utils rpm.
@@ -38,6 +40,9 @@
 
 %prep
 %setup -c -q -a1
+
+%patch1 -p0
+
 top=`pwd`
 for dir in %{libs} ; do
 	pushd $dir
@@ -126,5 +131,8 @@
 %{_libdir}/libnfsidmap.a
 
 %changelog
+* Thu Jan 19 2006 Steve Dickson <steved at redhat.com> 1.0.8-2
+- Added debugging routines to libnfsidmap
+
 * Fri Jan  6 2006 Steve Dickson <steved at redhat.com> 1.0.8-1
 - Initial commit




More information about the fedora-cvs-commits mailing list