Skip to content
Snippets Groups Projects
Unverified Commit f8a133d3 authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

reject mounts with unsubstituted placeholders as incompletely configured

parent 792bcb82
No related branches found
No related tags found
No related merge requests found
...@@ -240,6 +240,20 @@ class OC_Mount_Config { ...@@ -240,6 +240,20 @@ class OC_Mount_Config {
} }
foreach ($options as &$option) { foreach ($options as &$option) {
$option = self::substitutePlaceholdersInConfig($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)) { if (class_exists($class)) {
try { try {
...@@ -264,6 +278,22 @@ class OC_Mount_Config { ...@@ -264,6 +278,22 @@ class OC_Mount_Config {
return StorageNotAvailableException::STATUS_ERROR; 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 * Read the mount points in the config file into an array
* *
......
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