You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark HB <m....@mail.cryst.bbk.ac.uk> on 2006/09/12 10:16:55 UTC

Executing binary from Servlet

Hi,

I am looking for some help on a problem I have encountered with
executing a binary from a servlet using Runtime.getRuntime().exec()
The code that I have is simply executing a binary called "cimmsim":

File theDir = new File(curdir+"WORK/"+rand);
java.lang.String cmdline = theDir+"/cimmsim -f config";
try {
Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
}
catch (IOException e)
{ e.printStackTrace(); }

The error that is produced is:
java.io.IOException: java.io.IOException:
/srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
cannot execute
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Runtime.java:566)
        at java.lang.Runtime.exec(Runtime.java:428)
        at RunSimulation.run(CimmSimServlet.java:655)

A uname -a on the system gives:
Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
x86_64 x86_64 GNU/Linux
SUSE LINUX 10.1

I have ensured that the permissions are set to at least 755 and am now
at a bit of a loss.
Any ideas?

Cheers
Mark



-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04
---------------------------------------------------------------------------



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Sriram Narayanan <sr...@gmail.com>.
On 9/12/06, Mark HB <m....@mail.cryst.bbk.ac.uk> wrote:
> I have ensured that the permissions are set to at least 755 and am now
> at a bit of a loss.
> Any ideas?
>

