[Xorp-hackers] Hi,all. Is this a bug or just a mistake config?

Bruce Simpson bms at incunabulum.net
Mon Nov 30 16:01:01 PST 2009


cheng wan wrote:
>
>     Thank you, Bruce.
>     The official document "rtrmgr.pdf"(Chapter 2.3.2) gave one example:
>     foo {
>     %set: program "/bin/echo -n ’$(@)' >> /tmp/file.txt";
>     }
>     What I wrote in test.tp <http://test.tp/> was mostly like this.
>     If I did not use "save" after "commit", everything is OK.
>     What does "These command strings aren't guaranteed to be executed
>     by a shell" mean?
>     Does that mean Template Tree program Action can not support this?
>

You're trying to use a shell output redirection ('>>') from a Router 
Manager template file directly. This is probably going to break.

RouterManager just happens to use RunShellCommand from libxorp for 
*most* of the template program actions. This is purely how it happens to 
be implemented right now, and it isn't invoked that way in all cases; 
please refer to the source code.

Have you ktrace'd or struss'd to discover exactly why EPERM ('Permission 
denied') is being returned when your file cannot be created on 'commit'?

If all you are trying to do is to implement some non-volatile storage, 
in the form of a file holding some state, you are probably better off 
wrapping that inside your commands; i.e. write a script which knows 
where the storage is, rather than trying to use shell redirection, which 
may not behave how you expect it to.

For an example of this approach, please refer to the LiveCD / LiveUSB 
image scripts under svn/trunk/other/LiveCD.

In tools/tools/nanobsd/Files/sbin/usb_save is a POSIX shell script, 
invoked by the Router Manager, which knows where its storage is.
In tools/tools/nanobsd/liveusb.nano are some hooks, in the shell 
function cust_xorp_conf(), which append these commands to the misc.cmds 
template file.

thanks,
BMS



More information about the Xorp-hackers mailing list