Skip to content
Snippets Groups Projects
Commit 376889dd authored by coredumperror's avatar coredumperror
Browse files

Added read/write permission checking to the default cache location.

parent 326e9813
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,8 @@ function s3fs_settings() {
'#type' => 'textfield',
'#title' => t('Default Cache Location'),
'#default_value' => _s3fs_get_setting('awssdk2_default_cache_config'),
'#description' => t('The default cache location for your EC2 Instance Profile Credentials.'),
'#description' => t('The default location to which your EC2 Instance Profile Credentials should be cached.
This must be a path to a folder in which the webserver can read and write.'),
'#states' => array(
'visible' => array(
':input[id=edit-s3fs-use-instance-profile]' => array('checked' => TRUE),
......
......@@ -82,6 +82,28 @@ function s3fs_requirements($phase) {
);
}
if (_s3fs_get_setting('awssdk2_use_instance_profile')) {
$default_cache_config = _s3fs_get_setting('awssdk2_default_cache_config');
if (isset($config['awssdk2_default_cache_config'])) {
$default_cache_config = $config['awssdk2_default_cache_config'];
}
$message = array(
'title' => $t('AWS Instance Profile Cache'),
);
if (empty($default_cache_config) || !(is_writable($default_cache_config) && is_readable($default_cache_config))) {
$message['value'] = $t('The instance profile cache is NOT configured correctly in S3FS. It must be set to an
existing folder on the server, and the webserver must have read and write permissions on that folder.');
$message['severity'] = REQUIREMENT_ERROR;
}
else {
$message['value'] = $t('The instance profile cache setting in S3FS is configured correctly.');
$message['severity'] = REQUIREMENT_INFO;
}
$requirements['s3fs_default_cache_location_status'] = $message;
}
return $requirements;
}
......
......@@ -731,12 +731,13 @@ function _s3fs_get_amazons3_client($config) {
array('!settings_page' => l(t('settings page'), 'admin/config/media/s3fs/settings')))
);
}
else if ($use_instance_profile && empty($default_cache_config)) {
else if ($use_instance_profile && (
empty($default_cache_config) || !(is_writable($default_cache_config) && is_readable($default_cache_config)))) {
throw new s3fsException(t("Your AWS credentials have not been properly configured.
You are attempting to use instance profile credentials but you have not set a default cache location.
You are attempting to use instance profile credentials but you have not set a valid default cache location.
Please set it on the !settings_page or set \$conf['awssdk2_default_cache_config'] in settings.php.
Note that this cache location must be an existing folder that can be read and written by both your webserver
and whichever user you run drush commands under.",
Note that this cache location must be an existing folder that can be read and written by your webserver.
It should also be writable by whichever user you run drush commands under.",
array('!settings_page' => l(t('settings page'), 'admin/config/media/s3fs/settings')))
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment