You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kam Lung Leung <kl...@advoicetech.com> on 2005/06/21 23:04:35 UTC
Can't rename a file using renameTo()
Hi,
I have a servlet, Servlet-A, that rename a file from /tmp/oldFile to /someDirectory/newFile. The Servlet-A runs fine when it runs by itself in a Red Hat Linux 7.2 server that has jakarta-tomcat-4.1.30 running. However, it false to rename the /tmp/oldFile to /someDirectory/newFile when the Servlet-A run (within the jakarta-tomcat-4.1.30) in a Red Hat Linux 7.2 server box that also has jboss-3.2.1_tomcat-4.1.24 running. I thought it may be privilege issue so I set the /someDirectory directory with “chmod –R 777” and run Tomcat as a root user. But, it is still false to rename the /tmp/oldFile file to the /someDirectory/newFile.
The strange thing is that the Servlet-A was able to write the oldFile to the /tmp directory but can not rename the oldFile to the /someDirectory directory that was allowed for writing for ALL user levels. Can this be Jboss prevented the rename operation. I used the canRead and canWrite to check allowable action by the File. It turns out that the Servlet-A can read and write the /tmp/ oldFile. But the Servlet-A can’t read or write the /someDirectory/newFile.
The strangest thing is that when the Servlet-A runs in a Red Hat Linux 7.2 server that has ONLY jakarta-tomcat-4.1.30 running, the condition of canRead and canwrite are the same. Meaning that the Servlet-A was able to read, and write the oldFile. But can’t read, and write the newFile. However, the renameTo() method returned true and the Servlet-A was able to rename the /tmp/oldFile into /someDirectory/newFile.
Any help in this issue is greatly appreciated.
Kam
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can't rename a file using renameTo()
Posted by Jason Bainbridge <jb...@gmail.com>.
On 6/21/05, Kam Lung Leung <kl...@advoicetech.com> wrote:
> Hi,
>
> I have a servlet, Servlet-A, that rename a file from /tmp/oldFile to /someDirectory/newFile. The Servlet-A runs fine when it runs by itself in a Red Hat Linux 7.2 server that has jakarta-tomcat-4.1.30 running. However, it false to rename the /tmp/oldFile to /someDirectory/newFile when the Servlet-A run (within the jakarta-tomcat-4.1.30) in a Red Hat Linux 7.2 server box that also has jboss-3.2.1_tomcat-4.1.24 running. I thought it may be privilege issue so I set the /someDirectory directory with "chmod –R 777" and run Tomcat as a root user. But, it is still false to rename the /tmp/oldFile file to the /someDirectory/newFile.
>
> The strange thing is that the Servlet-A was able to write the oldFile to the /tmp directory but can not rename the oldFile to the /someDirectory directory that was allowed for writing for ALL user levels. Can this be Jboss prevented the rename operation. I used the canRead and canWrite to check allowable action by the File. It turns out that the Servlet-A can read and write the /tmp/ oldFile. But the Servlet-A can't read or write the /someDirectory/newFile.
>
> The strangest thing is that when the Servlet-A runs in a Red Hat Linux 7.2 server that has ONLY jakarta-tomcat-4.1.30 running, the condition of canRead and canwrite are the same. Meaning that the Servlet-A was able to read, and write the oldFile. But can't read, and write the newFile. However, the renameTo() method returned true and the Servlet-A was able to rename the /tmp/oldFile into /someDirectory/newFile.
It took me a few reads to even come close to following all that but is
it possibly that you are trying to copy a subdirectory within /tmp to
a subdirectory of /someDirectory that doesn't exist?
--
Jason Bainbridge
http://kde.org - webmaster@kde.org
Personal Site - http://jasonbainbridge.com
Re: Can't rename a file using renameTo()
Posted by Christoph Kutzinski <ku...@gmx.de>.
Hi,
I would guess that there is a security policy in JBoss that prevents
JBoss (and its integrated Tomcat) from writing outside some special
directories (e.g. its working directory and the temp directory).
There is surely a way to lessen this security restriction, but that is
obviously a JBoss question. You should ask for more help in a JBoss
forum/mailing list (or probably just reading the JBoss configuration
documentation would help, too)
Christoph
Kam Lung Leung wrote:
> Hi Jason,
>
> Thank you for the information. It is a long paragraph. I checked the /SomeDirectory again, and it is the same name. I was able to create directory with the mkdir -p
> /SomeDirectory/firstSubdirectory/secondSubdirectory and manually created a file by this command
> "touch /SomeDirectory/firstSubdirectory/secondSubdirectory/newFile" . The Servlet was able to create directories under the /SomeDirectory directory. For example, the Servlet was able to create
> /SomeDirectory/firstSubdirectory/secondSubdirectory directories. But the Servlet can’t rename the file named oldFile under the /tmp directory to /SomeDirectory/firstSubdirectory/secondSubdirectory/newFile. The Servlet did created all directories under the /SomeDirectory by not able to move the oldFile to the that directory. The same code work fines what it run without the Jboss running in the same server.
>
> Kam
>
>
>
>
>
> ---- Jason Bainbridge <jb...@gmail.com> wrote:
>
>>On 6/21/05, Kam Lung Leung <kl...@advoicetech.com> wrote:
>>
>>>Hi,
>>>
>>>I have a servlet, Servlet-A, that rename a file from /tmp/oldFile to /someDirectory/newFile. The Servlet-A runs fine when it runs by itself in a Red Hat Linux 7.2 server that has jakarta-tomcat-4.1.30 running. However, it false to rename the /tmp/oldFile to /someDirectory/newFile when the Servlet-A run (within the jakarta-tomcat-4.1.30) in a Red Hat Linux 7.2 server box that also has jboss-3.2.1_tomcat-4.1.24 running. I thought it may be privilege issue so I set the /someDirectory directory with "chmod –R 777" and run Tomcat as a root user. But, it is still false to rename the /tmp/oldFile file to the /someDirectory/newFile.
>>>
>>>The strange thing is that the Servlet-A was able to write the oldFile to the /tmp directory but can not rename the oldFile to the /someDirectory directory that was allowed for writing for ALL user levels. Can this be Jboss prevented the rename operation. I used the canRead and canWrite to check allowable action by the File. It turns out that the Servlet-A can read and write the /tmp/ oldFile. But the Servlet-A can't read or write the /someDirectory/newFile.
>>>
>>>The strangest thing is that when the Servlet-A runs in a Red Hat Linux 7.2 server that has ONLY jakarta-tomcat-4.1.30 running, the condition of canRead and canwrite are the same. Meaning that the Servlet-A was able to read, and write the oldFile. But can't read, and write the newFile. However, the renameTo() method returned true and the Servlet-A was able to rename the /tmp/oldFile into /someDirectory/newFile.
>>
>>It took me a few reads to even come close to following all that but is
>>it possibly that you are trying to copy a subdirectory within /tmp to
>>a subdirectory of /someDirectory that doesn't exist?
>>
>>
>>--
>>Jason Bainbridge
>>http://kde.org - webmaster@kde.org
>>Personal Site - http://jasonbainbridge.com
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Can't rename a file using renameTo()
Posted by Kam Lung Leung <kl...@advoicetech.com>.
Hi Jason,
Thank you for the information. It is a long paragraph. I checked the /SomeDirectory again, and it is the same name. I was able to create directory with the mkdir -p
/SomeDirectory/firstSubdirectory/secondSubdirectory and manually created a file by this command
"touch /SomeDirectory/firstSubdirectory/secondSubdirectory/newFile" . The Servlet was able to create directories under the /SomeDirectory directory. For example, the Servlet was able to create
/SomeDirectory/firstSubdirectory/secondSubdirectory directories. But the Servlet can’t rename the file named oldFile under the /tmp directory to /SomeDirectory/firstSubdirectory/secondSubdirectory/newFile. The Servlet did created all directories under the /SomeDirectory by not able to move the oldFile to the that directory. The same code work fines what it run without the Jboss running in the same server.
Kam
---- Jason Bainbridge <jb...@gmail.com> wrote:
>
> On 6/21/05, Kam Lung Leung <kl...@advoicetech.com> wrote:
> > Hi,
> >
> > I have a servlet, Servlet-A, that rename a file from /tmp/oldFile to /someDirectory/newFile. The Servlet-A runs fine when it runs by itself in a Red Hat Linux 7.2 server that has jakarta-tomcat-4.1.30 running. However, it false to rename the /tmp/oldFile to /someDirectory/newFile when the Servlet-A run (within the jakarta-tomcat-4.1.30) in a Red Hat Linux 7.2 server box that also has jboss-3.2.1_tomcat-4.1.24 running. I thought it may be privilege issue so I set the /someDirectory directory with "chmod –R 777" and run Tomcat as a root user. But, it is still false to rename the /tmp/oldFile file to the /someDirectory/newFile.
> >
> > The strange thing is that the Servlet-A was able to write the oldFile to the /tmp directory but can not rename the oldFile to the /someDirectory directory that was allowed for writing for ALL user levels. Can this be Jboss prevented the rename operation. I used the canRead and canWrite to check allowable action by the File. It turns out that the Servlet-A can read and write the /tmp/ oldFile. But the Servlet-A can't read or write the /someDirectory/newFile.
> >
> > The strangest thing is that when the Servlet-A runs in a Red Hat Linux 7.2 server that has ONLY jakarta-tomcat-4.1.30 running, the condition of canRead and canwrite are the same. Meaning that the Servlet-A was able to read, and write the oldFile. But can't read, and write the newFile. However, the renameTo() method returned true and the Servlet-A was able to rename the /tmp/oldFile into /someDirectory/newFile.
>
> It took me a few reads to even come close to following all that but is
> it possibly that you are trying to copy a subdirectory within /tmp to
> a subdirectory of /someDirectory that doesn't exist?
>
>
> --
> Jason Bainbridge
> http://kde.org - webmaster@kde.org
> Personal Site - http://jasonbainbridge.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org