Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Question about File ownership file upload and HTTP Post

Christopher Schultz

2007-07-27

Replies:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Josh,

Josh Rountree wrote:
> I have a servlet that processes requests for file uploads. When I
> write this file to disk, root is the owner?

You should not be running Tomcat as root. Are you doing that? Stop it!

> Is this the correct behavior?

Unless you do something special, the file will be owned by the user that
the Tomcat process is running as.

> Since I do not have root access on the machine that the servlet
> executes I cannot remove these files. Any documentation that explains
> how to change the owner of these uploaded files?

File ownership is one of those things that Java does not handle very
well. There's a bug report that's still in progress at Sun:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4313887

All the related documentation for this bug (and duplicates of it) says
to write your own native wrapper around the filesystem calls necessary.
Fortunately, such a wrapper would be very simple to write, if still a
pain in the neck to deploy, etc.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGqjxu9CaO5/Lv0PARAicgAJ9tk7IOC178TxPbJvTN1mGiGCv9CgCgmaYg
1cYKWzYugHEqrLCljCi5BkI=
=qWxD
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.