Wrong user/group for directories created in temp dir

Wrong user/group for directories created in temp dir

by Maxime Pelletier -
Number of replies: 5
Hi all,

I've setup 2 Moodle servers behind a HAproxy server. The dataroot directory is the same NFS mount on the 2 servers, which come from another server.

As specified in config.php, I create a directory local to each server for $CFG->tempdir

However, subdirectoried created under this directory are created with "root" as owner and group. Because of that, I get the famous "Invalid permissions detected in $CFG->dataroot directory, administrator has to fix permissions. " error message.

After changing owner to apache.apache, everything works well.

In developpement, I'm getting the following error:
===============
Debug info: [tempdir]/typo3temp/cs is not writable, check permissions.
Error code: invaliddatarootpermissions
Stack trace:
  • line 1379 of /lib/setuplib.php: invalid_dataroot_permissions thrown
  • line 1448 of /lib/setuplib.php: call to make_writable_directory()
  • line 86 of /lib/classes/text.php: call to make_temp_directory()
  • line 604 of /lib/classes/text.php: call to core_text::typo3()
  • line 37 of /enrol/flatfile/settings.php: call to core_text::get_encodings()
  • line 75 of /lib/classes/plugininfo/enrol.php: call to include()
  • line 109 of /admin/settings/plugins.php: call to core\plugininfo\enrol->load_settings()
  • line 6389 of /lib/adminlib.php: call to require()
  • line 3518 of /lib/navigationlib.php: call to admin_get_root()
  • line 3375 of /lib/navigationlib.php: call to settings_navigation->load_administration_settings()
  • line 717 of /lib/pagelib.php: call to settings_navigation->initialise()
  • line 734 of /lib/pagelib.php: call to moodle_page->magic_get_settingsnav()
  • line 109 of /blocks/admin_bookmarks/block_admin_bookmarks.php: call to moodle_page->__get()
  • line 296 of /blocks/moodleblock.class.php: call to block_admin_bookmarks->get_content()
  • line 238 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 956 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1008 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 361 of /lib/outputrenderers.php: call to block_manager->ensure_content_created()
  • line 48 of /theme/essential/layout/columns2.php: call to core_renderer->standard_head_html()
  • line 870 of /lib/outputrenderers.php: call to include()
  • line 800 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 2568 of /lib/outputrenderers.php: call to core_renderer->header()
  • line 362 of /lib/setuplib.php: call to core_renderer->fatal_error()
  • line ? of unknownfile: call to default_exception_handler()
===============


Any idea on why this happen?


Thanks in advance for yoiur help!

Average of ratings: -
In reply to Maxime Pelletier

Re: Wrong user/group for directories created in temp dir

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Have you *actually* used the /tmp directory (i.e. the system temporary directory) rather than create your own temporary area for Moodle? If so, that has the sticky bit set and will cause all manner of oddness. 

In reply to Howard Miller

Re: Wrong user/group for directories created in temp dir

by Maxime Pelletier -

Hi Howard,

Thanks for you answer, it will probably solve my problem.

When I set the tempdir to be /var/www/moodletemp, then Moodle creates a subdirectory "typo3temp" with apache.apache as owner, but this directory contains another subdirectory "cs" with root.root as owner. This eventually leads to the dataroot exception in Moodle.

When I set the tempdir to be /tmp/moodletemp, then all subdirectories avec created with apache.apache as owner. This should fix my problem.

I'm not quite sure if my problem is related to a bug of something missing in the documentation.

Regards

In reply to Maxime Pelletier

Re: Wrong user/group for directories created in temp dir

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is really weird. Moodle should not be able to create a directory with root ownership - even if it wanted to. Your web server (Apache on CentOS presumably) is running as user 'apache' and simply should not have the ability to do that (again, even if it wanted to). 

Just in case, empty the contents of /var/www/moodletemp and try again. 

In reply to Howard Miller

Re: Wrong user/group for directories created in temp dir

by Maxime Pelletier -

Hi Howard,

Apache is running as "apache" user. I don't understand either where this is coming from...

I already deleted the content of moodletemp a couple of time already smile

Thanks for following up!

In reply to Howard Miller

Re: Wrong user/group for directories created in temp dir

by Maxime Pelletier -

Hi Howard,

I can't confirm at 100% that I found my problem, but i would make sense...

I found that my scheduled task (cron, user sync, course enrol, ...) were all launch from root crontab. I moved them to apache user crontab. I guess that some temp directories were created by one of these scripts, which causes my problem.

If my problem come back, I'll let the world knows here smile

Regards