c398f3
diff -up nfs-utils-2.3.3/nfs.conf.orig nfs-utils-2.3.3/nfs.conf
c398f3
--- nfs-utils-2.3.3/nfs.conf.orig	2021-04-17 10:49:23.660184527 -0400
c398f3
+++ nfs-utils-2.3.3/nfs.conf	2021-04-17 11:14:41.482108562 -0400
c398f3
@@ -21,6 +21,7 @@ use-gss-proxy=1
c398f3
 # keytab-file=/etc/krb5.keytab
c398f3
 # cred-cache-directory=
c398f3
 # preferred-realm=
c398f3
+# set-home=1
c398f3
 #
c398f3
 [lockd]
c398f3
 # port=0
c398f3
diff -up nfs-utils-2.3.3/systemd/nfs.conf.man.orig nfs-utils-2.3.3/systemd/nfs.conf.man
c398f3
--- nfs-utils-2.3.3/systemd/nfs.conf.man.orig	2021-04-17 10:49:23.696185472 -0400
c398f3
+++ nfs-utils-2.3.3/systemd/nfs.conf.man	2021-04-17 11:14:41.483108588 -0400
c398f3
@@ -222,7 +222,8 @@ Recognized values:
c398f3
 .BR rpc-timeout ,
c398f3
 .BR keytab-file ,
c398f3
 .BR cred-cache-directory ,
c398f3
-.BR preferred-realm .
c398f3
+.BR preferred-realm ,
c398f3
+.BR set-home .
c398f3
 
c398f3
 See
c398f3
 .BR rpc.gssd (8)
c398f3
diff -up nfs-utils-2.3.3/utils/gssd/gssd.c.orig nfs-utils-2.3.3/utils/gssd/gssd.c
c398f3
--- nfs-utils-2.3.3/utils/gssd/gssd.c.orig	2021-04-17 10:49:23.684185157 -0400
c398f3
+++ nfs-utils-2.3.3/utils/gssd/gssd.c	2021-04-17 11:14:41.483108588 -0400
c398f3
@@ -87,6 +87,8 @@ unsigned int  context_timeout = 0;
c398f3
 unsigned int  rpc_timeout = 5;
c398f3
 char *preferred_realm = NULL;
c398f3
 char *ccachedir = NULL;
c398f3
+/* set $HOME to "/" by default */
c398f3
+static bool set_home = true;
c398f3
 /* Avoid DNS reverse lookups on server names */
c398f3
 static bool avoid_dns = true;
c398f3
 static bool use_gssproxy = false;
c398f3
@@ -885,7 +887,7 @@ sig_die(int signal)
c398f3
 static void
c398f3
 usage(char *progname)
c398f3
 {
c398f3
-	fprintf(stderr, "usage: %s [-f] [-l] [-M] [-n] [-v] [-r] [-p pipefsdir] [-k keytab] [-d ccachedir] [-t timeout] [-R preferred realm] [-D]\n",
c398f3
+	fprintf(stderr, "usage: %s [-f] [-l] [-M] [-n] [-v] [-r] [-p pipefsdir] [-k keytab] [-d ccachedir] [-t timeout] [-R preferred realm] [-D] [-H]\n",
c398f3
 		progname);
c398f3
 	exit(1);
c398f3
 }
c398f3
@@ -926,6 +928,7 @@ read_gss_conf(void)
c398f3
 		preferred_realm = s;
c398f3
 
c398f3
 	use_gssproxy = conf_get_bool("gssd", "use-gss-proxy", use_gssproxy);
c398f3
+	set_home = conf_get_bool("gssd", "set-home", set_home);
c398f3
 }
c398f3
 
c398f3
 int
c398f3
@@ -946,7 +949,7 @@ main(int argc, char *argv[])
c398f3
 	verbosity = conf_get_num("gssd", "verbosity", verbosity);
c398f3
 	rpc_verbosity = conf_get_num("gssd", "rpc-verbosity", rpc_verbosity);
c398f3
 
