java system.getenv(HOME) returns tomcat6 directory
Hi as the subject reads
System.getenv("HOME")
in my action class (struts2) and deploy that as a war in
/var/lib/tomcat6/webapps/
When i run my class, getenv HOME returns
/var/lib/tomcat6
Can anyone tell me whats going on? I even tested it out on a standalone java class.Returns the proper value of home. Tried it on开发者_StackOverflow shell also echo $HOME
and it gives a proper output.
Running on Ubuntu 10.04.
i THINK ive got what the problem is.. My project got deployed with permissions for "tomcat6 tomcat6" so when i getenv HOME, it gives me tomcat home. Am I right?
No.
The problem is that your tomcat6 service is configured to run as the "tomcat" user. (There is typically a variable in the init.d/tomcatd script that does this ...) THIS IS DONE FOR SECURITY REASONS. Don't change it unless you've done a proper risk assessment.
What you really need to do is change your web application so that it doesn't expect $HOME to be >>your<< home directory. Instead, create a webapp specific properties file that gives the location of this external (to tomcat) directory. Or better still (and best practice!) change your application so that it doesn't need to refer to an external directory at all.
精彩评论