tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Stalp <st...@imbei.uni-mainz.de>
Subject Re: starting a binary by calling a servlet
Date Tue, 14 Jun 2005 12:52:54 GMT
I did it. 
I made this entry in catalina-policy:

 // Mein Eintrag zum ausführen eines Prozesses:
grant codeBase "file:${catalina.home}/webapps/my_exec/-" {
    permission java.io.FilePermission "/home/chris/c/file-test","execute";
};

Then I wrote this servlet:
[code]
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class FireStarter extends HttpServlet
{

 public void doGet ( HttpServletRequest req, HttpServletResponse res ) throws 
ServletException, IOException
 {
  int rueckgabe = 0;
  
  rueckgabe = Fireone();
  
  res.setContentType ( "text/html" );
  
  PrintWriter out = res.getWriter();
  
  out.println ( "<HTML>" );
  out.println ( "<HEAD><TITLE>Firestarter</TITLE></HEAD>" );
  out.println ( "<BODY>" );
  out.println ( "<BIG> Firestarter </BIG>" );
  out.println ( "</BODY></HTML>" );
 }
 
 public int Fireone ( )
 {
  int rueck_gabe = 0;
  try
  {
   String cmd1 = "/home/chris/c/file-test";
   Runtime rt = Runtime.getRuntime(); 
   Process myproc = rt.exec( cmd1 ); 
   rueck_gabe = myproc.waitFor();
   System.out.println("die Rueckgabe war: " + rueck_gabe );
  }
  catch( IOException ioexc ) 
  {
    ioexc.printStackTrace(); 
  }
  
  catch( InterruptedException intexc ) 
  {
    intexc.printStackTrace();
  } 
  return ( rueck_gabe );
  
 }
 
}
[/code]

And I put into a package ( with WEB-INF/  the web.xml-files and so on...) 
my_exec.WAR.

BUT this is the result/trace I got :-(
[quote]
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from 
fulfilling this request.

exception

java.security.AccessControlException: access denied 
(java.io.FilePermission /home/chris/c/file-test execute)
	at 
java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
	at java.security.AccessController.checkPermission(AccessController.java:401)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
	at java.lang.SecurityManager.checkExec(SecurityManager.java:771)
	at java.lang.Runtime.exec(Runtime.java:563)
	at java.lang.Runtime.exec(Runtime.java:428)
	at java.lang.Runtime.exec(Runtime.java:364)
	at java.lang.Runtime.exec(Runtime.java:326)
	at FireStarter.Fireone(FireStarter.java:32)
	at FireStarter.doGet(FireStarter.java:12)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
	at org.apache.catalina.core.ApplicationFilterChain.access$000
(ApplicationFilterChain.java:51)
	at 
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:129)
	at java.security.AccessController.doPrivileged(Native Method)
	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:125)
	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
	at 
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
	at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
 at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
 at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
 at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
 at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
 at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
 at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
 at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
 at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
 at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
 at java.lang.Thread.run(Thread.java:534)

Apache Tomcat/4.1
[/quote]
What went wrong, any small detail?

Thank you...

Gruss Christian


-- 
Christian Stalp
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Johannes-Gutenberg-Universität Mainz
Tel.: 06131 / 17-3107
E-Mail: stalp@imbei.uni-mainz.de

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message