[asterisk-users] asterisk at non-root / zaptel

Tzafrir Cohen tzafrir.cohen at xorcom.com
Wed Oct 17 04:47:27 CDT 2007


On Wed, Oct 17, 2007 at 08:43:59AM +0100, Alan Lord wrote:
> Robert McNaught wrote:
> > Alan,
> > 
> > What do you mean by the udev rules?
> > 
> > I previously had asterisk compiled and running as user and group 'asterisk'
> > 
> > zaptel and libpri were compiled and installed using user 'root'
> > 
> > so the zaptel service was root.  I had a dependency issue with asterisk 
> > trying to access a file owned by root for zaptel to work.  How is yours 
> > configured?
> > 
> > Should I be trying to compile and install libpri and zaptel as user 
> > 'asterisk' - I tried this but would not compile as dependency problems 
> > with files being owned as root.  Do you know if there is options in the 
> > make command to put when you compile libpri and zaptel as user 
> > 'asterisk' - maybe that would get round it?
> > 
> > Cheers
> > 
> > Robert
> > 
> 
> Hi Robert,
> 
> most recent Linux systems use an automatic process to create and manage 
> device nodes under /dev. This is called udev.
> 
> In your /etc directory there should be something along the lines of udev 
> or rc.udev or rules.d...
> 
> In my build I have /etc/udev/rules.d/udev_rules_files_in_here
> 
> If you run 'make config' in the zaptel build (after make install) it 
> will install a file called zaptel.rules into the udev hierarchy. It put 
> mine under rules.d
> 
> Here is the contents of zaptel.rules:
> 
> # zaptel devices with ownership/permissions for running as non-root
> KERNEL=="zapctl", NAME="zap/ctl", OWNER="asterisk", GROUP="asterisk", 
> MODE="0660"
> KERNEL=="zaptranscode", NAME="zap/transcode", OWNER="asterisk", 
> GROUP="asterisk", MODE="0660"
> KERNEL=="zaptimer", NAME="zap/timer", OWNER="asterisk", 
> GROUP="asterisk", MODE="0660"
> KERNEL=="zapchannel", NAME="zap/channel", OWNER="asterisk", 
> GROUP="asterisk", MODE="0660"
> KERNEL=="zappseudo", NAME="zap/pseudo", OWNER="asterisk", 
> GROUP="asterisk", MODE="0660"
> KERNEL=="zap[0-9]*", NAME="zap/%n", OWNER="asterisk", GROUP="asterisk", 
> MODE="0660"
> 
> As you should be able to see, this file creates the relevant device 
> nodes with owner and group "asterisk". When Linux boots if zaptel 
> modules get loaded, these devices will be created under /dev.

Actually, even less. 

Debian Etch has:

/etc/udev/rules.d/020_permissions.rules:SUBSYSTEM=="zaptel", GROUP="dialout"
/etc/udev/rules.d/udev.rules:KERNEL=="zapctl",          NAME="zap/ctl"
/etc/udev/rules.d/udev.rules:KERNEL=="zaptimer",        NAME="zap/timer"
/etc/udev/rules.d/udev.rules:KERNEL=="zapchannel",      NAME="zap/channel"
/etc/udev/rules.d/udev.rules:KERNEL=="zappseudo",       NAME="zap/pseudo"
/etc/udev/rules.d/udev.rules:KERNEL=="zap[0-9]*",       NAME="zap/%n"

(transcode is missing??)

The result: files are rw-rw---- (660) owned by root:dialout. Asterisk is
added to the group "dialout"

Centos 5 has:

/etc/udev/rules.d/50-udev.rules:# Section for zaptel device
/etc/udev/rules.d/50-udev.rules:KERNEL=="zapctl",               NAME="zap/ctl"
/etc/udev/rules.d/50-udev.rules:KERNEL=="zaptimer",             NAME="zap/timer"
/etc/udev/rules.d/50-udev.rules:KERNEL=="zapchannel",           NAME="zap/channel"
/etc/udev/rules.d/50-udev.rules:KERNEL=="zappseudo",            NAME="zap/pseudo"
/etc/udev/rules.d/50-udev.rules:KERNEL=="zap[0-9]*",            NAME="zap/%n"

Most recent distributions seem to have those ruels. So basically you
only need to fix:

* Add the rule for /dev/zap/transcode - you only really need this if you
  have a transcoder card (wctc4xxp).

  KERNEL=="zaptranscode", NAME="zap/transcode" # or something similar

  (needs to be fed to distributions)

* Set proper permissions. This is can be a one-liner like the Debian
  one. You can use OWNER= , GROUP= or whatever.


P.S.: the kernel folks seem to consider the classes hirarchy under /sys
a deprecated way of exploring devices, and prefer that those be in
busses . So this part may have to change in some future versions of
Zaptel.

-- 
               Tzafrir Cohen       
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com       
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-users mailing list