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