Do not crash command loading if unable to read enabled plugins file.
Some distributions set no permissions to read the enabled plugins file location. This can cause a crash when running not as root or rabbitmq user. It was decided that plugins commands can be skipped when printing the help message if the user have no access to the enabled plugins file. The warning message will be displayed in that case. Addresses https://github.com/rabbitmq/rabbitmq-server/issues/1296 [#149079123]
This commit is contained in:
parent
e37179830b
commit
306b7574e4
|
|
@ -34,7 +34,7 @@ use Mix.Config
|
|||
#
|
||||
# Or configure a 3rd-party app:
|
||||
#
|
||||
config :logger, level: :warn
|
||||
config :logger, [level: :warn, console: [device: :standard_error]]
|
||||
#
|
||||
|
||||
# It is also possible to import configuration files, relative to this
|
||||
|
|
|
|||
|
|
@ -61,9 +61,22 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
|
|||
|
||||
def plugin_modules(opts) do
|
||||
Helpers.require_rabbit(opts)
|
||||
enabled_plugins =
|
||||
try do
|
||||
PluginsHelpers.read_enabled(opts)
|
||||
catch err ->
|
||||
{:ok, enabled_plugins_file} = PluginsHelpers.enabled_plugins_file(opts)
|
||||
require Logger
|
||||
Logger.warn("Unable to read enebled plugins file.\n" <>
|
||||
" Reason: #{inspect(err)}\n" <>
|
||||
" Plugins commands will not be available.\n" <>
|
||||
" Please make sure you have access to\n" <>
|
||||
" #{enabled_plugins_file}")
|
||||
[]
|
||||
end
|
||||
|
||||
partitioned =
|
||||
Enum.group_by(PluginsHelpers.read_enabled(opts), fn(app) ->
|
||||
Enum.group_by(enabled_plugins, fn(app) ->
|
||||
case Application.load(app) do
|
||||
:ok -> :loaded;
|
||||
{:error, {:already_loaded, ^app}} -> :loaded;
|
||||
|
|
|
|||
Loading…
Reference in New Issue