c398f3
-	while ((opt = getopt(argc, argv, "DfvrlmnMp:k:d:t:T:R:")) != -1) {
c398f3
+	while ((opt = getopt(argc, argv, "HDfvrlmnMp:k:d:t:T:R:")) != -1) {
c398f3
 		switch (opt) {
c398f3
 			case 'f':
c398f3
 				fg = 1;
c398f3
@@ -994,6 +997,9 @@ main(int argc, char *argv[])
c398f3
 			case 'D':
c398f3
 				avoid_dns = false;
c398f3
 				break;
c398f3
+			case 'H':
c398f3
+				set_home = false;
c398f3
+				break;
c398f3
 			default:
c398f3
 				usage(argv[0]);
c398f3
 				break;
c398f3
@@ -1003,13 +1009,19 @@ main(int argc, char *argv[])
c398f3
 	/*
c398f3
 	 * Some krb5 routines try to scrape info out of files in the user's
c398f3
 	 * home directory. This can easily deadlock when that homedir is on a
c398f3
-	 * kerberized NFS mount. By setting $HOME unconditionally to "/", we
c398f3
-	 * prevent this behavior in routines that use $HOME in preference to
c398f3
-	 * the results of getpw*.
c398f3
+	 * kerberized NFS mount. By setting $HOME to "/" by default, we prevent
c398f3
+	 * this behavior in routines that use $HOME in preference to the results
c398f3
+	 * of getpw*.
c398f3
+	 *
c398f3
+	 * Some users do not use Kerberized home dirs and need $HOME to remain
c398f3
+	 * unchanged. Those users can leave $HOME unchanged by setting set_home
c398f3
+	 * to false.
c398f3
 	 */
c398f3
-	if (setenv("HOME", "/", 1)) {
c398f3
-		printerr(0, "gssd: Unable to set $HOME: %s\n", strerror(errno));
c398f3
-		exit(1);
c398f3
+	if (set_home) {
c398f3
+		if (setenv("HOME", "/", 1)) {
c398f3
+			printerr(0, "gssd: Unable to set $HOME: %s\n", strerror(errno));
c398f3
+			exit(1);
c398f3
+		}
c398f3
 	}
c398f3
 
c398f3
 	if (use_gssproxy) {
c398f3
diff -up nfs-utils-2.3.3/utils/gssd/gssd.man.orig nfs-utils-2.3.3/utils/gssd/gssd.man
c398f3
--- nfs-utils-2.3.3/utils/gssd/gssd.man.orig	2021-04-17 10:49:23.650184264 -0400
c398f3
+++ nfs-utils-2.3.3/utils/gssd/gssd.man	2021-04-17 11:14:41.484108615 -0400
c398f3
@@ -8,7 +8,7 @@
c398f3
 rpc.gssd \- RPCSEC_GSS daemon
c398f3
 .SH SYNOPSIS
c398f3
 .B rpc.gssd
c398f3
-.RB [ \-DfMnlvr ]
c398f3
+.RB [ \-DfMnlvrH ]
c398f3
 .RB [ \-k
c398f3
 .IR keytab ]
c398f3
 .RB [ \-p
c398f3
@@ -297,6 +297,16 @@ The default timeout is set to 5 seconds.
c398f3
 If you get messages like "WARNING: can't create tcp rpc_clnt to server
c398f3
 %servername% for user with uid %uid%: RPC: Remote system error -
c398f3
 Connection timed out", you should consider an increase of this timeout.
c398f3
+.TP
c398f3
+.B -H
c398f3
+Avoids setting $HOME to "/". This allows rpc.gssd to read per user k5identity
c398f3
+files versus trying to read /.k5identity for each user.
c398f3
+
c398f3
+If
c398f3
+.B \-H
c398f3
+is not set, rpc.gssd will use the first match found in
c398f3
+/var/kerberos/krb5/user/$EUID/client.keytab and will not use a principal based on
c398f3
+host and/or service parameters listed in $HOME/.k5identity.
c398f3
 .SH CONFIGURATION FILE
c398f3
 Many of the options that can be set on the command line can also be
c398f3
 controlled through values set in the
c398f3
@@ -354,6 +364,13 @@ Equivalent to
c398f3
 .B preferred-realm
c398f3
 Equivalent to
c398f3
 .BR -R .
c398f3
+.TP
c398f3
+.B set-home
c398f3
+Setting to
c398f3
+.B false
c398f3
+is equivalent to providing the
c398f3
+.B -H
c398f3
+flag.
c398f3
 .P
c398f3
 In addtion, the following value is recognized from the
c398f3
 .B [general]