File chan-dongle-fix-locking.diff of Package asterisk-chan-dongle
Index: b/chan_dongle.c
===================================================================
--- a/chan_dongle.c
+++ b/chan_dongle.c
@@ -51,6 +51,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+ */
@@ -122,7 +125,7 @@ static int lock_build(const char * devna
#if defined(__FreeBSD__)
return snprintf(buf, length, "/var/spool/lock/LCK..%s", basename);
#else
- return snprintf(buf, length, "/var/lock/LCK..%s", basename);
+ return snprintf(buf, length, "/run/lock/LCK..%s", basename);
#endif
}
@@ -133,7 +136,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 */
@@ -518,7 +523,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_enqueue_ping(&pvt->sys_chan);