A platform for community discussion. Free, open, simple.
DEV: Remove `/etc` from default `SafeExec` paths (#42466)
David Taylord7105ba613a4
diff --git a/lib/discourse/safe_exec.rb b/lib/discourse/safe_exec.rbindex c4b8a5e3ecb..99dbda15f83 100644--- a/lib/discourse/safe_exec.rb+++ b/lib/discourse/safe_exec.rb@@ -4,7 +4,7 @@ require "landlock"module Discourseclass SafeExec- DEFAULT_READ_PATHS = %w[/bin /etc /lib /lib64 /usr].freeze+ DEFAULT_READ_PATHS = %w[/bin /lib /lib64 /usr].freezeDEFAULT_EXECUTE_PATHS = %w[/bin /lib /lib64 /usr].freezedef self.capture(diff --git a/lib/image_magick.rb b/lib/image_magick.rbindex 86212283a31..f79f8438e98 100644--- a/lib/image_magick.rb+++ b/lib/image_magick.rb@@ -19,8 +19,13 @@ module ImageMagickDEFAULT_TIMEOUT = 30+ FONTCONFIG_READ_PATHS = %w[/etc/fonts].freeze+def self.asset_read_paths- @asset_read_paths ||= [Rails.root.join("vendor").to_s, ENV["MAGICK_CONFIGURE_PATH"]].compact+ @asset_read_paths ||=+ Discourse::SafeExec.existing_paths(+ [Rails.root.join("vendor").to_s, ENV["MAGICK_CONFIGURE_PATH"], *FONTCONFIG_READ_PATHS],+ )enddef self.magick(*args, read: [], write: [], timeout: nil, nice: nil, failure_message: "")diff --git a/plugins/discourse-ai/lib/completions/xls_to_text.rb b/plugins/discourse-ai/lib/completions/xls_to_text.rbindex 282f9c5b151..a434cc489dc 100644--- a/plugins/discourse-ai/lib/completions/xls_to_text.rb+++ b/plugins/discourse-ai/lib/completions/xls_to_text.rb@@ -47,8 +47,11 @@ module DiscourseAiendend+ CATDOC_CONFIG_PATH = "/etc/catdocrc"+def self.sandbox_read_paths(path)- Discourse::SafeExec.default_read_paths + [File.realpath(path)]+ Discourse::SafeExec.default_read_paths ++ Discourse::SafeExec.existing_paths([CATDOC_CONFIG_PATH]) + [File.realpath(path)]endendend