mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
app.c: make sure that no non-async-signal-safe syscalls are used after
fork before exec Posix does only allow async-signal-safe syscalls after fork before exec. As asterisk ignores this, functions like TrySystem or System sometimes end up in a deadlocked child process. The patch prevents the use of non-async-signal-safe syscalls. ASTERISK-28776 Change-Id: Idc76365c0592ee3f3b3bd72a4f48f7a098978e8e
This commit is contained in:
committed by
George Joseph
parent
7fbfbe7da0
commit
6b2d945174
@@ -388,6 +388,10 @@ static int multi_thread_safe;
|
||||
|
||||
static char randompool[256];
|
||||
|
||||
#ifdef HAVE_CAP
|
||||
static cap_t child_cap;
|
||||
#endif
|
||||
|
||||
static int sig_alert_pipe[2] = { -1, -1 };
|
||||
static struct {
|
||||
unsigned int need_reload:1;
|
||||
@@ -1099,13 +1103,7 @@ static pid_t safe_exec_prep(int dualfork)
|
||||
|
||||
if (pid == 0) {
|
||||
#ifdef HAVE_CAP
|
||||
cap_t cap = cap_from_text("cap_net_admin-eip");
|
||||
|
||||
if (cap_set_proc(cap)) {
|
||||
/* Careful with order! Logging cannot happen after we close FDs */
|
||||
ast_log(LOG_WARNING, "Unable to remove capabilities.\n");
|
||||
}
|
||||
cap_free(cap);
|
||||
cap_set_proc(child_cap);
|
||||
#endif
|
||||
#ifdef HAVE_WORKING_FORK
|
||||
if (ast_opt_high_priority) {
|
||||
@@ -1804,10 +1802,8 @@ int ast_set_priority(int pri)
|
||||
if (pri) {
|
||||
sched.sched_priority = 10;
|
||||
if (sched_setscheduler(0, SCHED_RR, &sched)) {
|
||||
ast_log(LOG_WARNING, "Unable to set high priority\n");
|
||||
return -1;
|
||||
} else
|
||||
ast_verb(1, "Set to realtime thread\n");
|
||||
}
|
||||
} else {
|
||||
sched.sched_priority = 0;
|
||||
/* According to the manpage, these parameters can never fail. */
|
||||
@@ -3920,8 +3916,14 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CAP
|
||||
child_cap = cap_from_text("cap_net_admin-eip");
|
||||
#endif
|
||||
/* Not a remote console? Start the daemon. */
|
||||
asterisk_daemon(isroot, runuser, rungroup);
|
||||
#ifdef HAS_CAP
|
||||
cap_free(child_cap);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user