1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-12-29 09:28:07 +00:00

close all the android system fds when starting the dropbear server

This commit is contained in:
Greg Alexander 2014-12-20 15:50:46 -05:00
parent 90e7ca14ae
commit 253c468b3a

View File

@ -135,6 +135,7 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
const char *logfn; const char *logfn;
int logfd; int logfd;
int retval; int retval;
int i;
logfn = conf_path_file("dropbear.err"); logfn = conf_path_file("dropbear.err");
unlink(logfn); unlink(logfn);
@ -143,6 +144,11 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
/* replace stderr, so the output is preserved... */ /* replace stderr, so the output is preserved... */
dup2(logfd, 2); dup2(logfd, 2);
} }
for (i = 3; i < 255; i++) {
/* close all of the dozens of fds that android typically
* leaves open */
close(i);
}
argv[argc++] = "-R"; /* enable DROPBEAR_DELAY_HOSTKEY */ argv[argc++] = "-R"; /* enable DROPBEAR_DELAY_HOSTKEY */
argv[argc++] = "-F"; /* don't redundant fork to background */ argv[argc++] = "-F"; /* don't redundant fork to background */