View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
06711Bug reportsTheme editorpublic2012-10-19 16:21
Reporterzozlak Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version2.00+ 
Fixed in Version2.00+ 
Summary06711: Wrong filesystem privileages set to template preview
Description

When php is running as different user then www server (e.g. mod suphp is used under Apache) and secure suphp settings are being used (new files umask 0077), then templates preview files created by Limesurvey has insuficient privileages for web server to display it (file is accesible only by its owner and is owned by user different than user web server is running as).
Limesurvey template editor should ensure that www server will have sufficient privileges to read template preview file by manualy setting access right to that file by eihter "group" or "all users" (in the first case when installing Limesurvey www user has to be added to the group under the files are created, the second case will work always but could be considered less secure).

Steps To Reproduce
  1. Using Apache web server configure php to run using suphp module (as sudoed CGI).
  2. Ensure that suphp umask is configured as 0077 (in fact the only right setting :) ).
  3. Login to Limesurvey administration panel and go to template editor.
  4. See
    Forbidden
    You don't have permission to access /tmp/template_temp_XXXXX.html

error message

TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)121014
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL 5.5.24
Server OS (if known)Debian 6 (Squeeze)
Webserver software & version (if known)Apache 2.2.22
PHP Version5.4.4-7, suphp

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-10-16 10:49

administrator   ~21348

LimeSurvey creates all files as webserver user (because the script itself is run by the webserver) so how would the webserver not be able to see it unless it is configured incorrectly. And if the script itself that created the file can set the file permission anway afterwards what good is the umask then?

The only way would be to chmod files after creation but which mask would be applied here? There is no general permission scheme you can use here.

Anyway, this sounds more like a feature request than a bug issue.
You should rather consider it to submit this to http://ideas.limesurvey.org , instead.

zozlak

zozlak

2012-10-16 17:05

reporter   ~21379

My long and detailed reply has just been just lost, as I spent too much time writing it :(
In brief:

  • the user which runs the PHP interpreter could be another user then the one which runs a web server (that is not a case when you are using Apache with mod_php, but mod_php and Apache are not the only way of running PHP :) ); I could describe this topic deeply if you are interested, but I think it is unnecessary here and now;
  • you are right that there is no permission schema which will satisfy all possible platforms;
  • I think that the simpliest and quite elegant solution will be accessing template previews by not directly, but through a simple php script wich will just read a template preview file and send it to the browser. It would work in a way that:
    • in the IFRAME displaing template preview the SRC property will be "pathToScript?file=template_temp_XXX.html" instead of "/tmp/template_temp_XXX.html" (this requires small change in "application/views/admin/templates/templatesummary_view.php", line 119);
    • script source will be just like:
      <?php
      importLocationOfLimeTmpDirectory(if it is stored in a configuration variable)
      if(!isset($_GET['file'])) return; // or display an error message
      //<-- make sure nobody is trying to use our script to get file another than template preview
      $file=array();
      preg_match('/^[_a-zA-Z0-9]+[.]html$/', $_GET['file'], $file);
      if(count($file)==0) return;
      $file=$PathToLimeTmpDir.$file[0];
      //-->
      if(!file_exists($file)) return; // or display an error message
      readfile($file);
      ?>
    • on mod_php platforms there will be no difference, and on the platforms where PHP is running as sudoed CGI problems with files permisions will gone;
  • I could easily prepare a patch described above, the only help I need form you is to tell me where such wrapper script should be placed to be in harmony with Limesruvey file structure?
c_schmitz

c_schmitz

2012-10-18 14:17

administrator   ~21437

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=9926

c_schmitz

c_schmitz

2012-10-19 16:21

administrator   ~21487

New version 2.00+ Build 121019 released. Please update.

Related Changesets

LimeSurvey: master 916d8b47

2012-10-18 05:17:19

c_schmitz

Details Diff
Fixed issue 06711: Template preview not working with strange umask PHP configurations Affected Issues
06711
mod - application/controllers/admin/templates.php Diff File
mod - application/views/admin/templates/templatesummary_view.php Diff File

Issue History

Date Modified Username Field Change
2012-10-16 10:39 zozlak New Issue
2012-10-16 10:49 c_schmitz Note Added: 21348
2012-10-16 10:49 c_schmitz Assigned To => c_schmitz
2012-10-16 10:49 c_schmitz Status new => feedback
2012-10-16 17:05 zozlak Note Added: 21379
2012-10-16 17:05 zozlak Status feedback => assigned
2012-10-18 14:17 c_schmitz Status assigned => resolved
2012-10-18 14:17 c_schmitz Fixed in Version => 2.00+
2012-10-18 14:17 c_schmitz Resolution open => fixed
2012-10-18 14:17 c_schmitz Changeset attached => LimeSurvey master 916d8b47
2012-10-18 14:17 c_schmitz Note Added: 21437
2012-10-19 16:21 c_schmitz Note Added: 21487
2012-10-19 16:21 c_schmitz Status resolved => closed
2015-12-11 14:40 c_schmitz Category Templates => Theme editor