reject mounts with unsubstituted placeholders as incompletely configured

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-02-13 12:21:51 +01:00
parent 792bcb82ae
commit f8a133d39e
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 30 additions and 0 deletions

View File

@ -240,6 +240,20 @@ class OC_Mount_Config {
}
foreach ($options as &$option) {
$option = self::substitutePlaceholdersInConfig($option);
if(!self::arePlaceholdersSubstituted($option)) {
\OC::$server->getLogger()->error(
'A placeholder was not substituted: {option} for mount type {class}',
[
'app' => 'files_external',
'option' => $option,
'class' => $class,
]
);
throw new StorageNotAvailableException(
'Mount configuration incomplete',
StorageNotAvailableException::STATUS_INCOMPLETE_CONF
);
}
}
if (class_exists($class)) {
try {
@ -264,6 +278,22 @@ class OC_Mount_Config {
return StorageNotAvailableException::STATUS_ERROR;
}
public static function arePlaceholdersSubstituted($option):bool {
$result = true;
if(is_array($option)) {
foreach ($option as $optionItem) {
if(is_array($optionItem)) {
$result = $result && self::arePlaceholdersSubstituted($option);
}
}
} else if (is_string($option)) {
if (strpos($option, '$') !== false) {
$result = false;
}
}
return $result;
}
/**
* Read the mount points in the config file into an array
*