machtudong / asterisk-chan-dongle

Automatically exported from code.google.com/p/asterisk-chan-dongle
Other
0 stars 0 forks source link

Lock problem when running asterisk as non-root #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When running asterisk not as a superuser and using IMEI/IMSI discovery on 
several devices, the following error continuously occurs:

[Jul  4 03:10:32] ERROR[14181] at_response.c: [dg-2] Received unexpected 'OK'
[Jul  4 03:10:32] ERROR[13935] pdiscovery.c: [dg-1 discovery] failed to get 
valid response from /dev/ttyUSB2 in 500 msec
[Jul  4 03:10:32] ERROR[14182] at_response.c: [dg-3] Received unexpected 'OK'
[Jul  4 03:10:33] ERROR[13935] pdiscovery.c: [dg-1 discovery] failed to get 
valid response from /dev/ttyUSB5 in 500 msec
[Jul  4 03:10:48] ERROR[14181] at_response.c: [dg-2] Received unexpected 'OK'
[Jul  4 03:10:48] ERROR[13935] pdiscovery.c: [dg-1 discovery] failed to get 
valid response from /dev/ttyUSB2 in 500 msec
[Jul  4 03:10:48] ERROR[14182] at_response.c: [dg-3] Received unexpected 'OK'
[Jul  4 03:10:49] ERROR[13935] pdiscovery.c: [dg-1 discovery] failed to get 
valid response from /dev/ttyUSB5 in 500 msec

In my case, I have 3 dongles (dg-[123]), the latter two are connected, the 
first one is being tried to discover.

OS: 3.2.12-gentoo #2 SMP Thu May 31 03:19:21 MSK 2012 x86_64
Asterisk 1.8.12.1, started as /usr/sbin/asterisk -f -g -U asterisk
chan_dongle: Huawei 3G Dongle Channel Driver, Version 1.1, Revision 14

It seems that problem is in locking mechanism, chan_dongle.c:
static int lock_build(const char * devname, char * buf, unsigned length)
{
        (...)
        /* NOTE: use system system wide lock directory */
        return snprintf(buf, length, "/var/lock/LOCK..%s", basename);
}

A workaround is to grant permissions to asterisk for /var/lock, e.g.:
chown :asterisk /var/lock/;
chmod g+w /var/lock/;

But isn't it a better way to make lock path configurable?

Original issue reported on code.google.com by fd...@antar.bryansk.ru on 3 Jul 2012 at 11:34

GoogleCodeExporter commented 9 years ago
set rights permissions for /var/lock 

Original comment by bg_...@mail.ru on 19 Jul 2012 at 10:06

GoogleCodeExporter commented 9 years ago
No, it's a bad idea.
On gentoo, for example, owner and permissions on /var/lock are being reset to 
defaults at every startup.

Original comment by fd...@antar.bryansk.ru on 19 Jul 2012 at 6:35