File chan-dongle-fix-locking.diff of Package asterisk-chan-dongle
Index: b/chan_dongle.c
===================================================================
--- a/chan_dongle.c
+++ b/chan_dongle.c
@@ -50,6 +50,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Rev: "
#include <fcntl.h> /* O_RDWR O_NOCTTY */
#include <signal.h> /* SIGURG */
+#include <unistd.h>
+#include <sys/types.h>
+
#include "ast_compat.h" /* asterisk compatibility fixes */
#if ASTERISK_VERSION_NUM >= 130000 /* 13+ */
@@ -126,7 +129,9 @@ static int lock_create(const char * lock
int len = 0;
char pidb[21];
- fd = open(lockfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
+ ast_log(LOG_ERROR, "uid: %d, euid: %d\n", getuid(), geteuid());
+
+ fd = open(lockfile, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IRGRP | S_IROTH);
if(fd >= 0)
{
/* NOTE: bg: i assume next open reuse same fd - not thread-safe */
@@ -442,7 +447,7 @@ static void* do_monitor_phone (void* dat
ecmd = at_queue_head_cmd (pvt);
if(ecmd)
{
- ast_log (LOG_ERROR, "[%s] timedout while waiting '%s' in response to '%s'\n", dev, at_res2str (ecmd->res), at_cmd2str (ecmd->cmd));
+ ast_log (LOG_ERROR, "[%s] timed out while waiting '%s' in response to '%s'\n", dev, at_res2str (ecmd->res), at_cmd2str (ecmd->cmd));
goto e_cleanup;
}
at_enque_ping(&pvt->sys_chan);