2018-10-17 10:57:56 +02:00
|
|
|
# HG changeset patch
|
|
|
|
# Parent 5e19a205fa03584bb0d829ecbba7495ce1899b65
|
|
|
|
# -- uset do be called '-xauthlocalhostname'
|
|
|
|
handle hostname changes when forwarding X
|
|
|
|
|
2021-01-18 02:12:55 +01:00
|
|
|
Index: openssh-8.4p1/session.c
|
|
|
|
===================================================================
|
|
|
|
--- openssh-8.4p1.orig/session.c
|
|
|
|
+++ openssh-8.4p1/session.c
|
|
|
|
@@ -985,7 +985,7 @@ copy_environment(char **source, char ***
|
2020-06-06 08:49:00 +02:00
|
|
|
#endif
|
2018-10-17 10:57:56 +02:00
|
|
|
|
|
|
|
static char **
|
|
|
|
-do_setup_env(struct ssh *ssh, Session *s, const char *shell)
|
|
|
|
+do_setup_env(struct ssh *ssh, Session *s, const char *shell, int *env_size)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
size_t n;
|
2021-01-18 02:12:55 +01:00
|
|
|
@@ -1195,6 +1195,8 @@ do_setup_env(struct ssh *ssh, Session *s
|
2018-10-17 10:57:56 +02:00
|
|
|
for (i = 0; env[i]; i++)
|
|
|
|
fprintf(stderr, " %.200s\n", env[i]);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ *env_size = envsize;
|
|
|
|
return env;
|
|
|
|
}
|
|
|
|
|
2021-01-18 02:12:55 +01:00
|
|
|
@@ -1203,7 +1205,7 @@ do_setup_env(struct ssh *ssh, Session *s
|
2018-10-17 10:57:56 +02:00
|
|
|
* first in this order).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
-do_rc_files(struct ssh *ssh, Session *s, const char *shell)
|
|
|
|
+do_rc_files(struct ssh *ssh, Session *s, const char *shell, char **env, int *env_size)
|
|
|
|
{
|
|
|
|
FILE *f = NULL;
|
2021-01-18 02:12:55 +01:00
|
|
|
char *cmd = NULL, *user_rc = NULL;
|
|
|
|
@@ -1260,12 +1262,20 @@ do_rc_files(struct ssh *ssh, Session *s,
|
|
|
|
fatal("%s: xasprintf: %s", __func__, strerror(errno));
|
2018-10-17 10:57:56 +02:00
|
|
|
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);
|
2021-01-18 02:12:55 +01:00
|
|
|
@@ -1526,6 +1536,7 @@ do_child(struct ssh *ssh, Session *s, co
|
2019-10-10 15:32:50 +02:00
|
|
|
char **env, *argv[ARGV_MAX], remote_id[512];
|
2018-10-17 10:57:56 +02:00
|
|
|
const char *shell, *shell0;
|
|
|
|
struct passwd *pw = s->pw;
|
2019-10-10 15:32:50 +02:00
|
|
|
+ int env_size;
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
|
2021-01-18 02:12:55 +01:00
|
|
|
@@ -1582,7 +1593,7 @@ do_child(struct ssh *ssh, Session *s, co
|
2018-10-17 10:57:56 +02:00
|
|
|
* Make sure $SHELL points to the shell from the password file,
|
|
|
|
* even if shell is overridden from login.conf
|
|
|
|
*/
|
|
|
|
- env = do_setup_env(ssh, s, shell);
|
|
|
|
+ env = do_setup_env(ssh, s, shell, &env_size);
|
|
|
|
|
|
|
|
#ifdef HAVE_LOGIN_CAP
|
|
|
|
shell = login_getcapstr(lc, "shell", (char *)shell, (char *)shell);
|
2021-01-18 02:12:55 +01:00
|
|
|
@@ -1646,7 +1657,7 @@ do_child(struct ssh *ssh, Session *s, co
|
2018-10-17 10:57:56 +02:00
|
|
|
|
|
|
|
closefrom(STDERR_FILENO + 1);
|
|
|
|
|
|
|
|
- do_rc_files(ssh, s, shell);
|
|
|
|
+ do_rc_files(ssh, s, shell, env, &env_size);
|
|
|
|
|
|
|
|
/* restore SIGPIPE for child */
|
2020-06-06 08:49:00 +02:00
|
|
|
ssh_signal(SIGPIPE, SIG_DFL);
|