Skip to content

Commit 652b2a5

Browse files
committed
fix: Android use /system/bin/sh not /bin/sh
/bin/sh isn't always exists in android system, but /system/bin/sh is. After fix this, wifidog can build by NDK and run with some small warnnings.
1 parent 437e7a0 commit 652b2a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/util.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
debug(LOG_DEBUG, "wd_gethostbyname() unlocked"); \
7373
} while (0)
7474

75+
#include "../config.h"
76+
#ifdef __ANDROID__
77+
#define WD_SHELL_PATH "/system/bin/sh"
78+
#else
79+
#define WD_SHELL_PATH "/bin/sh"
80+
#endif
81+
7582
/** @brief FD for icmp raw socket */
7683
static int icmp_fd;
7784

@@ -91,7 +98,7 @@ execute(const char *cmd_line, int quiet)
9198
int pid, status, rc;
9299

93100
const char *new_argv[4];
94-
new_argv[0] = "/bin/sh";
101+
new_argv[0] = WD_SHELL_PATH;
95102
new_argv[1] = "-c";
96103
new_argv[2] = cmd_line;
97104
new_argv[3] = NULL;
@@ -101,7 +108,7 @@ execute(const char *cmd_line, int quiet)
101108
/* We don't want to see any errors if quiet flag is on */
102109
if (quiet)
103110
close(2);
104-
if (execvp("/bin/sh", (char *const *)new_argv) == -1) { /* execute the command */
111+
if (execvp(WD_SHELL_PATH, (char *const *)new_argv) == -1) { /* execute the command */
105112
debug(LOG_ERR, "execvp(): %s", strerror(errno));
106113
} else {
107114
debug(LOG_ERR, "execvp() failed");

0 commit comments

Comments
 (0)