*
* @{
*/
-fr_dict_gctx_t const *fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir);
+fr_dict_gctx_t *fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir);
+
+void fr_dict_global_ctx_perm_check(fr_dict_gctx_t *gctx, bool enable);
void fr_dict_global_ctx_set(fr_dict_gctx_t const *gctx);
struct fr_dict_gctx_s {
bool free_at_exit; //!< This gctx will be freed on exit.
+ bool perm_check; //!< Whether we should check dictionary
+ ///< file permissions as they're loaded.
+
bool read_only;
char *dict_dir_default; //!< The default location for loading dictionaries if one
* the server configuration with little difficulty.
*/
#ifdef S_IWOTH
- if ((statbuf.st_mode & S_IWOTH) != 0) {
+ if (dict_gctx->perm_check && ((statbuf.st_mode & S_IWOTH) != 0)) {
fclose(fp);
fr_strerror_printf_push("Dictionary is globally writable: %s. "
"Refusing to start due to insecure configuration", fn);
* - A pointer to the new global context on success.
* - NULL on failure.
*/
-fr_dict_gctx_t const *fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir)
+fr_dict_gctx_t *fr_dict_global_ctx_init(TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir)
{
fr_dict_gctx_t *new_ctx;
fr_strerror_const("Out of Memory");
return NULL;
}
+ new_ctx->perm_check = true; /* Check file permissions by default */
new_ctx->protocol_by_name = fr_hash_table_alloc(new_ctx, dict_protocol_name_hash, dict_protocol_name_cmp, NULL);
if (!new_ctx->protocol_by_name) {
return new_ctx;
}
+/** Set whether we check dictionary file permissions
+ *
+ * @param[in] gctx to alter.
+ * @param[in] enable Whether we should check file permissions as they're loaded.
+ */
+void fr_dict_global_ctx_perm_check(fr_dict_gctx_t *gctx, bool enable)
+{
+ gctx->perm_check = enable;
+}
+
/** Set a new, active, global dictionary context
*
* @param[in] gctx To set.