Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #7314] double macros in command arguments seems to lead to exception #2021

Closed
icinga-migration opened this issue Sep 25, 2014 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/7314

Created by kiorky on 2014-09-25 15:55:13 +00:00

Assignee: gbeutner
Status: Resolved (closed on 2014-12-01 14:55:03 +00:00)
Target Version: 2.2.2
Last Update: 2014-12-01 17:27:06 +00:00 (in Redmine)

Icinga Version: 2.0.1

apply Service "S_TEST" {
    check_command = "C_TEST"
    assign where host.name in ["xxxxx"]
    import "ST_ALERT"
    vars.b = "2"
    vars.a = "1"
}
object CheckCommand "C_TEST" {
    import "C_BASE"
    command = "/bin/echo $a$$b$"
}

leads to

Exception occured while checking 'xxxx!S_TEST': ../../../lib/icinga/macroprocessor.cpp(170): Throw in function static icinga::String icinga::MacroProcessor::InternalResolveMacros(const icinga::String&, const ResolverList&, const Ptr&, icinga::String*, const EscapeCallback&, int)


Dynamic exception type: boost::exception_detail::clone_impl >
std::exception::what: Closing $ not found in macro format string.
[icinga::StackTrace*] = 
(0) libicinga.so: void boost::throw_exception >(boost::exception_detail::error_info_injector const&) (+0x104) [0x7f6e77b29ac4]
(1) libicinga.so: void boost::exception_detail::throw_exception_(std::runtime_error const&, char const*, char const*, int) (+0x69) [0x7f6e77b29bc9]
(2) libicinga.so: icinga::MacroProcessor::InternalResolveMacros(icinga::String const&, std::vector >, std::allocator > > > const&, boost::shared_ptr const&, icinga::String*, boost::function const&, int) (+0x419) [0x7f6e77b289d9]
(3) libicinga.so: icinga::MacroProcessor::ResolveMacros(icinga::Value const&, std::vector >, std::allocator > > > const&, boost::shared_ptr const&, icinga::String*, boost::function const&) (+0x124) [0x7f6e77b28cf4]
(4) libicinga.so: icinga::PluginUtility::ExecuteCommand(boost::shared_ptr const&, boost::shared_ptr const&, boost::shared_ptr const&, std::vector >, std::allocator > > > const&, boost::function const&) (+0xd3c) [0x7f6e77b41e7c]
(5) libmethods.so: icinga::PluginCheckTask::ScriptFunc(boost::shared_ptr const&, boost::shared_ptr const&) (+0x807) [0x7f6e774a9217]
(6) libmethods.so: icinga::Value icinga::ScriptFunctionWrapperV const&, boost::shared_ptr const&>(void (*)(boost::shared_ptr const&, boost::shared_ptr const&), std::vector > const&) (+0x96) [0x7f6e774a3ec6]
(7) libmethods.so: boost::detail::function::function_obj_invoker1 const&, boost::shared_ptr const&), std::vector > const&), boost::_bi::list2 const&, boost::shared_ptr const&)>, boost::arg<1> > >, icinga::Value, std::vector > const&>::invoke(boost::detail::function::function_buffer&, std::vector > const&) (+0xd) [0x7f6e774a265d]
(8) libbase.so: icinga::ScriptFunction::Invoke(std::vector > const&) (+0x1d) [0x7f6e7cbfdeed]
(9) libbase.so: icinga::DynamicObject::InvokeMethod(icinga::String const&, std::vector > const&) (+0x112) [0x7f6e7cbe05d2]
(10) libicinga.so: icinga::CheckCommand::Execute(boost::shared_ptr const&, boost::shared_ptr const&) (+0x1ca) [0x7f6e77ac4a0a]
(11) libicinga.so: icinga::Checkable::ExecuteCheck() (+0x1c1) [0x7f6e77b50491]
(12) libchecker.so: icinga::CheckerComponent::ExecuteCheckHelper(boost::shared_ptr const&) (+0x28) [0x7f6e7724f5b8]
(13) libbase.so: icinga::ThreadPool::WorkerThread::ThreadProc(icinga::ThreadPool::Queue&) (+0x3ad) [0x7f6e7cc2203d]
(14) libboost_thread.so.1.54.0: (+0xba4a) [0x7f6e7bb65a4a]
(15) libpthread.so.0: (+0x8182) [0x7f6e7cedd182]
(16) libc.so.6: clone (+0x6d) [0x7f6e7c06efbd]


[icinga::ContextTrace*] = 
(0) Resolving macros for string '/bin/echo $a$$b$'
(1) Executing check for object 'xxx!S_TEST'

Attachments

Changesets

2014-12-01 14:53:23 +00:00 by gbeutner a5c206c

Fix problem with macro arguments which are not separated by whitespace

fixes #7314

2014-12-01 14:54:45 +00:00 by gbeutner c0b78e8

Fix problem with macro arguments which are not separated by whitespace

fixes #7314

Relations:

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-11 17:07:26 +00:00

Problem is here that the macro resolver interprets two dollar signs as one dollar sign being escaped. Though the error message should be better.

@icinga-migration
Copy link
Author

Updated by kiorky on 2014-10-14 09:31:34 +00:00

Ok, but then, how can i write this command ?

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-14 09:48:41 +00:00

  • File added Auswahl_106.png

Try it the shell escaping way of an empty string and trick the parser:

object CheckCommand "echo-test" {
  import "plugin-check-command"
  command = "echo $a$''$b$"
}

object Host "echo-test" {
  check_command = "echo-test"
  vars.a = 1
  vars.b = 2
}

Auswahl_106.png

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-11-11 22:28:05 +00:00

  • Category set to libicinga
  • Status changed from New to Assigned
  • Assigned to set to kiorky

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-11-24 13:25:36 +00:00

  • Status changed from Assigned to New
  • Assigned to deleted kiorky
  • Target Version set to 2.2.1

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-11-25 09:49:54 +00:00

  • Target Version changed from 2.2.1 to 2.2.2

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-11-26 19:22:06 +00:00

TODO: Add a unit test for this once it's fixed.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-01 14:43:34 +00:00

  • Status changed from New to Assigned
  • Assigned to set to gbeutner

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-01 14:55:03 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset a5c206c.

@icinga-migration
Copy link
Author

Updated by kiorky on 2014-12-01 17:27:06 +00:00

Great !

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-12-11 17:56:16 +00:00

  • Duplicated set to 8068

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-12-16 19:01:14 +00:00

  • Relates set to 6858

@icinga-migration icinga-migration added bug Something isn't working libicinga labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.2.2 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant