2

I built a webapp that uses libpcap (via jpcap).

In order to be able to get the network interfaces list or to bind to a network interface, the application (in this case a webaap that runs from tomcat server) must be running with root privileges.

During development I simply ran Eclipse with root privileges (sudo eclipse) and my webapp worked just fine with Eclipse's local tomcat server.

However, when I try to deploy my webapp to the "real" tomcat server, it isn't working. I Also tried to start the tomcat6 service with sudo and changed the TOMCAT6_USER definition (defined in /etc/init.d/tomcat6) from "tomcat6" to "root" but it made no difference.

What should I do to make it work?

Hagay Myr
  • 299
  • 2
  • 6
  • 16
  • First off, I think you are off topic with this question (should be asked on http://serverfault.com/). But just from reading it, the necessity to run Tomcat and/or a single webapp as root feels like a massive security issue to me... If I were to do something similar, I'd probably make the monitor app a demon to run natively, and open a network port to establish local connections from the webapp to it. – weltraumpirat Apr 01 '12 at 09:25
  • @weltraumpirat, I wasn't familiar with serverfault.com. I will publish my question there (also). As for the security issue, you might be right, the current implementation has an inherent problem and it should have been built the way you suggested or similar. However, for the purpose of my project it is sufficient for now. Is the still a way to do so? – Hagay Myr Apr 01 '12 at 10:28

1 Answers1

4

It seems that there is a bug in the tomcat initialization scripts, since (as you correctly mention) the TOMCAT6_USER and TOMCAT6_GROUP variables defined in /etc/init.d/tomcat are ignored. After reading the script for a while, I found out that it is possible to have Tomcat6 running as "root" by changing the same variables but in the "/etc/default/tomcat6" file.

PS: Don't run Tomcat as root

Perception
  • 79,279
  • 19
  • 185
  • 195
andres.riancho
  • 1,186
  • 13
  • 18