I'd faced a similar problem yesterday when adding some features to
Sahi (http://sahi.sourceforge.net/). But this was on Windows.

I took the system environment properties, converted these into an
array, and passed them as arguments to Runtime.exec() instead of
passing a null.

If you _don't_ wish to pass any environment to the executable, then
try passing an empty array instead of a null.

-- Sriram

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by David Delbecq <de...@oma.be>.
considering where the exception occured, i bet this is not a java
security exception (it already passed the security test at that point
and is inside the priviledged code, moreover this is an IOException not
a SecurityException you get). However, there is a bad code inside
UNIXProcess:
        IOException e = gate.getException();
        if (e != null)
            throw new IOException(e.toString());
So you will have to stick a debugger at that point to get the original
exception (eg run tomcat inside eclipse using ad-hoc eclipse plugins,
put a breakpoint inside that address and read the original exception).
Mark HB a écrit :
> Hi,
>
> My apologies for the confusion, but my previous claim to have sorted
> this problem out is now incorrect. It seems with the upgrade to 1.5.0,
> the execution of the external binary does work, --- but only
> sometimes?? ---. I can't seem to work out the exact conditions that it
> works, and seems to be random.
>
>
> Could someone please indicate what I need to add/change in the
> catalina.policy file to allow the execution of external binaries. I've
> had a good look at this url and can't seem to find any indicators.
>
> > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>
> Cheers
> Mark
>
>
> -------------------------------------
>
> Thanks Enrico,
>
> However I seem to have inadvertently solved it. I was updating to the
> latest release of jre and recompiled the servlet with 1.5.0 and now it
> works.
> Previously I was using 1.3.1.
> So there we go.
>
> Cheers
> Mark
>
> Enrico Giurin wrote:
>> Hello,
>> I guess yours is a problem of security manager of tomcat.
>> I think you have to modify some entries of the catalina.policy file.
>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>
>>
>> Enrico.
>>
>> ----- Original Message ----- From: "Mark HB"
>> <m....@mail.cryst.bbk.ac.uk>
>> To: <us...@tomcat.apache.org>
>> Sent: Tuesday, September 12, 2006 10:16 AM
>> Subject: Executing binary from Servlet
>>
>>
>>> Hi,
>>>
>>> I am looking for some help on a problem I have encountered with
>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>> The code that I have is simply executing a binary called "cimmsim":
>>>
>>> File theDir = new File(curdir+"WORK/"+rand);
>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>> try {
>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>> }
>>> catch (IOException e)
>>> { e.printStackTrace(); }
>>>
>>> The error that is produced is:
>>> java.io.IOException: java.io.IOException:
>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>> cannot execute
>>>        at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
>>>        at java.lang.Runtime.execInternal(Native Method)
>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>
>>> A uname -a on the system gives:
>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>> x86_64 x86_64 GNU/Linux
>>> SUSE LINUX 10.1
>>>
>>> I have ensured that the permissions are set to at least 755 and am now
>>> at a bit of a loss.
>>> Any ideas?
>>>
>>> Cheers
>>> Mark
>>>
>>>
>>>
>>> -- 
>>> ---------------------------------------------------------------------------
>>>
>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>> Research Associate                      |
>>> Room 359                                | Fax: +44-20-7631-6803
>>> School of Crystallography               |
>>> Birkbeck College                        | Email:
>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>> London WC1E 7HX                         | markyhb@gmail.com
>>> UK                                      |
>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>> ---------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>> -- 
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date:
>>> 11/09/2006
>>>
>>>
>>
>>
>>    
>>            ___________________________________ Yahoo! Mail: gratis
>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Martin Gainty <mg...@hotmail.com>.
if you're front ending with Apache.. then Apache .htaccess could be configured against it..
If you exec those same commands with root access and it works its definitely a permission problem with the previous username
Good Point
M-
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Santosh Puranshettiwar" <sa...@wirkle.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, September 12, 2006 8:56 AM
Subject: Re: Executing binary from Servlet


> >Specifically its been my experience that if you DONT have Security 
> permissions specifically >configured for that jar then the >classes will 
> not run
> Is it applicable to only to jars or to any webapp deployed in Tomcat as 
> such. I've managed to use exec() successfully on some programs 
> successfully without ever touching the security manager.
> 
> For Mark HB:
> Could it be a ownership/group problem?
> 
> Santosh.
> Martin Gainty wrote:
>> Mark-
>> My experience has been radically different than Davids
>>
>> Specifically its been my experience that if you DONT have Security permissions specifically configured for that jar then the classes will not run
>> here is an example from catalina.policy
>>
>> grant codeBase "file:${catalina.home}/bin/bootstrap.jar" 
>> {
>>  permission java.lang.RuntimePermission "getenv.CATALINA_HOME";
>>  permission java.lang.RuntimePermission "setenv.CATALINA_HOME";
>>  permission java.util.PropertyPermission "catalina.home", "read,write";
>>         permission java.security.AllPermission;
>> };
>> You have to run with security manager in order to have the policy read and interpreted correctly
>>
>> I would suggest you run in debug so you can display what is going on
>> i.e.
>> sh catalina.sh -debug -security
>>   
>>> run org.apache.catalina.startup.Bootstrap
>>>     
>>
>> M-
>> *********************************************************************
>> This email message and any files transmitted with it contain confidential
>> information intended only for the person(s) to whom this email message is
>> addressed.  If you have received this email message in error, please notify
>> the sender immediately by telephone or email and destroy the original
>> message without making a copy.  Thank you.
>>
>>
>>
>> ----- Original Message ----- 
>> From: "Mark HB" <m....@mail.cryst.bbk.ac.uk>
>> To: "Tomcat Users List" <us...@tomcat.apache.org>
>> Sent: Tuesday, September 12, 2006 8:27 AM
>> Subject: Re: Executing binary from Servlet
>>
>>
>>   
>>> HI,
>>> It all runs fine as a standalone, and when I print the command that I am 
>>> running using exec to the screen and then run it myself, it works fine.
>>> I had this servlet deployed on another machine, and I never had this 
>>> problem.
>>> It is very odd, as sometimes it works and the executable is executed and 
>>> the results are returned, and other times it returns the same error as 
>>> before.
>>> There doesn't seem to be any pattern as to when they work.
>>> I have changed the policy file, to no affect
>>>
>>> java.io.IOException: java.io.IOException:
>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>> cannot execute
>>>       at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>       at java.lang.Runtime.execInternal(Native Method)
>>>       at java.lang.Runtime.exec(Runtime.java:566)
>>>       at java.lang.Runtime.exec(Runtime.java:428)
>>>       at RunSimulation.run(CimmSimServlet.java:655)
>>>
>>> I am looking into deploying the servlet in the J2EE app server instead 
>>> and seeing if that avoids this problem.
>>> Its all very odd!
>>> Thanks
>>> Mark
>>>
>>> Santosh Puranshettiwar wrote:
>>>     
>>>> I agree with David. This does not seem to be a SecurityManager 
>>>> problem. Does your code run properly as a normal executable program 
>>>> (with main())?
>>>>
>>>> Sameer Acharya wrote:
>>>>       
>>>>> Have you tried adding following to your web app permissions in policy 
>>>>> file
>>>>>
>>>>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>>>>
>>>>> -Sameer
>>>>>
>>>>>
>>>>>
>>>>> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,
>>>>>
>>>>> My apologies for the confusion, but my previous claim to have sorted 
>>>>> this problem out is now incorrect. It seems with the upgrade to 
>>>>> 1.5.0, the execution of the external binary does work, --- but only 
>>>>> sometimes?? ---. I can't seem to work out the exact conditions that 
>>>>> it works, and seems to be random.
>>>>>
>>>>>
>>>>> Could someone please indicate what I need to add/change in the 
>>>>> catalina.policy file to allow the execution of external binaries. 
>>>>> I've had a good look at this url and can't seem to find any indicators.
>>>>>
>>>>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>>
>>>>> Cheers
>>>>> Mark
>>>>>
>>>>>
>>>>> -------------------------------------
>>>>>
>>>>> Thanks Enrico,
>>>>>
>>>>> However I seem to have inadvertently solved it. I was updating to the
>>>>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>>>>> works.
>>>>> Previously I was using 1.3.1.
>>>>> So there we go.
>>>>>
>>>>> Cheers
>>>>> Mark
>>>>>
>>>>> Enrico Giurin wrote:
>>>>>  
>>>>>         
>>>>>> Hello,
>>>>>> I guess yours is a problem of security manager of tomcat.
>>>>>> I think you have to modify some entries of the catalina.policy file.
>>>>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>>>
>>>>>>
>>>>>> Enrico.
>>>>>>
>>>>>> ----- Original Message ----- From: "Mark HB"
>>>>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>>>>> Subject: Executing binary from Servlet
>>>>>>
>>>>>>
>>>>>>    
>>>>>>           
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am looking for some help on a problem I have encountered with
>>>>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>>>>
>>>>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>>>>> try {
>>>>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>>>>> }
>>>>>>> catch (IOException e)
>>>>>>> { e.printStackTrace(); }
>>>>>>>
>>>>>>> The error that is produced is:
>>>>>>> java.io.IOException: java.io.IOException:
>>>>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>>>>> cannot execute
>>>>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>>>>
>>>>>>> A uname -a on the system gives:
>>>>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>>>>> x86_64 x86_64 GNU/Linux
>>>>>>> SUSE LINUX 10.1
>>>>>>>
>>>>>>> I have ensured that the permissions are set to at least 755 and am now
>>>>>>> at a bit of a loss.
>>>>>>> Any ideas?
>>>>>>>
>>>>>>> Cheers
>>>>>>> Mark
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> --------------------------------------------------------------------------- 
>>>>>>>
>>>>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>>>>> Research Associate                      |
>>>>>>> Room 359                                | Fax: +44-20-7631-6803
>>>>>>> School of Crystallography               |
>>>>>>> Birkbeck College                        | Email:
>>>>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>>>>> UK                                      |
>>>>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>>>>> --------------------------------------------------------------------------- 
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> No virus found in this incoming message.
>>>>>>> Checked by AVG Free Edition.
>>>>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>>>>> 11/09/2006
>>>>>>>
>>>>>>>
>>>>>>>       
>>>>>>>             
>>>>>>    
>>>>>>            ___________________________________ Yahoo! Mail: gratis 
>>>>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>     
>>>>>>           
>>>>>   
>>>>>         
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>       
>>> -- 
>>> ---------------------------------------------------------------------------
>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>> Research Associate                      |
>>> Room 359                                | Fax: +44-20-7631-6803
>>> School of Crystallography               |
>>> Birkbeck College                        | Email:
>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>> London WC1E 7HX                         | markyhb@gmail.com
>>> UK                                      |
>>>               http://people.cryst.bbk.ac.uk/~ghall04                    
>>> ---------------------------------------------------------------------------
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>     
>> >
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Executing binary from Servlet

Posted by Santosh Puranshettiwar <sa...@wirkle.com>.
 >Specifically its been my experience that if you DONT have Security 
permissions specifically >configured for that jar then the >classes will 
not run
Is it applicable to only to jars or to any webapp deployed in Tomcat as 
such. I've managed to use exec() successfully on some programs 
successfully without ever touching the security manager.

For Mark HB:
Could it be a ownership/group problem?

Santosh.
Martin Gainty wrote:
> Mark-
> My experience has been radically different than Davids
>
> Specifically its been my experience that if you DONT have Security permissions specifically configured for that jar then the classes will not run
> here is an example from catalina.policy
>
> grant codeBase "file:${catalina.home}/bin/bootstrap.jar" 
> {
>  permission java.lang.RuntimePermission "getenv.CATALINA_HOME";
>  permission java.lang.RuntimePermission "setenv.CATALINA_HOME";
>  permission java.util.PropertyPermission "catalina.home", "read,write";
>         permission java.security.AllPermission;
> };
> You have to run with security manager in order to have the policy read and interpreted correctly
>
> I would suggest you run in debug so you can display what is going on
> i.e.
> sh catalina.sh -debug -security
>   
>> run org.apache.catalina.startup.Bootstrap
>>     
>
> M-
> *********************************************************************
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
>
>
>
> ----- Original Message ----- 
> From: "Mark HB" <m....@mail.cryst.bbk.ac.uk>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Tuesday, September 12, 2006 8:27 AM
> Subject: Re: Executing binary from Servlet
>
>
>   
>> HI,
>> It all runs fine as a standalone, and when I print the command that I am 
>> running using exec to the screen and then run it myself, it works fine.
>> I had this servlet deployed on another machine, and I never had this 
>> problem.
>> It is very odd, as sometimes it works and the executable is executed and 
>> the results are returned, and other times it returns the same error as 
>> before.
>> There doesn't seem to be any pattern as to when they work.
>> I have changed the policy file, to no affect
>>
>> java.io.IOException: java.io.IOException:
>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>> cannot execute
>>       at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>       at java.lang.Runtime.execInternal(Native Method)
>>       at java.lang.Runtime.exec(Runtime.java:566)
>>       at java.lang.Runtime.exec(Runtime.java:428)
>>       at RunSimulation.run(CimmSimServlet.java:655)
>>
>> I am looking into deploying the servlet in the J2EE app server instead 
>> and seeing if that avoids this problem.
>> Its all very odd!
>> Thanks
>> Mark
>>
>> Santosh Puranshettiwar wrote:
>>     
>>> I agree with David. This does not seem to be a SecurityManager 
>>> problem. Does your code run properly as a normal executable program 
>>> (with main())?
>>>
>>> Sameer Acharya wrote:
>>>       
>>>> Have you tried adding following to your web app permissions in policy 
>>>> file
>>>>
>>>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>>>
>>>> -Sameer
>>>>
>>>>
>>>>
>>>> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,
>>>>
>>>> My apologies for the confusion, but my previous claim to have sorted 
>>>> this problem out is now incorrect. It seems with the upgrade to 
>>>> 1.5.0, the execution of the external binary does work, --- but only 
>>>> sometimes?? ---. I can't seem to work out the exact conditions that 
>>>> it works, and seems to be random.
>>>>
>>>>
>>>> Could someone please indicate what I need to add/change in the 
>>>> catalina.policy file to allow the execution of external binaries. 
>>>> I've had a good look at this url and can't seem to find any indicators.
>>>>
>>>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>
>>>> Cheers
>>>> Mark
>>>>
>>>>
>>>> -------------------------------------
>>>>
>>>> Thanks Enrico,
>>>>
>>>> However I seem to have inadvertently solved it. I was updating to the
>>>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>>>> works.
>>>> Previously I was using 1.3.1.
>>>> So there we go.
>>>>
>>>> Cheers
>>>> Mark
>>>>
>>>> Enrico Giurin wrote:
>>>>  
>>>>         
>>>>> Hello,
>>>>> I guess yours is a problem of security manager of tomcat.
>>>>> I think you have to modify some entries of the catalina.policy file.
>>>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>>
>>>>>
>>>>> Enrico.
>>>>>
>>>>> ----- Original Message ----- From: "Mark HB"
>>>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>>>> Subject: Executing binary from Servlet
>>>>>
>>>>>
>>>>>    
>>>>>           
>>>>>> Hi,
>>>>>>
>>>>>> I am looking for some help on a problem I have encountered with
>>>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>>>
>>>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>>>> try {
>>>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>>>> }
>>>>>> catch (IOException e)
>>>>>> { e.printStackTrace(); }
>>>>>>
>>>>>> The error that is produced is:
>>>>>> java.io.IOException: java.io.IOException:
>>>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>>>> cannot execute
>>>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>>>
>>>>>> A uname -a on the system gives:
>>>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>>>> x86_64 x86_64 GNU/Linux
>>>>>> SUSE LINUX 10.1
>>>>>>
>>>>>> I have ensured that the permissions are set to at least 755 and am now
>>>>>> at a bit of a loss.
>>>>>> Any ideas?
>>>>>>
>>>>>> Cheers
>>>>>> Mark
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> --------------------------------------------------------------------------- 
>>>>>>
>>>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>>>> Research Associate                      |
>>>>>> Room 359                                | Fax: +44-20-7631-6803
>>>>>> School of Crystallography               |
>>>>>> Birkbeck College                        | Email:
>>>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>>>> UK                                      |
>>>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>>>> --------------------------------------------------------------------------- 
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> No virus found in this incoming message.
>>>>>> Checked by AVG Free Edition.
>>>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>>>> 11/09/2006
>>>>>>
>>>>>>
>>>>>>       
>>>>>>             
>>>>>    
>>>>>            ___________________________________ Yahoo! Mail: gratis 
>>>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>     
>>>>>           
>>>>   
>>>>         
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>       
>> -- 
>> ---------------------------------------------------------------------------
>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>> Research Associate                      |
>> Room 359                                | Fax: +44-20-7631-6803
>> School of Crystallography               |
>> Birkbeck College                        | Email:
>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>> London WC1E 7HX                         | markyhb@gmail.com
>> UK                                      |
>>               http://people.cryst.bbk.ac.uk/~ghall04                    
>> ---------------------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>     
> >


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Martin Gainty <mg...@hotmail.com>.
Mark-
My experience has been radically different than Davids

Specifically its been my experience that if you DONT have Security permissions specifically configured for that jar then the classes will not run
here is an example from catalina.policy

grant codeBase "file:${catalina.home}/bin/bootstrap.jar" 
{
 permission java.lang.RuntimePermission "getenv.CATALINA_HOME";
 permission java.lang.RuntimePermission "setenv.CATALINA_HOME";
 permission java.util.PropertyPermission "catalina.home", "read,write";
        permission java.security.AllPermission;
};
You have to run with security manager in order to have the policy read and interpreted correctly

I would suggest you run in debug so you can display what is going on
i.e.
sh catalina.sh -debug -security
>run org.apache.catalina.startup.Bootstrap

M-
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Mark HB" <m....@mail.cryst.bbk.ac.uk>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, September 12, 2006 8:27 AM
Subject: Re: Executing binary from Servlet


> HI,
> It all runs fine as a standalone, and when I print the command that I am 
> running using exec to the screen and then run it myself, it works fine.
> I had this servlet deployed on another machine, and I never had this 
> problem.
> It is very odd, as sometimes it works and the executable is executed and 
> the results are returned, and other times it returns the same error as 
> before.
> There doesn't seem to be any pattern as to when they work.
> I have changed the policy file, to no affect
> 
> java.io.IOException: java.io.IOException:
> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
> cannot execute
>       at java.lang.UNIXProcess.(UNIXProcess.java:143)
>       at java.lang.Runtime.execInternal(Native Method)
>       at java.lang.Runtime.exec(Runtime.java:566)
>       at java.lang.Runtime.exec(Runtime.java:428)
>       at RunSimulation.run(CimmSimServlet.java:655)
> 
> I am looking into deploying the servlet in the J2EE app server instead 
> and seeing if that avoids this problem.
> Its all very odd!
> Thanks
> Mark
> 
> Santosh Puranshettiwar wrote:
>> I agree with David. This does not seem to be a SecurityManager 
>> problem. Does your code run properly as a normal executable program 
>> (with main())?
>>
>> Sameer Acharya wrote:
>>> Have you tried adding following to your web app permissions in policy 
>>> file
>>>
>>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>>
>>> -Sameer
>>>
>>>
>>>
>>> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,
>>>
>>> My apologies for the confusion, but my previous claim to have sorted 
>>> this problem out is now incorrect. It seems with the upgrade to 
>>> 1.5.0, the execution of the external binary does work, --- but only 
>>> sometimes?? ---. I can't seem to work out the exact conditions that 
>>> it works, and seems to be random.
>>>
>>>
>>> Could someone please indicate what I need to add/change in the 
>>> catalina.policy file to allow the execution of external binaries. 
>>> I've had a good look at this url and can't seem to find any indicators.
>>>
>>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>
>>> Cheers
>>> Mark
>>>
>>>
>>> -------------------------------------
>>>
>>> Thanks Enrico,
>>>
>>> However I seem to have inadvertently solved it. I was updating to the
>>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>>> works.
>>> Previously I was using 1.3.1.
>>> So there we go.
>>>
>>> Cheers
>>> Mark
>>>
>>> Enrico Giurin wrote:
>>>  
>>>> Hello,
>>>> I guess yours is a problem of security manager of tomcat.
>>>> I think you have to modify some entries of the catalina.policy file.
>>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>
>>>>
>>>> Enrico.
>>>>
>>>> ----- Original Message ----- From: "Mark HB"
>>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>>> Subject: Executing binary from Servlet
>>>>
>>>>
>>>>    
>>>>> Hi,
>>>>>
>>>>> I am looking for some help on a problem I have encountered with
>>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>>
>>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>>> try {
>>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>>> }
>>>>> catch (IOException e)
>>>>> { e.printStackTrace(); }
>>>>>
>>>>> The error that is produced is:
>>>>> java.io.IOException: java.io.IOException:
>>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>>> cannot execute
>>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>>
>>>>> A uname -a on the system gives:
>>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>>> x86_64 x86_64 GNU/Linux
>>>>> SUSE LINUX 10.1
>>>>>
>>>>> I have ensured that the permissions are set to at least 755 and am now
>>>>> at a bit of a loss.
>>>>> Any ideas?
>>>>>
>>>>> Cheers
>>>>> Mark
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>>> Research Associate                      |
>>>>> Room 359                                | Fax: +44-20-7631-6803
>>>>> School of Crystallography               |
>>>>> Birkbeck College                        | Email:
>>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>>> UK                                      |
>>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>>> 11/09/2006
>>>>>
>>>>>
>>>>>       
>>>>    
>>>>            ___________________________________ Yahoo! Mail: gratis 
>>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>     
>>>
>>>
>>>   
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> -- 
> ---------------------------------------------------------------------------
> Mark Halling-Brown                      | Tel: +44-20-7631-6839
> Research Associate                      |
> Room 359                                | Fax: +44-20-7631-6803
> School of Crystallography               |
> Birkbeck College                        | Email:
> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
> London WC1E 7HX                         | markyhb@gmail.com
> UK                                      |
>               http://people.cryst.bbk.ac.uk/~ghall04                    
> ---------------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Executing binary from Servlet

Posted by William Bonnet <wi...@wbonnet.net>.
Hi

> Tomcat is started using the startup.sh script provided and it runs using
> a specific tomcat account which has admin type rights.
> I am beginning to wonder what sort of problem this may be, as I must
> emphasise that:
> The runtime.exec() DOES work sometimes, and not others. There does not
> seem to be a pattern to when it works.
> Literally, I can click on the link and it will work, then click back and
> click on the link again, and it won't work!

Have you tried to run startup.sh from a root shell ? does it work ?
Have you check that catalina.sh is executable ?
Have you tried to run catalina.sh from a root shell ? does it work ?

Have you check that you linux partition is *not* mounted with the -noexec flag ?

Regards,
William

-- 
William                  http://www.wbonnet.net

http://www.sunwizard.net Le site français des amateurs de stations Unix
http://www.blastwave.org An OpenSolaris Community Site
http://www.guses.org     French speaking Solaris User Group

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Sameer Acharya <ac...@yahoo.com>.
>From your directory path mentioned it looks like this is a work folder

/srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:

Is it possible that your dir/file is not available at some point
in time when servlet is executing ?

Have you tried executing a process from some fixed directory 
location instead  ??
-Sameer

Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Tomcat is started using the startup.sh script provided and it runs using 
a specific tomcat account which has admin type rights.
I am beginning to wonder what sort of problem this may be, as I must 
emphasise that:
The runtime.exec() DOES work sometimes, and not others. There does not 
seem to be a pattern to when it works.
Literally, I can click on the link and it will work, then click back and 
click on the link again, and it won't work!

Because of this, I am trying to rack my brains as to what might cause 
this runtime.exec() to throw a "cannot execute" error sometimes, but not 
others.
It seems possible that it is not an error with Tomcat, as otherwise why 
would it not be consistently failing?
Cheers
Mark


Sameer Acharya wrote:
> Doesent look like a SecurityManager issue cos that would have resulted in a SecurityException. Just glanced thru the exec api doc and found this
>
> Starting an operating system process is highly system-dependent. Among the  many things that can go wrong are:  
>
> The operating system program file was not found.  
> Access to the program file was denied. 
> The working directory does not exist. 
>
> You will get an IOException if any of these happen.
>
>  How do you start the tomcat and under what id does it run ??
>
> -Sameer
>
>
> Mark HB  wrote: HI,
> It all runs fine as a standalone, and when I print the command that I am 
> running using exec to the screen and then run it myself, it works fine.
> I had this servlet deployed on another machine, and I never had this 
> problem.
> It is very odd, as sometimes it works and the executable is executed and 
> the results are returned, and other times it returns the same error as 
> before.
> There doesn't seem to be any pattern as to when they work.
> I have changed the policy file, to no affect
>
> java.io.IOException: java.io.IOException:
> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
> cannot execute
>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>        at java.lang.Runtime.execInternal(Native Method)
>        at java.lang.Runtime.exec(Runtime.java:566)
>        at java.lang.Runtime.exec(Runtime.java:428)
>        at RunSimulation.run(CimmSimServlet.java:655)
>
> I am looking into deploying the servlet in the J2EE app server instead 
> and seeing if that avoids this problem.
> Its all very odd!
> Thanks
> Mark
>
> Santosh Puranshettiwar wrote:
>   
>> I agree with David. This does not seem to be a SecurityManager 
>> problem. Does your code run properly as a normal executable program 
>> (with main())?
>>
>> Sameer Acharya wrote:
>>     
>>> Have you tried adding following to your web app permissions in policy 
>>> file
>>>
>>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>>
>>> -Sameer
>>>
>>>
>>>
>>> Mark HB  wrote: Hi,
>>>
>>> My apologies for the confusion, but my previous claim to have sorted 
>>> this problem out is now incorrect. It seems with the upgrade to 
>>> 1.5.0, the execution of the external binary does work, --- but only 
>>> sometimes?? ---. I can't seem to work out the exact conditions that 
>>> it works, and seems to be random.
>>>
>>>
>>> Could someone please indicate what I need to add/change in the 
>>> catalina.policy file to allow the execution of external binaries. 
>>> I've had a good look at this url and can't seem to find any indicators.
>>>
>>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>
>>> Cheers
>>> Mark
>>>
>>>
>>> -------------------------------------
>>>
>>> Thanks Enrico,
>>>
>>> However I seem to have inadvertently solved it. I was updating to the
>>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>>> works.
>>> Previously I was using 1.3.1.
>>> So there we go.
>>>
>>> Cheers
>>> Mark
>>>
>>> Enrico Giurin wrote:
>>>  
>>>       
>>>> Hello,
>>>> I guess yours is a problem of security manager of tomcat.
>>>> I think you have to modify some entries of the catalina.policy file.
>>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>
>>>>
>>>> Enrico.
>>>>
>>>> ----- Original Message ----- From: "Mark HB"
>>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>>> Subject: Executing binary from Servlet
>>>>
>>>>
>>>>    
>>>>         
>>>>> Hi,
>>>>>
>>>>> I am looking for some help on a problem I have encountered with
>>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>>
>>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>>> try {
>>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>>> }
>>>>> catch (IOException e)
>>>>> { e.printStackTrace(); }
>>>>>
>>>>> The error that is produced is:
>>>>> java.io.IOException: java.io.IOException:
>>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>>> cannot execute
>>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>>
>>>>> A uname -a on the system gives:
>>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>>> x86_64 x86_64 GNU/Linux
>>>>> SUSE LINUX 10.1
>>>>>
>>>>> I have ensured that the permissions are set to at least 755 and am now
>>>>> at a bit of a loss.
>>>>> Any ideas?
>>>>>
>>>>> Cheers
>>>>> Mark
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>>> Research Associate                      |
>>>>> Room 359                                | Fax: +44-20-7631-6803
>>>>> School of Crystallography               |
>>>>> Birkbeck College                        | Email:
>>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>>> UK                                      |
>>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>>> 11/09/2006
>>>>>
>>>>>
>>>>>       
>>>>>           
>>>>    
>>>>            ___________________________________ Yahoo! Mail: gratis 
>>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>     
>>>>         
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>     
>
>
>   


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04                    
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 			
---------------------------------
Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.

Re: Executing binary from Servlet

Posted by Mark HB <m....@mail.cryst.bbk.ac.uk>.
Tomcat is started using the startup.sh script provided and it runs using 
a specific tomcat account which has admin type rights.
I am beginning to wonder what sort of problem this may be, as I must 
emphasise that:
The runtime.exec() DOES work sometimes, and not others. There does not 
seem to be a pattern to when it works.
Literally, I can click on the link and it will work, then click back and 
click on the link again, and it won't work!

Because of this, I am trying to rack my brains as to what might cause 
this runtime.exec() to throw a "cannot execute" error sometimes, but not 
others.
It seems possible that it is not an error with Tomcat, as otherwise why 
would it not be consistently failing?
Cheers
Mark


Sameer Acharya wrote:
> Doesent look like a SecurityManager issue cos that would have resulted in a SecurityException. Just glanced thru the exec api doc and found this
>
> Starting an operating system process is highly system-dependent. Among the  many things that can go wrong are:  
>
> The operating system program file was not found.  
> Access to the program file was denied. 
> The working directory does not exist. 
>
> You will get an IOException if any of these happen.
>
>  How do you start the tomcat and under what id does it run ??
>
> -Sameer
>
>
> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: HI,
> It all runs fine as a standalone, and when I print the command that I am 
> running using exec to the screen and then run it myself, it works fine.
> I had this servlet deployed on another machine, and I never had this 
> problem.
> It is very odd, as sometimes it works and the executable is executed and 
> the results are returned, and other times it returns the same error as 
> before.
> There doesn't seem to be any pattern as to when they work.
> I have changed the policy file, to no affect
>
> java.io.IOException: java.io.IOException:
> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
> cannot execute
>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>        at java.lang.Runtime.execInternal(Native Method)
>        at java.lang.Runtime.exec(Runtime.java:566)
>        at java.lang.Runtime.exec(Runtime.java:428)
>        at RunSimulation.run(CimmSimServlet.java:655)
>
> I am looking into deploying the servlet in the J2EE app server instead 
> and seeing if that avoids this problem.
> Its all very odd!
> Thanks
> Mark
>
> Santosh Puranshettiwar wrote:
>   
>> I agree with David. This does not seem to be a SecurityManager 
>> problem. Does your code run properly as a normal executable program 
>> (with main())?
>>
>> Sameer Acharya wrote:
>>     
>>> Have you tried adding following to your web app permissions in policy 
>>> file
>>>
>>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>>
>>> -Sameer
>>>
>>>
>>>
>>> Mark HB  wrote: Hi,
>>>
>>> My apologies for the confusion, but my previous claim to have sorted 
>>> this problem out is now incorrect. It seems with the upgrade to 
>>> 1.5.0, the execution of the external binary does work, --- but only 
>>> sometimes?? ---. I can't seem to work out the exact conditions that 
>>> it works, and seems to be random.
>>>
>>>
>>> Could someone please indicate what I need to add/change in the 
>>> catalina.policy file to allow the execution of external binaries. 
>>> I've had a good look at this url and can't seem to find any indicators.
>>>
>>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>
>>> Cheers
>>> Mark
>>>
>>>
>>> -------------------------------------
>>>
>>> Thanks Enrico,
>>>
>>> However I seem to have inadvertently solved it. I was updating to the
>>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>>> works.
>>> Previously I was using 1.3.1.
>>> So there we go.
>>>
>>> Cheers
>>> Mark
>>>
>>> Enrico Giurin wrote:
>>>  
>>>       
>>>> Hello,
>>>> I guess yours is a problem of security manager of tomcat.
>>>> I think you have to modify some entries of the catalina.policy file.
>>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>>
>>>>
>>>> Enrico.
>>>>
>>>> ----- Original Message ----- From: "Mark HB"
>>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>>> Subject: Executing binary from Servlet
>>>>
>>>>
>>>>    
>>>>         
>>>>> Hi,
>>>>>
>>>>> I am looking for some help on a problem I have encountered with
>>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>>
>>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>>> try {
>>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>>> }
>>>>> catch (IOException e)
>>>>> { e.printStackTrace(); }
>>>>>
>>>>> The error that is produced is:
>>>>> java.io.IOException: java.io.IOException:
>>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>>> cannot execute
>>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>>
>>>>> A uname -a on the system gives:
>>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>>> x86_64 x86_64 GNU/Linux
>>>>> SUSE LINUX 10.1
>>>>>
>>>>> I have ensured that the permissions are set to at least 755 and am now
>>>>> at a bit of a loss.
>>>>> Any ideas?
>>>>>
>>>>> Cheers
>>>>> Mark
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>>> Research Associate                      |
>>>>> Room 359                                | Fax: +44-20-7631-6803
>>>>> School of Crystallography               |
>>>>> Birkbeck College                        | Email:
>>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>>> UK                                      |
>>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>>> --------------------------------------------------------------------------- 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> No virus found in this incoming message.
>>>>> Checked by AVG Free Edition.
>>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>>> 11/09/2006
>>>>>
>>>>>
>>>>>       
>>>>>           
>>>>    
>>>>            ___________________________________ Yahoo! Mail: gratis 
>>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>     
>>>>         
>>>   
>>>       
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>     
>
>
>   


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04                    
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Sameer Acharya <ac...@yahoo.com>.
Doesent look like a SecurityManager issue cos that would have resulted in a SecurityException. Just glanced thru the exec api doc and found this

Starting an operating system process is highly system-dependent. Among the  many things that can go wrong are:  

The operating system program file was not found.  
Access to the program file was denied. 
The working directory does not exist. 

You will get an IOException if any of these happen.

 How do you start the tomcat and under what id does it run ??

-Sameer


Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: HI,
It all runs fine as a standalone, and when I print the command that I am 
running using exec to the screen and then run it myself, it works fine.
I had this servlet deployed on another machine, and I never had this 
problem.
It is very odd, as sometimes it works and the executable is executed and 
the results are returned, and other times it returns the same error as 
before.
There doesn't seem to be any pattern as to when they work.
I have changed the policy file, to no affect

java.io.IOException: java.io.IOException:
/srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
cannot execute
       at java.lang.UNIXProcess.(UNIXProcess.java:143)
       at java.lang.Runtime.execInternal(Native Method)
       at java.lang.Runtime.exec(Runtime.java:566)
       at java.lang.Runtime.exec(Runtime.java:428)
       at RunSimulation.run(CimmSimServlet.java:655)

I am looking into deploying the servlet in the J2EE app server instead 
and seeing if that avoids this problem.
Its all very odd!
Thanks
Mark

Santosh Puranshettiwar wrote:
> I agree with David. This does not seem to be a SecurityManager 
> problem. Does your code run properly as a normal executable program 
> (with main())?
>
> Sameer Acharya wrote:
>> Have you tried adding following to your web app permissions in policy 
>> file
>>
>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>
>> -Sameer
>>
>>
>>
>> Mark HB  wrote: Hi,
>>
>> My apologies for the confusion, but my previous claim to have sorted 
>> this problem out is now incorrect. It seems with the upgrade to 
>> 1.5.0, the execution of the external binary does work, --- but only 
>> sometimes?? ---. I can't seem to work out the exact conditions that 
>> it works, and seems to be random.
>>
>>
>> Could someone please indicate what I need to add/change in the 
>> catalina.policy file to allow the execution of external binaries. 
>> I've had a good look at this url and can't seem to find any indicators.
>>
>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>
>> Cheers
>> Mark
>>
>>
>> -------------------------------------
>>
>> Thanks Enrico,
>>
>> However I seem to have inadvertently solved it. I was updating to the
>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>> works.
>> Previously I was using 1.3.1.
>> So there we go.
>>
>> Cheers
>> Mark
>>
>> Enrico Giurin wrote:
>>  
>>> Hello,
>>> I guess yours is a problem of security manager of tomcat.
>>> I think you have to modify some entries of the catalina.policy file.
>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>
>>>
>>> Enrico.
>>>
>>> ----- Original Message ----- From: "Mark HB"
>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>> Subject: Executing binary from Servlet
>>>
>>>
>>>    
>>>> Hi,
>>>>
>>>> I am looking for some help on a problem I have encountered with
>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>
>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>> try {
>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>> }
>>>> catch (IOException e)
>>>> { e.printStackTrace(); }
>>>>
>>>> The error that is produced is:
>>>> java.io.IOException: java.io.IOException:
>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>> cannot execute
>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>
>>>> A uname -a on the system gives:
>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>> x86_64 x86_64 GNU/Linux
>>>> SUSE LINUX 10.1
>>>>
>>>> I have ensured that the permissions are set to at least 755 and am now
>>>> at a bit of a loss.
>>>> Any ideas?
>>>>
>>>> Cheers
>>>> Mark
>>>>
>>>>
>>>>
>>>> -- 
>>>> --------------------------------------------------------------------------- 
>>>>
>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>> Research Associate                      |
>>>> Room 359                                | Fax: +44-20-7631-6803
>>>> School of Crystallography               |
>>>> Birkbeck College                        | Email:
>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>> UK                                      |
>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>> --------------------------------------------------------------------------- 
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>> -- 
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>> 11/09/2006
>>>>
>>>>
>>>>       
>>>    
>>>            ___________________________________ Yahoo! Mail: gratis 
>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>     
>>
>>
>>   
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04                    
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 		
---------------------------------
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail.

Re: Executing binary from Servlet

Posted by Mark HB <m....@mail.cryst.bbk.ac.uk>.
HI,
It all runs fine as a standalone, and when I print the command that I am 
running using exec to the screen and then run it myself, it works fine.
I had this servlet deployed on another machine, and I never had this 
problem.
It is very odd, as sometimes it works and the executable is executed and 
the results are returned, and other times it returns the same error as 
before.
There doesn't seem to be any pattern as to when they work.
I have changed the policy file, to no affect

java.io.IOException: java.io.IOException:
/srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
cannot execute
       at java.lang.UNIXProcess.(UNIXProcess.java:143)
       at java.lang.Runtime.execInternal(Native Method)
       at java.lang.Runtime.exec(Runtime.java:566)
       at java.lang.Runtime.exec(Runtime.java:428)
       at RunSimulation.run(CimmSimServlet.java:655)

I am looking into deploying the servlet in the J2EE app server instead 
and seeing if that avoids this problem.
Its all very odd!
Thanks
Mark

Santosh Puranshettiwar wrote:
> I agree with David. This does not seem to be a SecurityManager 
> problem. Does your code run properly as a normal executable program 
> (with main())?
>
> Sameer Acharya wrote:
>> Have you tried adding following to your web app permissions in policy 
>> file
>>
>> permission java.lang.RuntimePermission "java.lang.Runtime";
>>
>> -Sameer
>>
>>
>>
>> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,
>>
>> My apologies for the confusion, but my previous claim to have sorted 
>> this problem out is now incorrect. It seems with the upgrade to 
>> 1.5.0, the execution of the external binary does work, --- but only 
>> sometimes?? ---. I can't seem to work out the exact conditions that 
>> it works, and seems to be random.
>>
>>
>> Could someone please indicate what I need to add/change in the 
>> catalina.policy file to allow the execution of external binaries. 
>> I've had a good look at this url and can't seem to find any indicators.
>>
>>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>
>> Cheers
>> Mark
>>
>>
>> -------------------------------------
>>
>> Thanks Enrico,
>>
>> However I seem to have inadvertently solved it. I was updating to the
>> latest release of jre and recompiled the servlet with 1.5.0 and now it
>> works.
>> Previously I was using 1.3.1.
>> So there we go.
>>
>> Cheers
>> Mark
>>
>> Enrico Giurin wrote:
>>  
>>> Hello,
>>> I guess yours is a problem of security manager of tomcat.
>>> I think you have to modify some entries of the catalina.policy file.
>>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>>
>>>
>>> Enrico.
>>>
>>> ----- Original Message ----- From: "Mark HB"
>>> To: Sent: Tuesday, September 12, 2006 10:16 AM
>>> Subject: Executing binary from Servlet
>>>
>>>
>>>    
>>>> Hi,
>>>>
>>>> I am looking for some help on a problem I have encountered with
>>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>>> The code that I have is simply executing a binary called "cimmsim":
>>>>
>>>> File theDir = new File(curdir+"WORK/"+rand);
>>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>>> try {
>>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>>> }
>>>> catch (IOException e)
>>>> { e.printStackTrace(); }
>>>>
>>>> The error that is produced is:
>>>> java.io.IOException: java.io.IOException:
>>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>>> cannot execute
>>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>>        at java.lang.Runtime.execInternal(Native Method)
>>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>>
>>>> A uname -a on the system gives:
>>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>>> x86_64 x86_64 GNU/Linux
>>>> SUSE LINUX 10.1
>>>>
>>>> I have ensured that the permissions are set to at least 755 and am now
>>>> at a bit of a loss.
>>>> Any ideas?
>>>>
>>>> Cheers
>>>> Mark
>>>>
>>>>
>>>>
>>>> -- 
>>>> --------------------------------------------------------------------------- 
>>>>
>>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>>> Research Associate                      |
>>>> Room 359                                | Fax: +44-20-7631-6803
>>>> School of Crystallography               |
>>>> Birkbeck College                        | Email:
>>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>>> London WC1E 7HX                         | markyhb@gmail.com
>>>> UK                                      |
>>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>>> --------------------------------------------------------------------------- 
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>> -- 
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>>> 11/09/2006
>>>>
>>>>
>>>>       
>>>    
>>>            ___________________________________ Yahoo! Mail: gratis 
>>> 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>     
>>
>>
>>   
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04                    
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Santosh Puranshettiwar <sa...@wirkle.com>.
I agree with David. This does not seem to be a SecurityManager problem. 
Does your code run properly as a normal executable program (with main())?

Sameer Acharya wrote:
> Have you tried adding following to your web app permissions in policy file
>
> permission java.lang.RuntimePermission "java.lang.Runtime";
>
> -Sameer
>
>
>
> Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,
>
> My apologies for the confusion, but my previous claim to have sorted 
> this problem out is now incorrect. It seems with the upgrade to 1.5.0, 
> the execution of the external binary does work, --- but only sometimes?? 
> ---. I can't seem to work out the exact conditions that it works, and 
> seems to be random.
>
>
> Could someone please indicate what I need to add/change in the 
> catalina.policy file to allow the execution of external binaries. I've 
> had a good look at this url and can't seem to find any indicators.
>
>  > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>
> Cheers
> Mark
>
>
> -------------------------------------
>
> Thanks Enrico,
>
> However I seem to have inadvertently solved it. I was updating to the
> latest release of jre and recompiled the servlet with 1.5.0 and now it
> works.
> Previously I was using 1.3.1.
> So there we go.
>
> Cheers
> Mark
>
> Enrico Giurin wrote:
>   
>> Hello,
>> I guess yours is a problem of security manager of tomcat.
>> I think you have to modify some entries of the catalina.policy file.
>> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>>
>>
>> Enrico.
>>
>> ----- Original Message ----- From: "Mark HB" 
>>
>> To: 
>> Sent: Tuesday, September 12, 2006 10:16 AM
>> Subject: Executing binary from Servlet
>>
>>
>>     
>>> Hi,
>>>
>>> I am looking for some help on a problem I have encountered with
>>> executing a binary from a servlet using Runtime.getRuntime().exec()
>>> The code that I have is simply executing a binary called "cimmsim":
>>>
>>> File theDir = new File(curdir+"WORK/"+rand);
>>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>>> try {
>>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>>> }
>>> catch (IOException e)
>>> { e.printStackTrace(); }
>>>
>>> The error that is produced is:
>>> java.io.IOException: java.io.IOException:
>>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>>> cannot execute
>>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>>        at java.lang.Runtime.execInternal(Native Method)
>>>        at java.lang.Runtime.exec(Runtime.java:566)
>>>        at java.lang.Runtime.exec(Runtime.java:428)
>>>        at RunSimulation.run(CimmSimServlet.java:655)
>>>
>>> A uname -a on the system gives:
>>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>>> x86_64 x86_64 GNU/Linux
>>> SUSE LINUX 10.1
>>>
>>> I have ensured that the permissions are set to at least 755 and am now
>>> at a bit of a loss.
>>> Any ideas?
>>>
>>> Cheers
>>> Mark
>>>
>>>
>>>
>>> -- 
>>> --------------------------------------------------------------------------- 
>>>
>>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>>> Research Associate                      |
>>> Room 359                                | Fax: +44-20-7631-6803
>>> School of Crystallography               |
>>> Birkbeck College                        | Email:
>>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>>> London WC1E 7HX                         | markyhb@gmail.com
>>> UK                                      |
>>>               http://people.cryst.bbk.ac.uk/~ghall04
>>> --------------------------------------------------------------------------- 
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>> -- 
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>>> 11/09/2006
>>>
>>>
>>>       
>>     
>>
>>     
>>        
>> ___________________________________ Yahoo! Mail: gratis 1GB per i 
>> messaggi e allegati da 10MB http://mail.yahoo.it
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>     
>
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Sameer Acharya <ac...@yahoo.com>.
Have you tried adding following to your web app permissions in policy file

permission java.lang.RuntimePermission "java.lang.Runtime";

-Sameer



Mark HB <m....@mail.cryst.bbk.ac.uk> wrote: Hi,

My apologies for the confusion, but my previous claim to have sorted 
this problem out is now incorrect. It seems with the upgrade to 1.5.0, 
the execution of the external binary does work, --- but only sometimes?? 
---. I can't seem to work out the exact conditions that it works, and 
seems to be random.


Could someone please indicate what I need to add/change in the 
catalina.policy file to allow the execution of external binaries. I've 
had a good look at this url and can't seem to find any indicators.

 > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html

Cheers
Mark


-------------------------------------

Thanks Enrico,

However I seem to have inadvertently solved it. I was updating to the
latest release of jre and recompiled the servlet with 1.5.0 and now it
works.
Previously I was using 1.3.1.
So there we go.

Cheers
Mark

Enrico Giurin wrote:
> Hello,
> I guess yours is a problem of security manager of tomcat.
> I think you have to modify some entries of the catalina.policy file.
> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>
>
> Enrico.
>
> ----- Original Message ----- From: "Mark HB" 
> 
> To: 
> Sent: Tuesday, September 12, 2006 10:16 AM
> Subject: Executing binary from Servlet
>
>
>> Hi,
>>
>> I am looking for some help on a problem I have encountered with
>> executing a binary from a servlet using Runtime.getRuntime().exec()
>> The code that I have is simply executing a binary called "cimmsim":
>>
>> File theDir = new File(curdir+"WORK/"+rand);
>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>> try {
>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>> }
>> catch (IOException e)
>> { e.printStackTrace(); }
>>
>> The error that is produced is:
>> java.io.IOException: java.io.IOException:
>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>> cannot execute
>>        at java.lang.UNIXProcess.(UNIXProcess.java:143)
>>        at java.lang.Runtime.execInternal(Native Method)
>>        at java.lang.Runtime.exec(Runtime.java:566)
>>        at java.lang.Runtime.exec(Runtime.java:428)
>>        at RunSimulation.run(CimmSimServlet.java:655)
>>
>> A uname -a on the system gives:
>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>> x86_64 x86_64 GNU/Linux
>> SUSE LINUX 10.1
>>
>> I have ensured that the permissions are set to at least 755 and am now
>> at a bit of a loss.
>> Any ideas?
>>
>> Cheers
>> Mark
>>
>>
>>
>> -- 
>> --------------------------------------------------------------------------- 
>>
>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>> Research Associate                      |
>> Room 359                                | Fax: +44-20-7631-6803
>> School of Crystallography               |
>> Birkbeck College                        | Email:
>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>> London WC1E 7HX                         | markyhb@gmail.com
>> UK                                      |
>>               http://people.cryst.bbk.ac.uk/~ghall04
>> --------------------------------------------------------------------------- 
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> -- 
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>> 11/09/2006
>>
>>
>
>
>     
>
>     
>        
> ___________________________________ Yahoo! Mail: gratis 1GB per i 
> messaggi e allegati da 10MB http://mail.yahoo.it
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04
---------------------------------------------------------------------------



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.

Re: Executing binary from Servlet

Posted by Mark HB <m....@mail.cryst.bbk.ac.uk>.
Hi,

My apologies for the confusion, but my previous claim to have sorted 
this problem out is now incorrect. It seems with the upgrade to 1.5.0, 
the execution of the external binary does work, --- but only sometimes?? 
---. I can't seem to work out the exact conditions that it works, and 
seems to be random.


Could someone please indicate what I need to add/change in the 
catalina.policy file to allow the execution of external binaries. I've 
had a good look at this url and can't seem to find any indicators.

 > http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html

Cheers
Mark


-------------------------------------

Thanks Enrico,

However I seem to have inadvertently solved it. I was updating to the
latest release of jre and recompiled the servlet with 1.5.0 and now it
works.
Previously I was using 1.3.1.
So there we go.

Cheers
Mark

Enrico Giurin wrote:
> Hello,
> I guess yours is a problem of security manager of tomcat.
> I think you have to modify some entries of the catalina.policy file.
> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>
>
> Enrico.
>
> ----- Original Message ----- From: "Mark HB" 
> <m....@mail.cryst.bbk.ac.uk>
> To: <us...@tomcat.apache.org>
> Sent: Tuesday, September 12, 2006 10:16 AM
> Subject: Executing binary from Servlet
>
>
>> Hi,
>>
>> I am looking for some help on a problem I have encountered with
>> executing a binary from a servlet using Runtime.getRuntime().exec()
>> The code that I have is simply executing a binary called "cimmsim":
>>
>> File theDir = new File(curdir+"WORK/"+rand);
>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>> try {
>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>> }
>> catch (IOException e)
>> { e.printStackTrace(); }
>>
>> The error that is produced is:
>> java.io.IOException: java.io.IOException:
>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>> cannot execute
>>        at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
>>        at java.lang.Runtime.execInternal(Native Method)
>>        at java.lang.Runtime.exec(Runtime.java:566)
>>        at java.lang.Runtime.exec(Runtime.java:428)
>>        at RunSimulation.run(CimmSimServlet.java:655)
>>
>> A uname -a on the system gives:
>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>> x86_64 x86_64 GNU/Linux
>> SUSE LINUX 10.1
>>
>> I have ensured that the permissions are set to at least 755 and am now
>> at a bit of a loss.
>> Any ideas?
>>
>> Cheers
>> Mark
>>
>>
>>
>> -- 
>> --------------------------------------------------------------------------- 
>>
>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>> Research Associate                      |
>> Room 359                                | Fax: +44-20-7631-6803
>> School of Crystallography               |
>> Birkbeck College                        | Email:
>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>> London WC1E 7HX                         | markyhb@gmail.com
>> UK                                      |
>>               http://people.cryst.bbk.ac.uk/~ghall04
>> --------------------------------------------------------------------------- 
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> -- 
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>> 11/09/2006
>>
>>
>
>
>     
>
>     
>        
> ___________________________________ Yahoo! Mail: gratis 1GB per i 
> messaggi e allegati da 10MB http://mail.yahoo.it
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04
---------------------------------------------------------------------------



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Mark HB <m....@mail.cryst.bbk.ac.uk>.
Thanks Enrico,

However I seem to have inadvertently solved it. I was updating to the 
latest release of jre and recompiled the servlet with 1.5.0 and now it 
works.
Previously I was using 1.3.1.
So there we go.

Cheers
Mark

Enrico Giurin wrote:
> Hello,
> I guess yours is a problem of security manager of tomcat.
> I think you have to modify some entries of the catalina.policy file.
> http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html
>
>
> Enrico.
>
> ----- Original Message ----- From: "Mark HB" 
> <m....@mail.cryst.bbk.ac.uk>
> To: <us...@tomcat.apache.org>
> Sent: Tuesday, September 12, 2006 10:16 AM
> Subject: Executing binary from Servlet
>
>
>> Hi,
>>
>> I am looking for some help on a problem I have encountered with
>> executing a binary from a servlet using Runtime.getRuntime().exec()
>> The code that I have is simply executing a binary called "cimmsim":
>>
>> File theDir = new File(curdir+"WORK/"+rand);
>> java.lang.String cmdline = theDir+"/cimmsim -f config";
>> try {
>> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
>> }
>> catch (IOException e)
>> { e.printStackTrace(); }
>>
>> The error that is produced is:
>> java.io.IOException: java.io.IOException:
>> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
>> cannot execute
>>        at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
>>        at java.lang.Runtime.execInternal(Native Method)
>>        at java.lang.Runtime.exec(Runtime.java:566)
>>        at java.lang.Runtime.exec(Runtime.java:428)
>>        at RunSimulation.run(CimmSimServlet.java:655)
>>
>> A uname -a on the system gives:
>> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
>> x86_64 x86_64 GNU/Linux
>> SUSE LINUX 10.1
>>
>> I have ensured that the permissions are set to at least 755 and am now
>> at a bit of a loss.
>> Any ideas?
>>
>> Cheers
>> Mark
>>
>>
>>
>> -- 
>> --------------------------------------------------------------------------- 
>>
>> Mark Halling-Brown                      | Tel: +44-20-7631-6839
>> Research Associate                      |
>> Room 359                                | Fax: +44-20-7631-6803
>> School of Crystallography               |
>> Birkbeck College                        | Email:
>> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
>> London WC1E 7HX                         | markyhb@gmail.com
>> UK                                      |
>>               http://people.cryst.bbk.ac.uk/~ghall04
>> --------------------------------------------------------------------------- 
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> -- 
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 
>> 11/09/2006
>>
>>
>
>
>     
>
>     
>        
> ___________________________________ Yahoo! Mail: gratis 1GB per i 
> messaggi e allegati da 10MB http://mail.yahoo.it
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


-- 
---------------------------------------------------------------------------
Mark Halling-Brown                      | Tel: +44-20-7631-6839
Research Associate                      |
Room 359                                | Fax: +44-20-7631-6803
School of Crystallography               |
Birkbeck College                        | Email:
Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
London WC1E 7HX                         | markyhb@gmail.com
UK                                      |
               http://people.cryst.bbk.ac.uk/~ghall04                    
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Executing binary from Servlet

Posted by Enrico Giurin <en...@yahoo.it>.
Hello,
I guess yours is a problem of security manager of tomcat.
I think you have to modify some entries of the catalina.policy file.
http://tomcat.apache.org/tomcat-5.0-doc/security-manager-howto.html


Enrico.

----- Original Message ----- 
From: "Mark HB" <m....@mail.cryst.bbk.ac.uk>
To: <us...@tomcat.apache.org>
Sent: Tuesday, September 12, 2006 10:16 AM
Subject: Executing binary from Servlet


> Hi,
>
> I am looking for some help on a problem I have encountered with
> executing a binary from a servlet using Runtime.getRuntime().exec()
> The code that I have is simply executing a binary called "cimmsim":
>
> File theDir = new File(curdir+"WORK/"+rand);
> java.lang.String cmdline = theDir+"/cimmsim -f config";
> try {
> Process p = Runtime.getRuntime().exec(cmdline, null, theDir);
> }
> catch (IOException e)
> { e.printStackTrace(); }
>
> The error that is produced is:
> java.io.IOException: java.io.IOException:
> /srv/www/tomcat5/base/webapps/simulator/WORK/yqzatmopa343/cimmsim:
> cannot execute
>        at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
>        at java.lang.Runtime.execInternal(Native Method)
>        at java.lang.Runtime.exec(Runtime.java:566)
>        at java.lang.Runtime.exec(Runtime.java:428)
>        at RunSimulation.run(CimmSimServlet.java:655)
>
> A uname -a on the system gives:
> Linux apppx1 2.6.16.13-4-xen #1 SMP Wed May 3 04:53:23 UTC 2006 x86_64
> x86_64 x86_64 GNU/Linux
> SUSE LINUX 10.1
>
> I have ensured that the permissions are set to at least 755 and am now
> at a bit of a loss.
> Any ideas?
>
> Cheers
> Mark
>
>
>
> -- 
> ---------------------------------------------------------------------------
> Mark Halling-Brown                      | Tel: +44-20-7631-6839
> Research Associate                      |
> Room 359                                | Fax: +44-20-7631-6803
> School of Crystallography               |
> Birkbeck College                        | Email:
> Malet Street                            | ghall04@mail.cryst.bbk.ac.uk
> London WC1E 7HX                         | markyhb@gmail.com
> UK                                      |
>               http://people.cryst.bbk.ac.uk/~ghall04
> ---------------------------------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.2/443 - Release Date: 11/09/2006
>
> 


	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org