Failed to copy from module agi-bin - retrieve.conf problem

I’ve read all the forum’s topics about this issue but I still have it.
all permission are ok but I get this error any time I save and reload from amportal:

Retrieve conf failed to copy file(s) from a module’s agi-bin dir: copy(/var/lib/asterisk/agi-bin/checksound.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/directory): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/recordingcheck): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/fixlocalprefix): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/list-item-remove.php): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/enumlookup.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/dialparties.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/user_login_out.agi): failed to open stream: Permission denied

Added ago
(retrieve_conf.CPAGIBIN)

if I run from linux the retrieve.conf I got:
Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Checking for /etc/amportal.conf …OK
Bootstrapping /etc/amportal.conf …OK
Parsing /etc/amportal.conf …OK
Parsing /etc/asterisk/asterisk.conf …OK
Connecting to database…OK
Connecting to Asterisk manager interface…OK
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk
Added to globals: CWINUSEBUSY = true
Added to globals: AMPMGRUSER = admin
Added to globals: AMPMGRPASS = mypsw
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
Use of uninitialized value in string eq at /var/lib/asterisk/bin/retrieve_op_conf_from_mysql.pl line 415.
Please update your modules and reload Asterisk by browsing to your server.

any solution? Everything is up to date and installed

setup info please? versions, distro/hand build, directions used, deviations from directions, etc…

You have several issues here. It looks like it’s a hand build with things not setup correctly from what little you’ve provided.

The errors copy(/var/lib/asterisk/agi-bin/directory): failed to open stream: Permission denied
Mean exactly that. Either it does not have permission to read the file or write it. It could be because you have installed stuff in a nonstandard directory someplace and not informed the system of that in the config files, a install has gone bad, etc.

without those details it’s hard to be sure. You might have had a error on install that you didn’t notice or did, but things seemed to work so didn’t go back and really address and fix that is now getting even with you.

it’s a permission issue, probably because of running apache as something other than asterisk and not having cross group permissions properly set. When you run it from the command line, you are probably a different user. If you “su - ‘your_apache_user’” you will get the same error.

asterisk version 1.4
freepbx 2.5

I got the user asterisk in the apache group and the user apache in the asterisk group. Everything is ok and all works well but every time I apply and reload I got this error.
It’s not a permission problem I put that file even in 0777 but still the same issue.

Alek, it’s a permission problem. Take it from the Project Leader he knows what he is talking about.

The files are being copied from one location (you don’t have permission to read the file, i.e. failed to open stream: Permission denied). There are several locations that files are stored and re-copied when changes are applied.

So you think you solves all the problems but you have not.

Again I’ll ask which hand build directions used, deviations from directions, etc. Most important is the where did you deviate from them and why. As you might think you covered for it but you have not.

When we get the info maybe we can help correct the issue properly.

OK tell me what do you need to know then.
I got only 2 retrieve_conf files in all my dedicated server:
/var/lib/asterisk/bin/retrieve_conf
/var/www/html/pbx/admin/modules/framework/bin/retrieve_conf

both have permission 0775 to asterisk user and asterisk group
As I said asterisk user is inside apache group and apache user is inside asterisk group.

I coudln’t change apache user to asterisk because I’m running the freepbx on a dedicated webserver.
All the rest works well but I got this error message.
Other info PHP Version 5.1.6

tnx 4 the help

Ok it’s all in the details which you still refuse to provide…

So what OS, who’s directions did you follow and how did you deviate from them. I see one thing as you installed it at /var/www/html/pbx instead of the default /var/www/html. it’s all in the details and without them it’s REAL hard to help, share what you have done and why and then you get free help (yes we do this for free and because we like to, not because we have to).

So when we ask for something we expect cooperation back so that we can help.

How did you install it in this alternate directory. it’s important as to how it was done.

And as I stated before it might look like it’s working but with the error that it can’t copy files other things probably/might not be working correctly as the proper files are not being copied to the proper locations.

It’s difficoult to explain all that I’ve done to install.
Ok let’s try.

Yes I’ve changed the folder from www/html/ to www/html/pbx and obviously I’ve change the amportal this way:

AMPWEBROOT: the path to Apache’s webroot (leave off trailing slash)

AMPWEBROOT=/var/www/html/pbx

The other is default:
SERVERINTITLE=false
AMPDBUSER=asteriskuser
AMPDBPASS=dortyk
AMPDBNAME=asterisk
ASTETCDIR=/etc/asterisk
ASTMODDIR=/usr/lib/asterisk/modules
ASTVARLIBDIR=/var/lib/asterisk
ASTAGIDIR=/var/lib/asterisk/agi-bin
ASTSPOOLDIR=/var/spool/asterisk
ASTRUNDIR=/var/run/asterisk
ASTLOGDIR=/var/log/asterisk

all this folders have permission to user and group asterisk

Operting system is CENTOS 5
I’ve done the normal installation without changing apache user and setting the portal in that folder. That’s all.
Please tell me what more info do you need

tnx

ok so in your case all the files in the /var/www/html/pbx/admin/modules/core/agi-bin/ directory have ownership and group rights of asterisk.asterisk with a setting of 755?

