-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make writable directory location configurable, closes #959
* Created new FileDataManager class, moved data directory-specific Utils functions into it * When config.inc.php datadir_path value doesn't exist, default to source_root_path/data/ * Avoid "Can't write to file" data folder permissions problems during export and backup * Gracefully handle missing config file during installation, and missing datadir_path value in existing config * Automatically create compiled_view folder if it doesn't already exist * Expand and clarify documentation
- Loading branch information
1 parent
7c2c77d
commit b56dcab
Showing
40 changed files
with
321 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
Understanding ThinkUp's Folder Permissions | ||
========================================== | ||
|
||
In order for ThinkUp to run, it must be able to write caches, template compilations, and sometimes plugin data | ||
to a specific data directory defined in $THINKUP_CFG['datadir_path']. By default this is ``/your_path_to_thinkup/webapp/data``. | ||
In order to run, ThinkUp must be able to write files to a specific data directory defined in the | ||
``config.inc.php`` file as ``$THINKUP_CFG['datadir_path']``. By default the data directory is located in the root of | ||
the thinkup web-accessible directory and is named ``data``. | ||
|
||
The recommended and most secure way to grant ThinkUp write access to these folders is to change the owner of this | ||
The recommended and most secure way to grant ThinkUp write access to this folder is to change the owner of this | ||
folder to the web server user. The command for doing this is: | ||
|
||
``chown -R apache your_datadir_path`` | ||
|
||
Where your_datadir_path is your installation path and apache is the name of the web server user. | ||
Where your_datadir_path is your installation's data directory path and apache is the name of the web server user. | ||
(Note that this username could vary depending on your server.) | ||
|
||
If you are unable to change owner (chown) the folder, a less secure but just as effective method is to make the folder | ||
writable by the world. To do that, you can run this command: | ||
|
||
``chmod -R 777 your_datadir_path`` | ||
|
||
If possible, change the folder's owner to the web server user or group instead of setting its permissions to world-writable. | ||
If possible, change the folder's owner to the web server user or group instead of setting its permissions to | ||
world-writable. | ||
|
||
Change the Location of ThinkUp's Data Directory | ||
----------------------------------------------- | ||
|
||
For security-related or other reasons, you may not want ThinkUp's data directory to live in a web-accessible folder. | ||
To change the location ThinkUp's data directory, open the ``config.inc.php`` in any text editor and set your | ||
desired location in the ``$THINKUP_CFG['datadir_path']`` value. Note that ThinkUp's data directory must be writable | ||
by the web server and MySQL user for ThinkUp to function. Grant ThinkUp those access permissions using the | ||
instructions above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
The MySQL user does not have the proper file permissions to backup/export data | ||
============================================================================== | ||
|
||
The Thinkup MySQL user does not have the proper file permissions to backup or export data. Make Sure the MySQL | ||
server has write privileges to the ThinkUp's ``compiled_view`` directory under the data directory | ||
defined in $THINKUP_CFG['datadir_path']. | ||
ThinkUp's MySQL user does not have the proper file permissions to back up or export data. Make sure the MySQL | ||
user has write privileges to ThinkUp's ``backup`` folder under the data directory | ||
defined in ``config.inc.php``'s ``$THINKUP_CFG['datadir_path']`` value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/** | ||
* | ||
* ThinkUp/tests/TestOfFileDataManager.php | ||
* | ||
* Copyright (c) 2012 Gina Trapani | ||
* | ||
* LICENSE: | ||
* | ||
* This file is part of ThinkUp (http://thinkupapp.com). | ||
* | ||
* ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with ThinkUp. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
* | ||
* @author Gina Trapani <ginatrapani[at]gmail[dot]com> | ||
* @license http://www.gnu.org/licenses/gpl.html | ||
* @copyright 2012 Gina Trapani, Guillaume Boudreau | ||
*/ | ||
require_once dirname(__FILE__).'/init.tests.php'; | ||
require_once THINKUP_ROOT_PATH.'webapp/_lib/extlib/simpletest/autorun.php'; | ||
require_once THINKUP_ROOT_PATH.'webapp/config.inc.php'; | ||
|
||
class TestOfFileDataManager extends ThinkUpBasicUnitTestCase { | ||
|
||
public function testGetDataPathNoConfigFile() { | ||
Config::destroyInstance(); | ||
$this->removeConfigFile(); | ||
|
||
//test just path | ||
$path = FileDataManager::getDataPath(); | ||
$this->assertEqual($path, THINKUP_WEBAPP_PATH.'data/'); | ||
|
||
//test path with file | ||
$path = FileDataManager::getDataPath('myfile.txt'); | ||
$this->assertEqual($path, THINKUP_WEBAPP_PATH.'data/myfile.txt'); | ||
$this->restoreConfigFile(); | ||
} | ||
|
||
public function testGetDataPathConfigExistsWithoutDataDirValue() { | ||
Config::destroyInstance(); | ||
$this->removeConfigFile(); | ||
$cfg_values = array("table_prefix"=>"thinkupyo", "db_host"=>"myserver.com"); | ||
$config = Config::getInstance($cfg_values); | ||
|
||
//test just path | ||
$path = FileDataManager::getDataPath(); | ||
$this->assertEqual($path, THINKUP_WEBAPP_PATH.'data/'); | ||
|
||
//test path with file | ||
$path = FileDataManager::getDataPath('myfile.txt'); | ||
$this->assertEqual($path, THINKUP_WEBAPP_PATH.'data/myfile.txt'); | ||
$this->restoreConfigFile(); | ||
} | ||
|
||
public function testGetDataPathConfigExistsWithDataDirValue() { | ||
require THINKUP_ROOT_PATH.'webapp/config.inc.php'; | ||
|
||
//if test fails here, the config file doesn't have datadir_path set | ||
$this->assertNotNull($THINKUP_CFG['datadir_path']); | ||
|
||
//test just path | ||
$path = FileDataManager::getDataPath(); | ||
$this->assertEqual($path, $THINKUP_CFG['datadir_path']); | ||
|
||
//test path with file | ||
$path = FileDataManager::getDataPath('myfile.txt'); | ||
$this->assertEqual($path, $THINKUP_CFG['datadir_path'].'myfile.txt'); | ||
} | ||
|
||
public function testGetBackupPath() { | ||
require THINKUP_ROOT_PATH.'webapp/config.inc.php'; | ||
|
||
//if test fails here, the config file doesn't have datadir_path set | ||
$this->assertNotNull($THINKUP_CFG['datadir_path']); | ||
|
||
//test just path | ||
$path = FileDataManager::getBackupPath(); | ||
$this->assertEqual($path, $THINKUP_CFG['datadir_path'].'backup/'); | ||
|
||
//test just path | ||
$path = FileDataManager::getBackupPath('README.txt'); | ||
$this->assertEqual($path, $THINKUP_CFG['datadir_path'].'backup/README.txt'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.