Hello,

>>> I am using a Linux nfs client with an NFSROOT directory, the NFS server
>>> is
>>> also a Linux machine, with nfs-ganesha.
>>>
>>> After every boot, the NFS client hangs after some time. This is not too
>>> surprising and probably I will never really need the NFS client up for
>>> as
>>> long as it runs before the crash occurs. What is surprising is that, in
>>> several checks, the time from boot to crash was always very near to 28
>>> minutes.
>>>
>>> Any idea what is causing this behaviour?

Can anyone reproduce this behaviour, that the client crashes after some
time when using nfs-ganesha as a NFS4 server for an NFSROOT client? If
this does not happen anywhere else, the crash is maybe caused by a patch I
created to allow only numeric IDs, but I just re-checked the patch and
could not find a reason for the crash there.

I attached the patch, maybe one of the developers can check it?

Regards
  Christoph
Index: nfs-ganesha-2.2.0/config_samples/config.txt
===================================================================
--- nfs-ganesha-2.2.0.orig/config_samples/config.txt	2015-04-22 13:11:27.000000000 +0200
+++ nfs-ganesha-2.2.0/config_samples/config.txt	2015-04-22 13:12:25.000000000 +0200
@@ -163,6 +163,8 @@
 
 	Delegations(bool, default false)
 
+	Use_NFS_Idmap(bool, default true)
+
 
 EXPORT_DEFAULTS {}
 ------------------
Index: nfs-ganesha-2.2.0/include/gsh_config.h
===================================================================
--- nfs-ganesha-2.2.0.orig/include/gsh_config.h	2015-04-22 13:11:27.000000000 +0200
+++ nfs-ganesha-2.2.0/include/gsh_config.h	2015-04-22 14:37:39.000000000 +0200
@@ -425,6 +425,8 @@
 	bool pnfs_mds;
 	/** Whether this a pNFS DS server. Defaults to false */
 	bool pnfs_ds;
+	/** Whether to use ID mapping **/
+	bool use_idmap;
 } nfs_version4_parameter_t;
 
 /** @} */
Index: nfs-ganesha-2.2.0/support/nfs_read_conf.c
===================================================================
--- nfs-ganesha-2.2.0.orig/support/nfs_read_conf.c	2015-04-22 13:11:27.000000000 +0200
+++ nfs-ganesha-2.2.0/support/nfs_read_conf.c	2015-04-22 14:14:29.000000000 +0200
@@ -241,6 +241,8 @@
 		       nfs_version4_parameter, pnfs_mds),
 	CONF_ITEM_BOOL("PNFS_DS", true,
 		       nfs_version4_parameter, pnfs_ds),
+	CONF_ITEM_BOOL("Use_NFS_Idmap", true,
+		       nfs_version4_parameter, use_idmap),
 	CONFIG_EOL
 };
 
Index: nfs-ganesha-2.2.0/idmapper/idmapper.c
===================================================================
--- nfs-ganesha-2.2.0.orig/idmapper/idmapper.c	2015-04-22 13:19:13.000000000 +0200
+++ nfs-ganesha-2.2.0/idmapper/idmapper.c	2015-04-22 16:09:07.000000000 +0200
@@ -65,6 +65,7 @@
 bool idmapper_init(void)
 {
 #ifdef USE_NFSIDMAP
+  if (nfs_param.nfsv4_param.use_idmap) {
 	if (!nfs_param.nfsv4_param.use_getpwnam) {
 		if (nfs4_init_name_mapping(nfs_param.nfsv4_param.idmapconf)
 		    != 0) {
@@ -81,6 +82,7 @@
 		}
 		owner_domain.len = strlen(owner_domain.addr);
 	}
+  }
 #endif				/* USE_NFSIDMAP */
 	if (nfs_param.nfsv4_param.use_getpwnam) {
 		owner_domain.addr = gsh_strdup(nfs_param.nfsv4_param
@@ -193,6 +195,7 @@
 			}
 		} else {
 #ifdef USE_NFSIDMAP
+  if (nfs_param.nfsv4_param.use_idmap) {
 			if (group) {
 				rc = nfs4_gid_to_name(id, owner_domain.addr,
 						      namebuff,
@@ -211,6 +214,7 @@
 					(group ? "nfs4_gid_to_name" :
 					"nfs4_uid_to_name"), rc);
 			}
+  }
 #else				/* USE_NFSIDMAP */
 			looked_up = false;
 #endif				/* !USE_NFSIDMAP */
@@ -411,7 +415,19 @@
 				"getgrnam_r %s failed, error: %d", name, err);
 			return false;
 		}
-#ifndef USE_NFSIDMAP
+#ifdef USE_NFSIDMAP
+		else if (!nfs_param.nfsv4_param.use_idmap) {
+			char *end = NULL;
+			gid_t gid;
+
+			gid = strtol(name, &end, 10);
+			if (end && *end != '\0')
+				return 0;
+
+			*id = gid;
+			return true;
+		}
+#else
 		else {
 			char *end = NULL;
 			gid_t gid;
@@ -445,7 +461,20 @@
 			*got_gid = true;
 			return true;
 		}
-#ifndef USE_NFSIDMAP
+#ifdef USE_NFSIDMAP
+		else if (!nfs_param.nfsv4_param.use_idmap) {
+			char *end = NULL;
+			uid_t uid;
+
+			uid = strtol(name, &end, 10);
+			if (end && *end != '\0')
+				return 0;
+
+			*id = uid;
+			*got_gid = false;
+			return true;
+		}
+#else
 		else {
 			char *end = NULL;
 			uid_t uid;
@@ -484,6 +513,7 @@
 			 bool *got_gid, char *at)
 {
 #ifdef USE_NFSIDMAP
+  if (nfs_param.nfsv4_param.use_idmap) {
 	int rc;
 
 	if (group)
@@ -500,6 +530,7 @@
 			-rc);
 		return false;
 	}
+  }
 #else				/* USE_NFSIDMAP */
 	return false;
 #endif				/* USE_NFSIDMAP */
@@ -644,22 +675,27 @@
 bool principal2uid(char *principal, uid_t *uid, gid_t *gid)
 #endif
 {
-#ifdef USE_NFSIDMAP
-	uid_t gss_uid = ANON_UID;
-	gid_t gss_gid = ANON_GID;
+	uid_t gss_uid;
+	gid_t gss_gid;
 	const gid_t *gss_gidres = NULL;
 	int rc;
 	bool success;
-	struct gsh_buffdesc princbuff = {
-		.addr = principal,
-		.len = strlen(principal)
-	};
+	struct gsh_buffdesc princbuff;
+
+#ifdef USE_NFSIDMAP
+  if (nfs_param.nfsv4_param.use_idmap) {
+	gss_uid = ANON_UID;
+	gss_gid = ANON_GID;
+	princbuff.addr = principal;
+	princbuff.len = strlen(principal);
+  }
 #endif
 
 	if (nfs_param.nfsv4_param.use_getpwnam)
 		return false;
 
 #ifdef USE_NFSIDMAP
+  if (nfs_param.nfsv4_param.use_idmap) {
 	PTHREAD_RWLOCK_rdlock(&idmapper_user_lock);
 	success =
 	    idmapper_lookup_by_uname(&princbuff, &gss_uid, &gss_gidres, true);
@@ -777,6 +813,11 @@
 	*gid = gss_gid;
 
 	return true;
+  }
+  else {
+	assert(!"prohibited by configuration");
+	return false;
+  }
 #else				/* !USE_NFSIDMAP */
 	assert(!"prohibited by configuration");
 	return false;
------------------------------------------------------------------------------
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to