mirror of
https://github.com/ovh/the-bastion.git
synced 2024-09-20 23:15:58 +08:00
fix: osh.pl: plugin_config 'disabled' key is a boolean
This commit is contained in:
parent
6e03fa2877
commit
790802e6da
|
@ -827,7 +827,7 @@ if ($osh_command) {
|
||||||
my $isDisabled = OVH::Bastion::plugin_config(plugin => $osh_command, key => "disabled");
|
my $isDisabled = OVH::Bastion::plugin_config(plugin => $osh_command, key => "disabled");
|
||||||
|
|
||||||
# plugin is enabled by default if not explicitly disabled
|
# plugin is enabled by default if not explicitly disabled
|
||||||
if ($isDisabled and $isDisabled->value() =~ /yes/) {
|
if ($isDisabled and $isDisabled->value()) {
|
||||||
main_exit OVH::Bastion::EXIT_RESTRICTED_COMMAND, "plugin_disabled", "Sorry, this plugin has been disabled by policy.";
|
main_exit OVH::Bastion::EXIT_RESTRICTED_COMMAND, "plugin_disabled", "Sorry, this plugin has been disabled by policy.";
|
||||||
}
|
}
|
||||||
if ($isDisabled->is_err && $isDisabled->err ne 'KO_NO_SUCH_FILE') {
|
if ($isDisabled->is_err && $isDisabled->err ne 'KO_NO_SUCH_FILE') {
|
||||||
|
|
|
@ -401,6 +401,15 @@ sub plugin_config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# compat: we previously expected "yes" as a value for the 'disabled' option, instead of a boolean.
|
||||||
|
# To keep compatibility we still consider "yes" as a true value (as any non-empty string is),
|
||||||
|
# however we check that the user was not confused and didn't try to enable the plugin by using
|
||||||
|
# a string such as "no" or "false" instead of a real false boolean:
|
||||||
|
if (defined $config{'disabled'} && $config{'disabled'} =~ /no|false/) {
|
||||||
|
warn_syslog("Configuration error for plugin $plugin on the 'disabled' key: expected a boolean, casted '" . $config{'disabled'} . "' into false");
|
||||||
|
$config{'disabled'} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$_plugin_config_cache{$plugin} = \%config;
|
$_plugin_config_cache{$plugin} = \%config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue