You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christian Riedel <sa...@nurfuerspam.de> on 2004/08/26 10:20:26 UTC

Is struts interfering with Runtime.exec() calls?

Hi all,

some days ago I posted a problem about not being able to do a chmod on
the local file system from withing my webapp via a Runtime.exec() call.
To achieve this I tried the following call:

> "/bin/chmod 660 /home/sarek/test/testfile"

wich did not show any effect. Nor do most of the other calls I tried
which only had other permissions to be set.

Here is a list of my attempts and their results:

new perm	before		after
------------------------------------------
g+rw		-rw-------	-rw-------
u=rw,g=rw	-rw-------	-rw-------
0660		-rw-------	-rw-------
0770		-rw-------	-rw-------
770		-rw-------	-rw-------
777		-rw-------	-rw-------
664		-rw-------	-rw-------

but most suprisingly:

064		-rw-------	----rw-r--

Now the problem is that I need to set the file's permission to
-rw-rw---- which I have not managed to do so far :-(

I thought there was a problem with tomcat and and security issues that
prevents me from doing such things. So I just tried a small test-jsp to
see if this was really the case:

> <html>
>         <head>
>                 <title>Page to test java.lang.Runtime calls for chmod</title>
>         <head>
>         <body>
> <%
> try {
>         String chmod = "/bin/chmod 660 /home/sarek/test/testfile";
>         Runtime run = Runtime.getRuntime();
>         out.println("- got Runtime<br>");
>         Process p = run.exec(chmod);
>         out.println("- executed: "+chmod+"<br>");
>         p.waitFor();
>         out.println("- Process ended with exit code "+p.exitValue()+"<br>");
> }
> catch (Exception e){
>         out.println("<br><font color='red'><strong>- caught exception: "+e.getMessage()+"</strong></font><br>");
> }
> %>
>         </body>
> </html>

With the result that any permissions I tried to set with this page are
set just as I want them to. So it does not seem that tomcat is the problem.

Now my actual question:

Can it be that struts - because I actually want to call the chmod
command from within a struts based application - is interfering with my
attempts to do this Runtime call?

I have no idea why all other attempts work but not when doing it from
within the application itself. We don't have any security manager set
and the testfile I pasted before works fine on the same tomcat instance.

Can anyone help me?

TIA

Christian
-- 
To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net


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


Re: Is struts interfering with Runtime.exec() calls?

Posted by Christian Riedel <sa...@nurfuerspam.de>.
On 26.08.2004 17:28, James Mitchell wrote:
> What container are you using?

Apache Tomcat 5.0.19

> What user or process is kicking off the jvm?

My normal system-user-account (sarek) is running Tomcat. So running the 
JVM as well.

> What permissions and/or groups does that user or process have or belong to?

The user belongs to the linux standard groups (main group is 'users') is

JVM: sun j2se "1.4.1_02-b06"
OS: SuSE Linux 8.2 (i586)

Christian
-- 
To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net


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


Re: Is struts interfering with Runtime.exec() calls?

Posted by James Mitchell <jm...@apache.org>.
What container are you using?
What user or process is kicking off the jvm?
What permissions and/or groups does that user or process have or belong to?



--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message -----
From: "Christian Riedel" <sa...@nurfuerspam.de>
To: <us...@struts.apache.org>
Sent: Thursday, August 26, 2004 11:11 AM
Subject: Re: Is struts interfering with Runtime.exec() calls?


> James,
>
> On 26.08.2004 16:48, James Mitchell wrote:
> > Short answer to your question.....no, Struts has nothing to do with
this.
> >
> > I can't understand how someone would take a week to try and get this
working
> > in JSP page, and even go so far as to write this email and send it to
this
> > list without first trying this (almost)verbatim in a simple test class.
> >
> > I ran your example on my home machine (Mandrake 10.0) and it worked just
> > fine in a JSP or in an Action forwarded to a JSP.  There's something
else
> > going on.
>
> Of course ... my example (the jsp you tried) worked fine for me as well
> ... That made me think that tomcat is not the problem so the next step
> logical setp for me was to think it's a struts related problem. For that
> reason I decided to ask here on the list. Sorry if you consider this as
> disrespect. We simply don't see what the problem could be.
>
> Here is what the application does:
> - it gets some data from a webpage form
> - it creates a file in a certain directory on the serve
> - and writes the data to this newly created File via FileOuputStream
>
> - later a script is called to do further processing with this new file
>
> For the script to work properly the created file has to have the file
> permission -rw-r--r--, so before calling the script I tried exactly the
> same code as in the test jsp. The code in the jsp really is copy-pasted
> from the app's source.
>
> Do you perhaps have any idea what could cause these problems I
> encounter? I am really running out of ideas.
>
> Christian
> --
> To reply to this posting directly use the following address and
> remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



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


Re: Is struts interfering with Runtime.exec() calls?

Posted by Christian Riedel <sa...@nurfuerspam.de>.
James,

On 26.08.2004 16:48, James Mitchell wrote:
> Short answer to your question.....no, Struts has nothing to do with this.
> 
> I can't understand how someone would take a week to try and get this working
> in JSP page, and even go so far as to write this email and send it to this
> list without first trying this (almost)verbatim in a simple test class.
> 
> I ran your example on my home machine (Mandrake 10.0) and it worked just
> fine in a JSP or in an Action forwarded to a JSP.  There's something else
> going on.

Of course ... my example (the jsp you tried) worked fine for me as well 
... That made me think that tomcat is not the problem so the next step 
logical setp for me was to think it's a struts related problem. For that 
reason I decided to ask here on the list. Sorry if you consider this as 
disrespect. We simply don't see what the problem could be.

Here is what the application does:
- it gets some data from a webpage form
- it creates a file in a certain directory on the serve
- and writes the data to this newly created File via FileOuputStream

- later a script is called to do further processing with this new file

For the script to work properly the created file has to have the file 
permission -rw-r--r--, so before calling the script I tried exactly the 
same code as in the test jsp. The code in the jsp really is copy-pasted 
from the app's source.

Do you perhaps have any idea what could cause these problems I 
encounter? I am really running out of ideas.

Christian
-- 
To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net


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


Re: Is struts interfering with Runtime.exec() calls?

Posted by James Mitchell <jm...@apache.org>.
Short answer to your question.....no, Struts has nothing to do with this.

I can't understand how someone would take a week to try and get this working
in JSP page, and even go so far as to write this email and send it to this
list without first trying this (almost)verbatim in a simple test class.

I ran your example on my home machine (Mandrake 10.0) and it worked just
fine in a JSP or in an Action forwarded to a JSP.  There's something else
going on.


--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message -----
From: "Christian Riedel" <sa...@nurfuerspam.de>
To: <us...@struts.apache.org>
Sent: Thursday, August 26, 2004 9:50 AM
Subject: Re: Is struts interfering with Runtime.exec() calls?


> Hi James,
>
> On 26.08.2004 15:43, James Mitchell wrote:
> > You are kidding right?
>
> I don't see any fun here and I am not kidding at all ...
>
> > Did you even try this from a test class?
>
> As described before I have tried it with the test jsp as well as from
> the application itself. The String containing the command for
> Runtime.execute() is:
>
> >>>"/bin/chmod 660 /home/sarek/test/testfile"
>
> The execute itself went fine, no Exceptions, exitcode 0 but the results
> of the command were as described in the table (see o.p.)
>
> I have tried to find the cause for nearly two weeks now. I simply don't
> see a mistake.
>
> Were you saying I was kidding because you cant imagine this result, or
> because I am missing something that was very obvious for you?
>
> Please enlighten me ;-)
>
> Christian
>
> --
> To reply to this posting directly use the following address and
> remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



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


Re: Is struts interfering with Runtime.exec() calls?

Posted by Christian Riedel <sa...@nurfuerspam.de>.
Hi James,

On 26.08.2004 15:43, James Mitchell wrote:
> You are kidding right?

I don't see any fun here and I am not kidding at all ...

> Did you even try this from a test class?

As described before I have tried it with the test jsp as well as from 
the application itself. The String containing the command for 
Runtime.execute() is:

>>>"/bin/chmod 660 /home/sarek/test/testfile"

The execute itself went fine, no Exceptions, exitcode 0 but the results 
of the command were as described in the table (see o.p.)

I have tried to find the cause for nearly two weeks now. I simply don't 
see a mistake.

Were you saying I was kidding because you cant imagine this result, or 
because I am missing something that was very obvious for you?

Please enlighten me ;-)

Christian

-- 
To reply to this posting directly use the following address and
remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net


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


Re: Is struts interfering with Runtime.exec() calls?

Posted by James Mitchell <jm...@apache.org>.
You are kidding right?

Did you even try this from a test class?



--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message -----
From: "Christian Riedel" <sa...@nurfuerspam.de>
To: <us...@struts.apache.org>
Sent: Thursday, August 26, 2004 4:20 AM
Subject: Is struts interfering with Runtime.exec() calls?


> Hi all,
>
> some days ago I posted a problem about not being able to do a chmod on
> the local file system from withing my webapp via a Runtime.exec() call.
> To achieve this I tried the following call:
>
> > "/bin/chmod 660 /home/sarek/test/testfile"
>
> wich did not show any effect. Nor do most of the other calls I tried
> which only had other permissions to be set.
>
> Here is a list of my attempts and their results:
>
> new perm before after
> ------------------------------------------
> g+rw -rw------- -rw-------
> u=rw,g=rw -rw------- -rw-------
> 0660 -rw------- -rw-------
> 0770 -rw------- -rw-------
> 770 -rw------- -rw-------
> 777 -rw------- -rw-------
> 664 -rw------- -rw-------
>
> but most suprisingly:
>
> 064 -rw------- ----rw-r--
>
> Now the problem is that I need to set the file's permission to
> -rw-rw---- which I have not managed to do so far :-(
>
> I thought there was a problem with tomcat and and security issues that
> prevents me from doing such things. So I just tried a small test-jsp to
> see if this was really the case:
>
> > <html>
> >         <head>
> >                 <title>Page to test java.lang.Runtime calls for
chmod</title>
> >         <head>
> >         <body>
> > <%
> > try {
> >         String chmod = "/bin/chmod 660 /home/sarek/test/testfile";
> >         Runtime run = Runtime.getRuntime();
> >         out.println("- got Runtime<br>");
> >         Process p = run.exec(chmod);
> >         out.println("- executed: "+chmod+"<br>");
> >         p.waitFor();
> >         out.println("- Process ended with exit code
"+p.exitValue()+"<br>");
> > }
> > catch (Exception e){
> >         out.println("<br><font color='red'><strong>- caught exception:
"+e.getMessage()+"</strong></font><br>");
> > }
> > %>
> >         </body>
> > </html>
>
> With the result that any permissions I tried to set with this page are
> set just as I want them to. So it does not seem that tomcat is the
problem.
>
> Now my actual question:
>
> Can it be that struts - because I actually want to call the chmod
> command from within a struts based application - is interfering with my
> attempts to do this Runtime call?
>
> I have no idea why all other attempts work but not when doing it from
> within the application itself. We don't have any security manager set
> and the testfile I pasted before works fine on the same tomcat instance.
>
> Can anyone help me?
>
> TIA
>
> Christian
> --
> To reply to this posting directly use the following address and
> remove the 'NO-SPAM' part: Riedel.Christian.NO-SPAM@gmx.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



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