Skip to contentSkip to conversation

gssd: set $HOME to prevent recursion when home dirs are on kerberized NFS mount

PATCH In review Jeff Layton 2 participants 2 messages Jan 22, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gssd: set $HOME to prevent recursion when home dirs are on kerberized NFS mount

Some krb5 routines will attempt to access files in the user's home directory. This is problematic for gssd when the user's homedir is on a kerberized NFS mount as it will end up deadlocked.

Fix this by setting $HOME unconditionally to "/".

Fixes this Fedora bug:

    https://bugzilla.redhat.com/show_bug.cgi?id=1052902
---
 utils/gssd/gssd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
utils/gssd/gssd.c +13 -0
index fdad153..611ef1a 100644
@@ -46,6 +46,7 @@
 
 #include <unistd.h>
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -161,6 +162,18 @@ main(int argc, char *argv[])
 		}
 	}
 
+	/*
+	 * Some krb5 routines try to scrape info out of files in the user's
+	 * home directory. This can easily deadlock when that homedir is on a
+	 * kerberized NFS mount. By setting $HOME unconditionally to "/", we
+	 * prevent this behavior in routines that use $HOME in preference to
+	 * the results of getpw*.
+	 */
+	if (setenv("HOME", "/", 1)) {
+		printerr(1, "Unable to set $HOME: %s\n", strerror(errno));
+		exit(1);
+	}
+
 	i = 0;
 	ccachesearch[i++] = strtok(ccachedir, ":");
 	do {
Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 6 lines · Jeff Layton

Some krb5 routines will attempt to access files in the user's home directory. This is problematic for gssd when the user's homedir is on a kerberized NFS mount as it will end up deadlocked.

Fix this by setting $HOME unconditionally to "/".

Quoted 8 lines

Fixes this Fedora bug:

    https://bugzilla.redhat.com/show_bug.cgi?id=1052902

Committed...

steved.

Quoted 36 lines
---
 utils/gssd/gssd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
utils/gssd/gssd.c +13 -0
index fdad153..611ef1a 100644
@@ -46,6 +46,7 @@
 
 #include <unistd.h>
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -161,6 +162,18 @@ main(int argc, char *argv[])
 		}
 	}
 
+	/*
+	 * Some krb5 routines try to scrape info out of files in the user's
+	 * home directory. This can easily deadlock when that homedir is on a
+	 * kerberized NFS mount. By setting $HOME unconditionally to "/", we
+	 * prevent this behavior in routines that use $HOME in preference to
+	 * the results of getpw*.
+	 */
+	if (setenv("HOME", "/", 1)) {
+		printerr(1, "Unable to set $HOME: %s\n", strerror(errno));
+		exit(1);
+	}
+
 	i = 0;
 	ccachesearch[i++] = strtok(ccachedir, ":");
 	do {