How did you get the files into the new location? By just moving them and editing the file or using the install_amp --webroot command line option? The proper way is via the command line switch.

Have you tried to run the “amportal chown” command to make sure everything that FreePBX knows about has it’s permissions set correctly?

I’ve just moved them but not using the command line switch.

This is the what amportal chown says:
SETTING FILE PERMISSIONS
Permissions OK

Now what does the /var/www/html/pbx/admin/modules/core/agi-bin/ directory have for it’s values?

all subdirectories in /var/www/html/pbx/ have ownership and group rights of asterisk.asterisk with a setting of 775

you mean these when you’re talking about “values”?

yes.
Currently is the asterisk process actually running as the asterisk user or as another user? the safe_asterisk process should be running as root as that spawns the asterisk process with it’s proper user and group permissions.

do
su asterisk
/var/lib/asterisk/bin/retrieve_conf
do you get the same errors still? Probably not
so now type
exit
su apache
/var/lib/asterisk/bin/retrieve_conf
do you get the same errors still? yes I’ll bet, so you have a permissions problem with the user apache and it not having the needed rights to read and copy the files from /var/www/html/pbx/admin/modules/core/agi-bin/ to /var/lib/asterisk/agi-bin

If all the permissions are set correctly and you’ve updated the amportal.conf file properly to point to the proper locations of things that you moved it should then work.

The requirement of it running as the asterisk user is NOT a FreePBX thing but a asterisk issue.

Ok running as asterisk user:

bash-3.1$ /var/lib/asterisk/bin/retrieve_conf

Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Checking for /etc/amportal.conf …OK
Bootstrapping /etc/amportal.conf …OK
Parsing /etc/amportal.conf …OK
Parsing /etc/asterisk/asterisk.conf …OK
Connecting to database…OK
Connecting to Asterisk manager interface…OK
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk
Added to globals: CWINUSEBUSY = true
Added to globals: AMPMGRUSER = admin
Added to globals: AMPMGRPASS = xxxxx
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: array_keys(): The first argument should be an array in /var/www/html/pbx/admin/extensions.class.php on line 226
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/pbx/admin/extensions.class.php on line 226
Use of uninitialized value in string eq at /var/lib/asterisk/bin/retrieve_op_conf_from_mysql.pl line 415.
touch: cannot touch Conferences': Permission denied touch: cannot touchdefined’: Permission denied
[ERROR] Error code 1: trying to create empty file /etc/asterisk/no Conferences defined
touch: cannot touch Parkings': Permission denied touch: cannot touchdefined’: Permission denied
[ERROR] Error code 1: trying to create empty file /etc/asterisk/no Parkings defined
touch: cannot touch iax': Permission denied touch: cannot touchtrunks’: Permission denied
touch: cannot touch defined': Permission denied [ERROR] Error code 1: trying to create empty file /etc/asterisk/no iax trunks defined touch: cannot touchAMP’: Permission denied
touch: cannot touch Users': Permission denied touch: cannot touchdefined’: Permission denied
[ERROR] Error code 1: trying to create empty file /etc/asterisk/no AMP Users defined
Please update your modules and reload Asterisk by browsing to your server.
bash-3.1$

I have to ask my programmer which is the apache psw to do the second test.

now that I’ve checked all the permission of these folders:
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk

and set them all to asterisk.asterisk with a setting of 775 I got this new error message:
Retrieve conf failed to copy file(s) from a module’s agi-bin dir: copy(/var/lib/asterisk/agi-bin/checksound.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/directory): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/recordingcheck): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/fixlocalprefix): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/list-item-remove.php): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/enumlookup.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/dialparties.agi): failed to open stream: Permission denied
copy(/var/lib/asterisk/agi-bin/user_login_out.agi): failed to open stream: Permission denied

Added ago
(retrieve_conf.CPAGIBIN)

maybe Is better to leave some permission to root?

no more help?

alek, you’ve been given the answer over and over. If you choose to run apache and asterisk as different users, then you are going to have to understand enough about linux and permissions to help yourself get it working. The error messages are telling you what is wrong, there’s nothing more but to address them.

I understood but my permissions for those folders are wrong?
Why then if I give the command amportal chown everything seems to be ok?

Alek,

Don’t take this the wrong way. But come on…

If you run the command amportal chown to change the permissions and it works after that what do you think?

That command was designed to go through and set all permissions to what they SHOULD, thus it fixes the files with wrong permissions. If you want to know what it’s fixing and why. Track what is changed, look at the amportal command code and read it.

You’ve tapped out my willingness of free help and I’ve had other priorities for the last week. realize that Free help is just that, free. and when I have free time I try and help but since doing that has a inverrse impact on my home life and getting paid at my real job…

The ampportal chown is the command I’ve been told to use, just that.
I’ve asked a simple question but it seems the answer isn’t that simple. I got that error and I’ve told how I got permission.
I don’t know how all permission have to be set by default, so I’ve asked to the forum. Anyway since I don’t have any problem related to that error, I’ll keep it like that.

tnx to all for your help