Servlets read/write a file (urgent)
1 posts in topic
Flat View  Flat View

Posted By:   John_Wu
Posted On:   Tuesday, October 23, 2001 08:36 PM

OS: Sun Solaris 2.6

Web server: iPlanet 4.1.

web server user: webadmin

I have a servlet S1 owned by user X. User X has a file F which is readable and writeable only by User X itself.
(i.e. F's permission is 0600).

My question is:

Is it possible that servlet S1 can read/write file X? In another words, can we make servlet S1 behave just like user X?

Thanks in advance,


Re: Servlets read/write a file (urgent)

Posted By:   Alex_Chaffee  
Posted On:   Monday, October 29, 2001 07:10 AM

Not really. Java has no API for "suid"-like functions.

You could fork a process with Runtime.exec that runs as user X and cats the file -- that is, a script like

cat $1

though you'll have to do some magic to get it to run as user X -- see http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html?page=2
About | Sitemap | Contact