2007-01-07 17:26:05 +01:00
|
|
|
--- session.c
|
|
|
|
+++ session.c
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1110,7 +1110,7 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static char **
|
|
|
|
-do_setup_env(Session *s, const char *shell)
|
|
|
|
+do_setup_env(Session *s, const char *shell, int *env_size)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
u_int i, envsize;
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1297,6 +1297,8 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
for (i = 0; env[i]; i++)
|
|
|
|
fprintf(stderr, " %.200s\n", env[i]);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ *env_size = envsize;
|
|
|
|
return env;
|
|
|
|
}
|
|
|
|
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1305,7 +1307,7 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
* first in this order).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
-do_rc_files(Session *s, const char *shell)
|
|
|
|
+do_rc_files(Session *s, const char *shell, char **env, int *env_size)
|
|
|
|
{
|
|
|
|
FILE *f = NULL;
|
|
|
|
char cmd[1024];
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1359,12 +1361,20 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
options.xauth_location);
|
|
|
|
f = popen(cmd, "w");
|
|
|
|
if (f) {
|
|
|
|
+ char hostname[MAXHOSTNAMELEN];
|
|
|
|
+
|
|
|
|
fprintf(f, "remove %s\n",
|
|
|
|
s->auth_display);
|
|
|
|
fprintf(f, "add %s %s %s\n",
|
|
|
|
s->auth_display, s->auth_proto,
|
|
|
|
s->auth_data);
|
|
|
|
pclose(f);
|
|
|
|
+ if (gethostname(hostname,sizeof(hostname)) >= 0)
|
|
|
|
+ child_set_env(&env,env_size,"XAUTHLOCALHOSTNAME",
|
|
|
|
+ hostname);
|
|
|
|
+ else
|
|
|
|
+ debug("Cannot set up XAUTHLOCALHOSTNAME %s\n",
|
|
|
|
+ strerror(errno));
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Could not run %s\n",
|
|
|
|
cmd);
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1650,6 +1660,7 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
{
|
|
|
|
extern char **environ;
|
|
|
|
char **env;
|
|
|
|
+ int env_size;
|
2008-04-09 22:21:23 +02:00
|
|
|
char *argv[ARGV_MAX];
|
2007-01-07 17:26:05 +01:00
|
|
|
const char *shell, *shell0, *hostname = NULL;
|
|
|
|
struct passwd *pw = s->pw;
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1716,7 +1727,7 @@
|
2007-01-07 17:26:05 +01:00
|
|
|
* Make sure $SHELL points to the shell from the password file,
|
|
|
|
* even if shell is overridden from login.conf
|
|
|
|
*/
|
|
|
|
- env = do_setup_env(s, shell);
|
|
|
|
+ env = do_setup_env(s, shell, &env_size);
|
|
|
|
|
|
|
|
#ifdef HAVE_LOGIN_CAP
|
|
|
|
shell = login_getcapstr(lc, "shell", (char *)shell, (char *)shell);
|
2009-03-03 22:42:45 +01:00
|
|
|
@@ -1784,7 +1795,7 @@
|
2008-04-09 22:21:23 +02:00
|
|
|
closefrom(STDERR_FILENO + 1);
|
2007-01-07 17:26:05 +01:00
|
|
|
|
|
|
|
if (!options.use_login)
|
|
|
|
- do_rc_files(s, shell);
|
|
|
|
+ do_rc_files(s, shell, env, &env_size);
|
|
|
|
|
|
|
|
/* restore SIGPIPE for child */
|
|
|
|
signal(SIGPIPE, SIG_DFL);
|