Command Authorization Fails with EEM applet or Tcl policy
One of my readers asked an interesting question: „why do the commands executed within a EEM Tcl policy fail with Command authorization fails message?“ The short answer is simple: If you use AAA command authorization (which you can only do if you're using a TACACS+ server), you have to specify the username under which the EEM will execute its CLI commands with the event manager session cli username user configuration command.
Note: This is only required if you use TACACS+ server, as the command authorization cannot be performed in AAA environments using RADIUS servers.
For those of you who want to know more, here's the in-depth explanation:
The EEM applets or Tcl policies do not execute in the context of a line (physical or virtual terminal interface), it's therefore impossible to execute CLI commands directly from the EEM policies (contrary to what you can do in Tcl shell with exec command). To execute CLI commands, you have to open a quasi-telnet session with the cli_open call and send and receive characters with the cli_exec call or a combination of cli_write/cli_read* calls. The same approach is used for the commands executed with the action cli commands within EEM applets, the only difference being that you cannot process the output generated by the CLI commands in the EEM applet.
The commands executed by an EEM applet or Tcl policy undergo all the security checks usually performed by a router (they are no different from commands typed in by an operator using a telnet session, only the authentication process is skipped). If you have configured AAA command authorization, the router sends AAA request to the TACACS+ server for every command the EEM applet tries to execute ... and the authorization requests fail if there is no username included in the request. As the login process is skipped, you have to set the desired username manually with the event manager session cli username user configuration command.
Question about using pure TCL scripts (without EMM) with AAA command authorization
How to start the TCL script under a specific username to prevent the "Command authorization fails message"
On the above article it is mentionned that the ios_config command is executed inside the context of another VTY line (also found with the AAA debug). The workaround is to define the FIRST VTY line with "transport input none" to prevent ssh or telnet to grab it and to configure the aaa authorization without any command authorization for this line.
Sorry for a late reply, I was on vacation. Your observation was successfully reproduced and is now the bug CSCsu65401. Thanks for the perfect workaround :)
inside EEM there is a generic queue to pass messages, with producers and consumers. Each entry has a specific type (trigger event, aaa event...), and there is a different consumer for each type.
The message "EM: No consumer registered for any event type" appears when:
1) EEM debug is enabled, and
2) when there a message in the queue, but there's no consumer associated.
This is not a bug nor a problem, but rather a notification to help IOS developers.
i tried some.
action 2.0 cli command "enable"
action 2.1 cli command "tclsh test.tcl"
that test.tcl contain below code :
puts "in tcl"
but i cant see anything printed in terminal.
i debug the eem actions and see that tcl file executing but nothing appear in terminal.
i apologize for my bad english.