The previous patched session.c just took the existing environment
and kept it. The new copies over a few specific variables needed
but otherwise does the normal setup.
Fixes #341 (TERM being ignored).
Fixes #290 (SSH_CONNECTION/SSH_CLIENT/SSH_TTY not setup).
Fixes https://github.com/termux/termux-app/issues/108 (SSH agent
forwarding not working).
TERMUX_PKG_HOMEPAGE=http://www.openssh.com/
TERMUX_PKG_DESCRIPTION="Secure shell for logging into a remote machine"
TERMUX_PKG_VERSION=7.2p2
TERMUX_PKG_HOMEPAGE=http://www.openssh.com/
TERMUX_PKG_DESCRIPTION="Secure shell for logging into a remote machine"
TERMUX_PKG_VERSION=7.2p2
-TERMUX_PKG_BUILD_REVISION=4
+TERMUX_PKG_BUILD_REVISION=5
TERMUX_PKG_SRCURL=http://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_DEPENDS="libandroid-support, ldns, openssl"
# --disable-strip to prevent host "install" command to use "-s", which won't work for target binaries:
TERMUX_PKG_SRCURL=http://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_DEPENDS="libandroid-support, ldns, openssl"
# --disable-strip to prevent host "install" command to use "-s", which won't work for target binaries:
---- ../openssh-6.4p1/session.c 2013-07-20 05:21:53.000000000 +0200
-+++ ./session.c 2014-02-07 00:37:57.000000000 +0100
-@@ -193,7 +193,7 @@
+diff -u -r ../openssh-7.2p2/session.c ./session.c
+--- ../openssh-7.2p2/session.c 2016-03-09 13:04:48.000000000 -0500
++++ ./session.c 2016-06-26 17:17:15.988592104 -0400
+@@ -196,7 +196,7 @@
temporarily_use_uid(pw);
/* Allocate a buffer for the socket name, and format the name. */
temporarily_use_uid(pw);
/* Allocate a buffer for the socket name, and format the name. */
/* Create private directory for socket */
if (mkdtemp(auth_sock_dir) == NULL) {
/* Create private directory for socket */
if (mkdtemp(auth_sock_dir) == NULL) {
f = fopen(login_getcapstr(lc, "welcome", "/etc/motd",
"/etc/motd"), "r");
#else
f = fopen(login_getcapstr(lc, "welcome", "/etc/motd",
"/etc/motd"), "r");
#else
#endif
if (f) {
while (fgets(buf, sizeof(buf), f))
#endif
if (f) {
while (fgets(buf, sizeof(buf), f))
-@@ -1125,6 +1125,9 @@
- static char **
- do_setup_env(Session *s, const char *shell)
- {
+@@ -1242,6 +1242,15 @@
+ if (getenv("TZ"))
+ child_set_env(&env, &envsize, "TZ", getenv("TZ"));
+
-+ return environ;
-+#else
- char buf[256];
- u_int i, envsize;
- char **env, *laddr;
-@@ -1311,6 +1314,7 @@
- fprintf(stderr, " %.200s\n", env[i]);
- }
- return env;
++ char const* envs_to_keep[] = {"LD_LIBRARY_PATH", "PATH", "ANDROID_ROOT", "ANDROID_DATA", "EXTERNAL_STORAGE"};
++ for (i = 0; i < (sizeof(envs_to_keep) / sizeof(envs_to_keep[0])); i++) {
++ char const* env_to_keep_name = envs_to_keep[i];
++ char const* env_to_keep_value = getenv(env_to_keep_name);
++ if (env_to_keep_value) child_set_env(&env, &envsize, env_to_keep_name, env_to_keep_value);
++ }
- }
-
- /*
-@@ -1614,7 +1618,9 @@
++
+ /* Set custom environment options from RSA authentication. */
+ if (!options.use_login) {
+ while (custom_environment) {
+@@ -1664,7 +1673,9 @@
* Close any extra file descriptors. Note that there may still be
* descriptors left by system functions. They will be closed later.
*/
* Close any extra file descriptors. Note that there may still be
* descriptors left by system functions. They will be closed later.
*/