Files
termux-packages/packages/openssh/sshd.c.patch
2024-07-09 13:39:56 +00:00

87 lines
2.4 KiB
Diff

diff -uNr openssh-portable-V_9_8_P1/sshd.c openssh-portable-V_9_8_P1.mod/sshd.c
--- openssh-portable-V_9_8_P1/sshd.c 2024-07-01 12:36:28.000000000 +0800
+++ openssh-portable-V_9_8_P1.mod/sshd.c 2024-07-01 18:02:23.167637504 +0800
@@ -1208,7 +1208,8 @@
saved_argc = ac;
rexec_argc = ac;
saved_argv = xcalloc(ac + 1, sizeof(*saved_argv));
- for (i = 0; (int)i < ac; i++)
+ saved_argv[0] = xstrdup("@TERMUX_PREFIX@/bin/sshd");
+ for (i = 1; (int)i < ac; i++)
saved_argv[i] = xstrdup(av[i]);
saved_argv[i] = NULL;
@@ -1217,10 +1217,10 @@
compat_init_setproctitle(ac, av);
av = saved_argv;
#endif
-
+#ifndef __ANDROID__
if (geteuid() == 0 && setgroups(0, NULL) == -1)
debug("setgroups(): %.200s", strerror(errno));
-
+#endif
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd();
@@ -1341,9 +1341,10 @@
break;
}
}
+#ifndef __ANDROID__
if (!test_flag && !do_dump_cfg && !path_absolute(av[0]))
fatal("sshd requires execution with an absolute path");
-
+#endif
closefrom(STDERR_FILENO + 1);
/* Reserve fds we'll need later for reexec things */
@@ -1602,12 +1602,13 @@
/* Ensure privsep directory is correctly configured. */
need_chroot = ((getuid() == 0 || geteuid() == 0) ||
options.kerberos_authentication);
+#ifndef __ANDROID__
if ((getpwnam(SSH_PRIVSEP_USER)) == NULL && need_chroot) {
fatal("Privilege separation user %s does not exist",
SSH_PRIVSEP_USER);
}
endpwent();
-
+#endif
if (need_chroot) {
if ((stat(_PATH_PRIVSEP_CHROOT_DIR, &sb) == -1) ||
(S_ISDIR(sb.st_mode) == 0))
@@ -1638,9 +1640,10 @@
* to create a file, and we can't control the code in every
* module which might be used).
*/
+#ifndef __ANDROID__
if (setgroups(0, NULL) < 0)
debug("setgroups() failed: %.200s", strerror(errno));
-
+#endif
/* Prepare arguments for sshd-session */
if (rexec_argc < 0)
fatal("rexec_argc %d < 0", rexec_argc);
@@ -1679,7 +1682,7 @@
already_daemon = daemonized();
if (!(debug_flag || inetd_flag || no_daemon_flag || already_daemon)) {
- if (daemon(0, 0) == -1)
+ if (daemon(1, 0) == -1)
fatal("daemon() failed: %.200s", strerror(errno));
disconnect_controlling_tty();
@@ -1691,9 +1694,10 @@
* Chdir to the root directory so that the current disk can be
* unmounted if desired.
*/
+#ifndef __ANDROID__
if (chdir("/") == -1)
error("chdir(\"/\"): %s", strerror(errno));
-
+#endif
/* ignore SIGPIPE */
ssh_signal(SIGPIPE, SIG_IGN);