forked from MirrorHub/synapse
Merge pull request #4512 from matrix-org/anoa/consent_dir
Check consent dir path on startup
This commit is contained in:
commit
03b086647f
3 changed files with 15 additions and 11 deletions
1
changelog.d/4512.bugfix
Normal file
1
changelog.d/4512.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug where setting a relative consent directory path would cause a crash.
|
|
@ -13,6 +13,10 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
from synapse.config import ConfigError
|
||||||
|
|
||||||
from ._base import Config
|
from ._base import Config
|
||||||
|
|
||||||
DEFAULT_CONFIG = """\
|
DEFAULT_CONFIG = """\
|
||||||
|
@ -85,7 +89,15 @@ class ConsentConfig(Config):
|
||||||
if consent_config is None:
|
if consent_config is None:
|
||||||
return
|
return
|
||||||
self.user_consent_version = str(consent_config["version"])
|
self.user_consent_version = str(consent_config["version"])
|
||||||
self.user_consent_template_dir = consent_config["template_dir"]
|
self.user_consent_template_dir = self.abspath(
|
||||||
|
consent_config["template_dir"]
|
||||||
|
)
|
||||||
|
if not path.isdir(self.user_consent_template_dir):
|
||||||
|
raise ConfigError(
|
||||||
|
"Could not find template directory '%s'" % (
|
||||||
|
self.user_consent_template_dir,
|
||||||
|
),
|
||||||
|
)
|
||||||
self.user_consent_server_notice_content = consent_config.get(
|
self.user_consent_server_notice_content = consent_config.get(
|
||||||
"server_notice_content",
|
"server_notice_content",
|
||||||
)
|
)
|
||||||
|
|
|
@ -101,16 +101,7 @@ class ConsentResource(Resource):
|
||||||
"missing in config file.",
|
"missing in config file.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# daemonize changes the cwd to /, so make the path absolute now.
|
consent_template_directory = hs.config.user_consent_template_dir
|
||||||
consent_template_directory = path.abspath(
|
|
||||||
hs.config.user_consent_template_dir,
|
|
||||||
)
|
|
||||||
if not path.isdir(consent_template_directory):
|
|
||||||
raise ConfigError(
|
|
||||||
"Could not find template directory '%s'" % (
|
|
||||||
consent_template_directory,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
loader = jinja2.FileSystemLoader(consent_template_directory)
|
loader = jinja2.FileSystemLoader(consent_template_directory)
|
||||||
self._jinja_env = jinja2.Environment(
|
self._jinja_env = jinja2.Environment(
|
||||||
|
|
Loading…
Reference in a new issue