icingaweb2-module-director icon indicating copy to clipboard operation
icingaweb2-module-director copied to clipboard

Icinga2 doesn't restart if command has set Render as String to true but still has arguments

Open w1ll-i-code opened this issue 1 year ago • 1 comments

Expected Behavior

I either want to not be able to add arguments or be able to add arguments regardless of the state of Render as String

Current Behavior

If the Check command has the field Render as String set to true, but the command has extra arguments, the director will generate a config file that can't be processed by icinga2.

Possible Solution

If Render as String is set, render it as ["<string>"] instead of "<string>".

Steps to Reproduce (for bugs)

  • Create a new Check Command
  • the command is /usr/bin/ls
  • set Render as String to true
  • add a parameter for the directory
  • Notice that the deploy fails because it expected an array as command but got a string
[2024-01-09 08:21:51 +0000] critical/config: Error: Validation failed for object 'basket-command' of type 'CheckCommand'; Attribute 'command': Attribute 'command' must be an array if the 'arguments' attribute is set.
Location: in [stage]/zones.d/director-global/command_templates.conf: 3:5-3:29
[stage]/zones.d/director-global/command_templates.conf(1): template CheckCommand "basket-command-template" {
[stage]/zones.d/director-global/command_templates.conf(2): import "plugin-check-command"
[stage]/zones.d/director-global/command_templates.conf(3): command = "/usr/bin/true" 
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/director-global/command_templates.conf(4): timeout = 5m
[stage]/zones.d/director-global/command_templates.conf(5): arguments += {
[2024-01-09 08:21:51 +0000] critical/config: 1 error
[2024-01-09 08:21:51 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.

Your Environment

  • Director version (System - About): 1.11.0
  • Icinga Web 2 version and modules (System - About): 2.10.5
  • Icinga 2 version (icinga2 --version): r2.14.0-1
  • Operating System and version: rhel 8.9
  • Webserver, PHP versions: 7.4.33

w1ll-i-code avatar Jan 11 '24 14:01 w1ll-i-code

I would't use that anyway but here it is documented:

Screenshot 2024-02-20 000505

Render the command as a plain string instead of an array. If enabled you can not define arguments. Disabled by default, and should only be used in rare cases. WARNING, this can allow shell script injection via custom variables used in command.

moreamazingnick avatar Feb 19 '24 23:02 moreamazingnick