Open Source - Automatically setting /dev/dahdi file permissions when running Asterisk as non-root user
When running Asterisk as a non-root user, it is necessary for the contents of /dev/dahdi to be accessible by that same user. If they are owned by the root user, for example, then Asterisk will not be able to read those files when the chan_dahdi.so module is loaded and it will cause that module load attempt to fail.
A quick fix for this is to use the chown utility to change the owner to the Asterisk user. For example, assuming the name of the user is "asterisk", you would run the following command from the Linux shell:
chown -R asterisk:asterisk /dev/dahdi
However, to ensure that this does not happen in the future when the init scripts are run and the channel files are generated, you will need to do the following:
Use a text editor to open the file: /etc/udev/rules.d/dahdi.rules
On the line beginning with SUBSYSTEM, change the OWNER and GROUP values to match the user and group that Asterisk is being run under
For example, if you're running Asterisk as asteriskpbx and the group that it belongs to is also asteriskpbx, then you would want to change those values to asteriskpbx as well
Save the modified dahdi_rules file
Reboot the server when appropriate for this change to take effect
Now when DAHDI and Asterisk are started next time, the files in /dev/dahdi should be owned by the correct user.