Skip to content

Commit bb6322c

Browse files
committed
patches: Fix compilation error due to unused result.
PHREAKSCRIPT-68 #close
1 parent 2fc5d63 commit bb6322c

3 files changed

+56
-81
lines changed

patches/19655-asterisk.c-Prevent-duplicate-Asterisk-processes-fro.patch

-80
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff --git a/main/asterisk.c b/main/asterisk.c
2+
index b0f8a14311..ee89c45ad9 100644
3+
--- a/main/asterisk.c
4+
+++ b/main/asterisk.c
5+
@@ -1709,6 +1709,37 @@ static int ast_tryconnect(void)
6+
return 1;
7+
}
8+
9+
+static int ast_is_starting(void)
10+
+{
11+
+ /* Don't use kill since that only works if Asterisk was started as the same user. */
12+
+ struct stat st;
13+
+ FILE *f;
14+
+ long file_pid;
15+
+ char procpath[PATH_MAX];
16+
+
17+
+ /* Get current value from PID file */
18+
+ f = fopen(ast_config_AST_PID, "r");
19+
+ if (!f) {
20+
+ return 0; /* PID file doesn't exist? No way to tell. */
21+
+ }
22+
+ if (fscanf(f, "%ld", &file_pid) < 1) {
23+
+ file_pid = 0; /* Failure */
24+
+ }
25+
+ fclose(f);
26+
+ if (!file_pid) {
27+
+ return 0;
28+
+ }
29+
+
30+
+ /* Check if such a process is running */
31+
+ snprintf(procpath, sizeof(procpath), "/proc/%ld", file_pid);
32+
+ if (stat(procpath, &st) == -1 && errno == ENOENT) {
33+
+ /* Process doesn't exist */
34+
+ return 0;
35+
+ }
36+
+ return 1;
37+
+}
38+
+
39+
+
40+
/*! \brief Urgent handler
41+
*
42+
* Called by soft_hangup to interrupt the poll, read, or other
43+
@@ -4080,6 +4111,12 @@ int main(int argc, char *argv[])
44+
exit(1);
45+
}
46+
47+
+ if (ast_is_starting()) {
48+
+ fprintf(stderr, "Asterisk is currently starting. Use 'asterisk -r' to connect momentarily.\n");
49+
+ printf("%s", term_quit());
50+
+ exit(1);
51+
+ }
52+
+
53+
#ifdef HAVE_CAP
54+
child_cap = cap_from_text("cap_net_admin-eip");
55+
#endif

phreaknet.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,7 @@ phreak_patches() { # $1 = $PATCH_DIR, $2 = $AST_SRC_DIR
25362536
git_patch "blueboxing.diff" # dsp: make blue boxing easier
25372537
git_patch "prefixinclude.diff" # pbx: prefix includes
25382538
git_patch "agi_record_noisefirst.diff" # res_agi: Add noise before silence detection option to Record AGI
2539-
git_patch "19655-asterisk.c-Prevent-duplicate-Asterisk-processes-fro.patch" # Prevent duplicate Asterisk process creation
2539+
git_patch "asterisk-prevent-duplicate-processes.diff" # Prevent duplicate Asterisk process creation
25402540

25412541
if [ "$EXPERIMENTAL_FEATURES" = "1" ] && [ $AST_MAJOR_VER -ge 21 ]; then
25422542
printf "Installing 21+ patches for experimental features\n"

0 commit comments

Comments
 (0)