termux-packages/packages/dropbear/svr-chansession.c.patch

49 lines
1.4 KiB
Diff

diff -uNr dropbear-2018.76/svr-chansession.c dropbear-2018.76.mod/svr-chansession.c
--- dropbear-2018.76/svr-chansession.c 2018-02-27 16:25:12.000000000 +0200
+++ dropbear-2018.76.mod/svr-chansession.c 2018-04-21 13:45:06.707063974 +0300
@@ -607,7 +607,11 @@
dropbear_exit("Out of memory"); /* TODO disconnect */
}
+#ifdef __ANDROID__
+ pw = getpwuid(getuid());
+#else
pw = getpwnam(ses.authstate.pw_name);
+#endif
if (!pw)
dropbear_exit("getpwnam failed after succeeding previously");
pty_setowner(pw, chansess->tty);
@@ -919,6 +923,8 @@
#endif
/* clear environment */
+ /* termux: do not clear environment on android */
+#ifndef __ANDROID__
/* if we're debugging using valgrind etc, we need to keep the LD_PRELOAD
* etc. This is hazardous, so should only be used for debugging. */
#ifndef DEBUG_VALGRIND
@@ -931,6 +937,7 @@
}
#endif /* HAVE_CLEARENV */
#endif /* DEBUG_VALGRIND */
+#endif /* __ANDROID__ */
/* We can only change uid/gid as root ... */
if (getuid() == 0) {
@@ -956,12 +963,14 @@
}
}
+ /* termux: do not modify environment since we did not clean it */
+#ifndef __ANDROID__
/* set env vars */
addnewvar("USER", ses.authstate.pw_name);
addnewvar("LOGNAME", ses.authstate.pw_name);
addnewvar("HOME", ses.authstate.pw_dir);
addnewvar("SHELL", get_user_shell());
- addnewvar("PATH", DEFAULT_PATH);
+#endif /* __ANDROID__ */
if (chansess->term != NULL) {
addnewvar("TERM", chansess->term);
}