mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Change working directory before calling pcapd under su.
Some implementation of Android su will reset environment variables, so the current working directory will not be preserved. To make sure the creation of pid file and log file, change working directory manually.
This commit is contained in:
parent
dc3bb39168
commit
9be48af56b
@ -240,6 +240,13 @@ int start_subprocess(const char *prog, const char *args, bool as_root, int* out_
|
||||
close(in_p[0]);
|
||||
|
||||
// write "su" command input
|
||||
if(as_root) {
|
||||
char* cwd = getcwd(NULL, 0);
|
||||
log_d("start_subprocess[%d]: cd %s", pid, cwd);
|
||||
write(in_p[1], "cd ",3);
|
||||
write(in_p[1], cwd, strlen(cwd));
|
||||
write(in_p[1], "\n", 1);
|
||||
}
|
||||
log_d("start_subprocess[%d]: %s %s", pid, prog, args);
|
||||
write(in_p[1], prog, strlen(prog));
|
||||
write(in_p[1], " ", 1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user