mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 00:51:19 +00:00
Fix the static build by dynamically resolving libutil symbols ##build
This commit is contained in:
parent
52b1affcb6
commit
498292a70d
@ -58,6 +58,12 @@
|
||||
|
||||
#define HAVE_PTY __UNIX__ && !__ANDROID__ && LIBC_HAVE_FORK && !__sun
|
||||
|
||||
#if HAVE_PTY
|
||||
static int (*dyn_openpty)(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp) = NULL;
|
||||
static int (*dyn_login_tty)(int fd) = NULL;
|
||||
static id_t (*dyn_forkpty)(int *amaster, char *name, struct termios *termp, struct winsize *winp) = NULL;
|
||||
#endif
|
||||
|
||||
#if EMSCRIPTEN
|
||||
#undef HAVE_PTY
|
||||
#define HAVE_PTY 0
|
||||
@ -278,6 +284,10 @@ static void restore_saved_fd(int saved, bool restore, int fd) {
|
||||
|
||||
static int handle_redirection_proc(const char *cmd, bool in, bool out, bool err) {
|
||||
#if HAVE_PTY
|
||||
if (!dyn_forkpty) {
|
||||
// No forkpty api found, maybe we should fallback to just fork without any pty allocated
|
||||
return -1;
|
||||
}
|
||||
// use PTY to redirect I/O because pipes can be problematic in
|
||||
// case of interactive programs.
|
||||
int saved_stdin = dup (STDIN_FILENO);
|
||||
@ -285,11 +295,12 @@ static int handle_redirection_proc(const char *cmd, bool in, bool out, bool err)
|
||||
return -1;
|
||||
}
|
||||
int saved_stdout = dup (STDOUT_FILENO);
|
||||
if (saved_stdout== -1) {
|
||||
if (saved_stdout == -1) {
|
||||
close (saved_stdin);
|
||||
return -1;
|
||||
}
|
||||
int fdm, pid = forkpty (&fdm, NULL, NULL, NULL);
|
||||
|
||||
int fdm, pid = dyn_forkpty (&fdm, NULL, NULL, NULL);
|
||||
if (pid == -1) {
|
||||
close (saved_stdin);
|
||||
close (saved_stdout);
|
||||
@ -357,7 +368,7 @@ static int handle_redirection_proc(const char *cmd, bool in, bool out, bool err)
|
||||
}
|
||||
|
||||
static int handle_redirection(const char *cmd, bool in, bool out, bool err) {
|
||||
if (!cmd || cmd[0] == '\0') {
|
||||
if (!cmd || !*cmd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -686,7 +697,7 @@ static int redirect_socket_to_pty(RSocket *sock) {
|
||||
// in case of interactive applications
|
||||
int fdm, fds;
|
||||
|
||||
if (openpty (&fdm, &fds, NULL, NULL, NULL) == -1) {
|
||||
if (dyn_openpty && dyn_openpty (&fdm, &fds, NULL, NULL, NULL) == -1) {
|
||||
perror ("opening pty");
|
||||
return -1;
|
||||
}
|
||||
@ -740,7 +751,9 @@ static int redirect_socket_to_pty(RSocket *sock) {
|
||||
|
||||
// parent
|
||||
r_socket_close_fd (sock);
|
||||
login_tty (fds);
|
||||
if (dyn_login_tty) {
|
||||
dyn_login_tty (fds);
|
||||
}
|
||||
close (fdm);
|
||||
|
||||
// disable the echo on slave stdin
|
||||
@ -756,9 +769,28 @@ static int redirect_socket_to_pty(RSocket *sock) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if HAVE_PTY
|
||||
|
||||
static void dyn_init(void) {
|
||||
if (!dyn_openpty) {
|
||||
dyn_openpty = r_lib_dl_sym (NULL, "openpty");
|
||||
}
|
||||
if (!dyn_login_tty) {
|
||||
dyn_openpty = r_lib_dl_sym (NULL, "login_tty");
|
||||
}
|
||||
if (!dyn_forkpty) {
|
||||
dyn_openpty = r_lib_dl_sym (NULL, "forkpty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_run_config_env(RRunProfile *p) {
|
||||
int ret;
|
||||
|
||||
dyn_init ();
|
||||
|
||||
if (!p->_program && !p->_system && !p->_runlib) {
|
||||
printf ("No program, system or runlib rule defined\n");
|
||||
return 1;
|
||||
|
@ -42,7 +42,7 @@ if [ 1 = "${DOCFG}" ]; then
|
||||
./configure --prefix="$PREFIX" --without-gpl --with-libr --without-libuv || exit 1
|
||||
fi
|
||||
${MAKE} -j 8 || exit 1
|
||||
BINS="rarun2 rasm2 radare2 ragg2 rabin2 rax2 rahash2 rafind2 r2agent radiff2"
|
||||
BINS="rarun2 rasm2 radare2 ragg2 rabin2 rax2 rahash2 rafind2 r2agent radiff2 r2r"
|
||||
# shellcheck disable=SC2086
|
||||
for a in ${BINS} ; do
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user