close all the android system fds when starting the dropbear server

sigsegv_dump
Greg Alexander 10 years ago
parent 90e7ca14ae
commit 253c468b3a

@ -135,6 +135,7 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
const char *logfn;
int logfd;
int retval;
int i;
logfn = conf_path_file("dropbear.err");
unlink(logfn);
@ -143,6 +144,11 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
/* replace stderr, so the output is preserved... */
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++] = "-F"; /* don't redundant fork to background */

Loading…
Cancel
Save