2019-09-06 00:43:47 +02:00
|
|
|
diff -uNr openssh-8.0p1/session.c openssh-8.0p1.mod/session.c
|
|
|
|
--- openssh-8.0p1/session.c 2019-04-18 01:52:57.000000000 +0300
|
|
|
|
+++ openssh-8.0p1.mod/session.c 2019-09-06 01:41:30.581023746 +0300
|
2019-04-18 09:02:44 +02:00
|
|
|
@@ -197,7 +197,7 @@
|
2015-06-13 01:03:31 +02:00
|
|
|
temporarily_use_uid(pw);
|
2019-04-18 09:02:44 +02:00
|
|
|
|
2015-06-13 01:03:31 +02:00
|
|
|
/* Allocate a buffer for the socket name, and format the name. */
|
|
|
|
- auth_sock_dir = xstrdup("/tmp/ssh-XXXXXXXXXX");
|
|
|
|
+ auth_sock_dir = xstrdup("@TERMUX_PREFIX@/tmp/ssh-XXXXXXXXXX");
|
2019-04-18 09:02:44 +02:00
|
|
|
|
2015-06-13 01:03:31 +02:00
|
|
|
/* Create private directory for socket */
|
|
|
|
if (mkdtemp(auth_sock_dir) == NULL) {
|
2019-04-18 09:02:44 +02:00
|
|
|
@@ -267,7 +267,7 @@
|
2019-03-02 13:52:55 +01:00
|
|
|
return;
|
2019-04-18 09:02:44 +02:00
|
|
|
|
2019-03-02 13:52:55 +01:00
|
|
|
temporarily_use_uid(pw);
|
|
|
|
- auth_info_file = xstrdup("/tmp/sshauth.XXXXXXXXXXXXXXX");
|
|
|
|
+ auth_info_file = xstrdup("@TERMUX_PREFIX@/tmp/sshauth.XXXXXXXXXXXXXXX");
|
|
|
|
if ((fd = mkstemp(auth_info_file)) == -1) {
|
|
|
|
error("%s: mkstemp: %s", __func__, strerror(errno));
|
|
|
|
goto out;
|
2019-09-06 00:43:47 +02:00
|
|
|
@@ -799,6 +799,11 @@
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
if (options.print_motd) {
|
|
|
|
+#ifdef __ANDROID__
|
|
|
|
+ // Normally this environment variable should be already unset, but
|
|
|
|
+ // doing this anyway.
|
|
|
|
+ unsetenv("TERMUX_HUSHLOGIN");
|
|
|
|
+#else
|
|
|
|
#ifdef HAVE_LOGIN_CAP
|
2015-06-13 01:03:31 +02:00
|
|
|
f = fopen(login_getcapstr(lc, "welcome", "/etc/motd",
|
|
|
|
"/etc/motd"), "r");
|
2019-09-06 00:43:47 +02:00
|
|
|
@@ -810,7 +815,14 @@
|
|
|
|
fputs(buf, stdout);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
+#ifdef __ANDROID__
|
|
|
|
+ else {
|
|
|
|
+ // Tell Termux login script not to display motd.
|
|
|
|
+ setenv("TERMUX_HUSHLOGIN", "1", 1);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1052,11 +1064,13 @@
|
2017-06-30 22:55:31 +02:00
|
|
|
# endif /* HAVE_CYGWIN */
|
|
|
|
#endif /* HAVE_LOGIN_CAP */
|
2019-04-18 09:02:44 +02:00
|
|
|
|
2017-06-30 22:55:31 +02:00
|
|
|
+#ifdef _PATH_MAILDIR
|
2019-04-18 09:02:44 +02:00
|
|
|
if (!options.use_pam) {
|
|
|
|
snprintf(buf, sizeof buf, "%.200s/%.50s",
|
|
|
|
_PATH_MAILDIR, pw->pw_name);
|
|
|
|
child_set_env(&env, &envsize, "MAIL", buf);
|
|
|
|
}
|
2017-06-30 22:55:31 +02:00
|
|
|
+#endif
|
2019-04-18 09:02:44 +02:00
|
|
|
|
2017-06-30 22:55:31 +02:00
|
|
|
/* Normal systems set SHELL by default. */
|
|
|
|
child_set_env(&env, &envsize, "SHELL", shell);
|
2019-09-06 00:43:47 +02:00
|
|
|
@@ -1100,6 +1114,15 @@
|
2019-03-02 13:52:55 +01:00
|
|
|
auth_sock_name);
|
2019-04-18 09:02:44 +02:00
|
|
|
|
|
|
|
|
2015-06-13 01:03:31 +02:00
|
|
|
+#ifdef __ANDROID__
|
2020-03-08 19:53:27 +01:00
|
|
|
+ char const* envs_to_keep[] = {"ANDROID_DATA", "ANDROID_ROOT", "ANDROID_RUNTIME_ROOT", "ANDROID_TZDATA_ROOT", "BOOTCLASSPATH", "EXTERNAL_STORAGE", "LANG", "LD_LIBRARY_PATH", "PATH", "PREFIX", "TERMUX_HUSHLOGIN", "TMPDIR"};
|
2016-06-26 23:56:11 +02:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2015-06-13 01:03:31 +02:00
|
|
|
+#endif
|
2016-06-26 23:56:11 +02:00
|
|
|
+
|
2018-04-04 00:09:47 +02:00
|
|
|
/* Set custom environment options from pubkey authentication. */
|
|
|
|
if (options.permit_user_env) {
|
|
|
|
for (n = 0 ; n < auth_opts->nenv; n++) {
|