Moodle Plugin Installer not working.

Moodle Plugin Installer not working.

by Mark Iannone -
Number of replies: 11

I have noticed that in Moodle 2.9 and 3.0 the plugin installer and the plugin up-grader does not work properly. What I have found is that when the installer is used the folder is placed in the correct moodle folder, but all of the folder permissions are changed to 777 and all of the files are changed to 666 and then the plugin does not work. A manual install setting the permissions of the main folder at 755 fixes the problem. When this is done all of the folders inside are at 755 and all of the files are 644 and the plugin works perfectly. It was so nice when the older versions of moodle were upgraded and all of the plugins auto updated correctly. I use about 6 plugins so it more work to upgrade. Has anyone else noticed this problem.

Cheers,

Mark Iannone

Chemistry Teacher

Average of ratings: -
In reply to Mark Iannone

Re: Moodle Plugin Installer not working.

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

File permissions 777 should work. They are more permissive than 755.

The only reason it might not work is if you have something like PHP 'safe mode' on, which detects overly-permissive (in it's opinion) file permissions, and then blocks access to those files, on the grounds of 'security'.

Have a look on the PHPinfo page, to see if there are any clues there.

Average of ratings:Useful (2)
In reply to Mark Iannone

Re: Moodle Plugin Installer not working.

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

I would guess you use the PHP Suhosin extension. IIRC, it refuses to serve a file with such permissions - see e.g. http://serverfault.com/questions/368536/disable-suhosin-file-permission-check

In either case, you should check your web server error logs.

In reply to David Mudrák

Re: Moodle Plugin Installer not working.

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Sorry to resurrect this thread. But I keep getting support requests about this. And it is invariably from users who don't know what a php.ini is. 

Is it really necessary to use 777 and 666? Can someone explain why this is the case?

In reply to Justin Hunt

Re: Moodle Plugin Installer not working.

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

I understood the problem discussed in this thread differently. With too permissive access rights, some patched PHP versions (e.g. the Suhosin mentioned) refuse to execute such script, ending with HTTP 500 error if I remember correctly.

What rights the files are created with depends on several factors - see lib/setup.php and search for $CFG->directorypermissions, $CFG->filepermissions and $CFG->umaskpermissions.

hth

In reply to David Mudrák

Re: Moodle Plugin Installer not working.

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks for the reply David. 

I did have a look at this. 

$CFG->directorypermissions defaults to 02777 is described in config.php as 

"permissions of new directories created by Moodle within the data directory. "

In setuplib.php and other places thats all good. But in the case described in this thread, we are not in the data directory. We are in the program directory. 

I had a quick snoop in lib/classes/update/code_manager.php at function unzip_plugin_file. It seems this calls function "extract_to_pathname" of zip_packer. Looking at that, to create the plugin directory it calls:

mkdir($newdir, $CFG->directorypermissions, true
 If I am not mistaken (and I often am)  this means that the new plugin directory will be created with permissions appropriate to the data directory and not for program directory. 
In reply to Justin Hunt

Re: Moodle Plugin Installer not working.

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Correct. I believe that my reasoning was that $CFG->directorypermissions would be appropriate setting in this situation too. So I sort of extended its original meaning to "permissions of new directories created by Moodle [anywhere]".

The alternative would be to introduce a new setting just for plugins auto-installation. But then, is there a valid use-case for when $CFG->directorypermissions is valid for dataroot and is not valid for dirroot? I am still pretty sure that one setting should be enough.

In reply to David Mudrák

Re: Moodle Plugin Installer not working.

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I am not sure about that. But I think this is a problem.

I do know that when the $CFG->directorypermissions is the default .. 02777 , that the plugin directories become 777 and the files become 666.

This errors out on some servers, presumably as stated, because Suhosin won't allow a hit from a browser on a file with those permissions.

I suspect that 777 for folders and 666 for files in the data directory however is not an issue because those files are not web accessible. 

Perhaps I should just put this issue on the tracker and see what people have to say there?

In reply to Justin Hunt

Re: Moodle Plugin Installer not working.

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Why simply not to set it to 02755 or 02750 on such servers? It makes sense for both PHP and data folders.

In reply to Justin Hunt

Re: Moodle Plugin Installer not working.

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok. I will suggest that to those whose permissions get stuffed and lets see how it goes. 

Thanks

In reply to Justin Hunt

Re: Moodle Plugin Installer not working.

by Antonio Duran -

Hi.


I have seen this problem happening quite often lately.

I don't know exactly what causing it (suhosin or something else in those servers), but the fact is that when permissions are set to 777 for folders and 666 for files, server fails returning error 500.


I really think this should be added to tracker for further discussion, as right now what I am doing is changing permissions after plugin installations, so that they work.


Telling people to manually change permissions in configuration file seems quite odd, specially when that is the default value set.

I know that I would be a little paranoid about doing that in one of my live sites, as I don't fully understand how it all works.


> Why simply not to set it to 02755 or 02750 on such servers? It makes sense for both PHP and data folders.


If this is true, why default permissions are not set with those values?


As I said, I think it is worth adding it to tracker.

I have no experience adding issues, so if any of you want to do it, that would be great. Otherwise, I will do it. I already created an account just in case.


Regards,

Antonio