|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Reading and writing files outside tomcat directoryI have an application whose class files are in /usr/local/tomcat/webapps/ROOT/WEB-INF/classes
It uses the following line to write a file called java.php: FileOutputStream fout = new FileOutputStream ("/usr/local/tomcat/webapps/ROOT/java.php", true); It does this perfectly. What I want is to write this file to a directory outside the tomcat directory. e.g. to /var/www/newdir In Tomcat under Windows I have no problem doing this. Tomcat is installed in F: and I can write to my apache directory c:\Apache2\htdocs by putting this file path in the above code line. But Tomcat under Linux does not allow me to do this, apparently for security reasons. But security does not really matter for me because this application won't be open. How do I read and write files outside the home directory? |
|
|
Re: Reading and writing files outside tomcat directoryTomcat version?
Installed from tomcat.apache.org or a third-party repackaged version? If repackaged, look at the docs - are you running under a security manager? - Peter 2009/11/3 noobie45 <philip.george@...> > > I have an application whose class files are in > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes > > It uses the following line to write a file called java.php: > FileOutputStream fout = new FileOutputStream > ("/usr/local/tomcat/webapps/ROOT/java.php", true); > > It does this perfectly. > > What I want is to write this file to a directory outside the tomcat > directory. e.g. to /var/www/newdir > > In Tomcat under Windows I have no problem doing this. Tomcat is installed > in > F: and I can write to my apache directory c:\Apache2\htdocs by putting this > file path in the above code line. > > But Tomcat under Linux does not allow me to do this, apparently for > security > reasons. But security does not really matter for me because this > application > won't be open. How do I read and write files outside the home directory? > -- > View this message in context: > http://old.nabble.com/Reading-and-writing-files-outside-tomcat-directory-tp26160054p26160054.html > Sent from the Tomcat - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
|
|
Re: Reading and writing files outside tomcat directorynoobie45 wrote:
> I have an application whose class files are in > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes > > It uses the following line to write a file called java.php: > FileOutputStream fout = new FileOutputStream > ("/usr/local/tomcat/webapps/ROOT/java.php", true); > > It does this perfectly. > > What I want is to write this file to a directory outside the tomcat > directory. e.g. to /var/www/newdir > > In Tomcat under Windows I have no problem doing this. Tomcat is installed in > F: and I can write to my apache directory c:\Apache2\htdocs by putting this > file path in the above code line. > > But Tomcat under Linux does not allow me to do this, apparently for security > reasons. But security does not really matter for me because this application > won't be open. How do I read and write files outside the home directory? Maybe just verify that the user-id under which Tomcat runs has the permission to write to the directory where you tell it to write ? Under Windows, you do not see that problem because you are probably running the Tomcat service under the user-id "LocalSystem", which has extensive access rights to all local resources. But under Unix/Linux, Tomcat will be running as some user (tomcat5 ?), which does not by default have writing rights to /var/www, or wherever your webserver directory is. It is not a Tomcat-level permission issue, it is a OS-level permission issue. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Reading and writing files outside tomcat directoryThe Tomcat is installed on my site under Debian. I think it's the standard version with directories in the usual places.
|
|
|
Re: Reading and writing files outside tomcat directoryThank you so much.
I am absolutely new to Tomcat on Linux. I need to figure out what you mean by "user-id under which Tomcat runs". |
|
|
Re: Reading and writing files outside tomcat directoryI used my ftp client (WinSCP) to change file permissions for the directory to R,W,X for others and now I am able to write the file outside the Tomcat directory.
Thanks again so much. |
|
|
Re: Reading and writing files outside tomcat directorynoobie45 wrote:
> Thank you so much. > > I am absolutely new to Tomcat on Linux. > > I need to figure out what you mean by "user-id under which Tomcat runs". Every process on Linux is ran by a certain user. With command "ps -ef", you can list all the processes and users that run them (first column from left). You can easily identify Tomcat process by recognizing Java executable, something like: tomcat 28710 1 5 10:43 ? 00:00:17 /usr/java/default/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Dorg.apache.el.parser.COERCE_TO_ZERO=false -XX:MaxPermSize=300m -Xms300m -Xmx400m -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath :/usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start Here you can see that Tomcat server is started as Java application packed in bootstrap.jar file, invoked by default JVM (/usr/java/default/bin/java), and ran by user "tomcat". On some system the user can be "root" or something else. Now, to go back to the original question: if the user that is running Tomcat server have privileges to read or write to any directory on the file system, so will the tomcat web application. (At least if the security manager is turned off which is default setting.) Regards, Ognjen --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Reading and writing files outside tomcat directoryThanks. I just tried out the command and got the list of users including tomcat.
|
| Free embeddable forum powered by Nabble | Forum Help |