[Pkg-shadow-devel] xauth and su.c (upstream CVS version)
Alexander Gattin
arg@online.com.ua
Mon, 10 Jan 2005 03:18:30 +0200
--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I have forgot to attach the patch...
--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="su-xauth.patch"
--- shadow-cvs/src/su.c.orig 2005-01-10 02:47:29.000000000 +0200
+++ shadow-cvs/src/su.c 2005-01-10 02:50:58.000000000 +0200
@@ -360,14 +360,19 @@
if ((cp = getenv ("TERM")))
addenv ("TERM", cp);
#ifndef USE_PAM
- /*
- * Also leave DISPLAY and XAUTHORITY if present, else
- * pam_xauth will not work.
- */
- if ((cp = getenv ("DISPLAY")))
- addenv ("DISPLAY", cp);
- if ((cp = getenv ("XAUTHORITY")))
- addenv ("XAUTHORITY", cp);
+ /* Preserve environment for X authentication, if possible.*/
+ if ((cp = getenv("DISPLAY"))) {
+ addenv("DISPLAY", cp);
+ cp = getenv("XAUTHORITY");
+ if (cp) addenv("XAUTHORITY", cp);
+ else if (pw->pw_dir && pw->pw_dir[0]) {
+ cp = malloc(strlen(pw->pw_dir) + 13);
+ sprintf(cp, "%s/.Xauthority",
+ pw->pw_dir);
+ addenv("XAUTHORITY", cp);
+ free(cp);
+ }
+ }
#endif /* !USE_PAM */
} else {
while (*envp)
--r5Pyd7+fXNt84Ff3--