<# # The FreeWRT Webinterface #- # Copyright © 2007 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un- # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # Advertising materials mentioning features or use of this work must # display the following acknowledgement: # This product includes material provided by Thorsten Glaser. # # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person's immediate fault when using the work as intended. #><%pre> #include "common.h" #include #include "c_exec.h" __RCSID("$Id$"); <%args> really; ck; op; <%application> unsigned checkpoint; <%cpp> bool okay = false; std::string pageheader = "management"; std::string pagetitle_run, pagetitle_wrong, pagetitle_ok, utilname; std::string text_wrong, text_ok; /* HTML ok in these */ if (op == "commit") { pageheader = "commit to fwcf (flash)"; pagetitle_run = "Committing to flash"; pagetitle_wrong = "Commit failed"; text_wrong = "Committing to flash failed."; pagetitle_ok = "Committed successfully"; text_ok = "The changes to /etc were "; text_ok += "successfully committed to flash using the "; text_ok += "FreeWRT Configuration Filesystem."; utilname = "fwcf commit"; okay = true; } else if (op == "reload") { pageheader = "reload webinterface"; pagetitle_run = "Reloading webinterface"; pagetitle_wrong = "Reload failed"; text_wrong = "Reloading webinterface failed."; pagetitle_ok = "Reloaded successfully"; text_ok = "The webinterface was reloaded."; utilname = "/etc/init.d/fwwif restart"; okay = true; } else if (op == "reboot") { pageheader = "reboot"; pagetitle_run = "Rebooting"; pagetitle_wrong = "Reboot failed"; text_wrong = "Reboot failed."; pagetitle_ok = "Rebooted successfully"; text_ok = "The embedded system was rebooted."; utilname = "/bin/busybox reboot"; okay = true; } runComp2(header, title, pageheader); unsigned ick; ick = strtoul(ck.c_str(), NULL, 0); if (!okay) {

Management functions

Please choose one of the following management functions.

% } else if (really == "yes" && ick && ick == checkpoint) {

<$pagetitle_run$>…

Please wait…

<%cpp> int i = 0; char *text; reply.setDirectMode(); // flush output checkpoint = arc4random(); /* prevent re-use */ text = c_exec(utilname.c_str(), &i); if (i) { reply.out() << "

"; reply.sout() << text_wrong; reply.out() << "!

\n

" << text_wrong << "

\n"; } else { reply.out() << "

"; reply.sout() << text_ok; reply.out() << ".

\n

" << text_ok << "

\n"; }

The “<$utilname$>” utility returned the following output:

%		reply.sout() << text ? (*text ? text : "(no output)") : "(null)";

The exit code was <$ WEXITSTATUS(i) $>.

Go back or to the index.

<%cpp> } else { do { checkpoint = arc4random(); /* authorisation */ } while (!checkpoint); if (op == "commit" || op == "reboot") { int i; char *changes; changes = c_exec("/sbin/fwcf status", &i); % if (op == "commit") {

Commit to flash

% } else if (op == "reboot") {

Reboot embedded system

% } % if (changes) {

The following files have been modified:

<$ *changes ? changes : "No files modified." $>
% if (op == "commit") {

Do you really want to commit all these changes into flash to retain them over system reboots?

% } else if (op == "reboot") {

Do you really want to reboot without saving these changes?

% } % free(changes); % } else {

Do you really want to commit all changes to /etc into flash to retain them over system reboots?

% } % } else if (op == "reload") {

Reload the webinterface

Do you really want to stop and restart the webinterface?

% }
  Yes No  
% } <& footer>