-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openssh: try resolving issues when starting sshd with root
- Loading branch information
Showing
5 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
diff -uNr openssh-portable-V_9_5_P1/auth.c openssh-portable-V_9_5_P1.mod/auth.c | ||
--- openssh-portable-V_9_5_P1/auth.c 2023-10-04 07:34:10.000000000 +0300 | ||
+++ openssh-portable-V_9_5_P1.mod/auth.c 2023-11-23 16:29:34.257875879 +0200 | ||
@@ -485,7 +485,13 @@ | ||
@@ -484,7 +484,20 @@ | ||
aix_setauthdb(user); | ||
#endif | ||
|
||
+#ifdef __ANDROID__ | ||
+ /* Effectively a single-user system, use current user no matter supplied user */ | ||
+ pw = getpwuid(getuid()); | ||
+ int uid = getuid(); | ||
+ if (__predict_false(uid == 0)) { | ||
+ /* If sshd is started as root user, get uid from the owner of TERMUX_PREFIX */ | ||
+ struct stat st; | ||
+ if (stat("@TERMUX_PREFIX@", &st) != -1) { | ||
+ uid = st.st_uid; | ||
+ } | ||
+ } | ||
+ /* Effectively a single-user system, use current user no matter supplied user */ | ||
+ pw = getpwuid(uid); | ||
+#else | ||
pw = getpwnam(user); | ||
+#endif | ||
+ | ||
|
||
#if defined(_AIX) && defined(HAVE_SETAUTHDB) | ||
aix_restoreauthdb(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
https://github.com/termux/termux-packages/issues/20774 | ||
|
||
--- a/sshd-session.c | ||
+++ b/sshd-session.c | ||
@@ -1074,7 +1074,18 @@ | ||
|
||
/* Store privilege separation user for later use if required. */ | ||
privsep_chroot = (getuid() == 0 || geteuid() == 0); | ||
+#ifdef __ANDROID__ | ||
+ /* Let the privilege separation user be Termux on Android */ | ||
+ do { | ||
+ struct stat st; | ||
+ if (stat("@TERMUX_PREFIX@", &st) != -1) { | ||
+ privsep_pw = getpwuid(st.st_uid); | ||
+ } | ||
+ } while (0); | ||
+ if (privsep_pw == NULL) { | ||
+#else | ||
if ((privsep_pw = getpwnam(SSH_PRIVSEP_USER)) == NULL) { | ||
+#endif | ||
if (privsep_chroot || options.kerberos_authentication) | ||
fatal("Privilege separation user %s does not exist", | ||
SSH_PRIVSEP_USER); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters