Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Running as root
Running as root [message #271010] Thu, 21 May 2009 20:24 Go to next message
Patrick Connolly is currently offline Patrick ConnollyFriend
Messages: 9
Registered: July 2009
Junior Member
I'm using Eclipse to run code on Linux that does ethernet capture (calling
libpcap) -similar to Wireshark. This means that the code must be running
as root since capture (promiscuous mode) isn't possible on Linux unless
the process is running as root. But I run other code in Eclipse that
doesn't require Root privileges; I'd prefer to run as user (ie not Root)
except when root is absolutely necessary.

HERE'S THE PROBLEM:
If I start Eclipse as Root for the capture and then later try to invoke
eclipse as a non-root user, Eclipse crashes. The reason is that it
attempts to write config or log files in the <workspace>/.metadata/
directory and when these writes fail, it ends up with a "null pointer
exception" or similar error -without informing the user - it just hangs or
crashes.

POSSIBLE SOLUTIONS:
1. Does anyone know for sure if it's possible to start Eclipse as a
non-root user and then start the process it's debugging as root?
2. It seems that clean solution to this problem would be to have the
root/superuser projects all in one workspace. Then -assuming that all
config information is written to the <workspace>/.metadata/ tree - all the
root permission file/directory issues would be in this workspace only and
other workspaces would have non-root-user permissions. Does anyone know
if it's correct to assume that all the config file writes happen only in
the workspace/.metadata/ tree.

I know I could try it out but I don't want to find out the hard way four
months from now (after I've forgotten about this whole issue) that it
doesn't really work because of some oddball file that is written outside
of the workspace tree under some rare circumstances.

Does anyone know for sure of a clean way of getting this capability of
debugging a process with root permission and then having the capability of
running as a non-root user later ?
Re: Running as root [message #271154 is a reply to message #271010] Wed, 27 May 2009 16:58 Go to previous messageGo to next message
Ian Bull is currently offline Ian BullFriend
Messages: 145
Registered: July 2009
Senior Member
I wonder if you can create an "external tool" (It's the icon next to the
launch icon in Eclipse). The external tool would call sudo and launch
java. You may have to setup the command line properly if you want debug
support. Looking at how the jdb works might help here:

http://java.sun.com/javase/6/docs/technotes/tools/windows/jd b.html

cheers,
ian

pjc wrote:
> I'm using Eclipse to run code on Linux that does ethernet capture
> (calling libpcap) -similar to Wireshark. This means that the code must
> be running as root since capture (promiscuous mode) isn't possible on
> Linux unless the process is running as root. But I run other code in
> Eclipse that doesn't require Root privileges; I'd prefer to run as user
> (ie not Root) except when root is absolutely necessary.
> HERE'S THE PROBLEM:
> If I start Eclipse as Root for the capture and then later try to invoke
> eclipse as a non-root user, Eclipse crashes. The reason is that it
> attempts to write config or log files in the <workspace>/.metadata/
> directory and when these writes fail, it ends up with a "null pointer
> exception" or similar error -without informing the user - it just hangs
> or crashes.
> POSSIBLE SOLUTIONS:
> 1. Does anyone know for sure if it's possible to start Eclipse as a
> non-root user and then start the process it's debugging as root? 2. It
> seems that clean solution to this problem would be to have the
> root/superuser projects all in one workspace. Then -assuming that all
> config information is written to the <workspace>/.metadata/ tree - all
> the root permission file/directory issues would be in this workspace
> only and other workspaces would have non-root-user permissions. Does
> anyone know if it's correct to assume that all the config file writes
> happen only in the workspace/.metadata/ tree.
>
> I know I could try it out but I don't want to find out the hard way four
> months from now (after I've forgotten about this whole issue) that it
> doesn't really work because of some oddball file that is written outside
> of the workspace tree under some rare circumstances.
>
> Does anyone know for sure of a clean way of getting this capability of
> debugging a process with root permission and then having the capability
> of running as a non-root user later ?
>


--
R. Ian Bull | EclipseSource Victoria | +1-888-679-8753
http://eclipsesource.com | http://twitter.com/eclipsesource
Re: Running as root [message #724809 is a reply to message #271010] Tue, 13 September 2011 08:45 Go to previous messageGo to next message
mib85 is currently offline mib85Friend
Messages: 4
Registered: September 2011
Junior Member
Patrick Connolly wrote on Thu, 21 May 2009 16:24
I'm using Eclipse to run code on Linux that does ethernet capture (calling
libpcap) -similar to Wireshark. This means that the code must be running
as root since capture (promiscuous mode) isn't possible on Linux unless
the process is running as root. But I run other code in Eclipse that
doesn't require Root privileges; I'd prefer to run as user (ie not Root)
except when root is absolutely necessary.

HERE'S THE PROBLEM:
If I start Eclipse as Root for the capture and then later try to invoke
eclipse as a non-root user, Eclipse crashes. The reason is that it
attempts to write config or log files in the <workspace>/.metadata/
directory and when these writes fail, it ends up with a "null pointer
exception" or similar error -without informing the user - it just hangs or
crashes.

POSSIBLE SOLUTIONS:
1. Does anyone know for sure if it's possible to start Eclipse as a
non-root user and then start the process it's debugging as root?
2. It seems that clean solution to this problem would be to have the
root/superuser projects all in one workspace. Then -assuming that all
config information is written to the <workspace>/.metadata/ tree - all the
root permission file/directory issues would be in this workspace only and
other workspaces would have non-root-user permissions. Does anyone know
if it's correct to assume that all the config file writes happen only in
the workspace/.metadata/ tree.

I know I could try it out but I don't want to find out the hard way four
months from now (after I've forgotten about this whole issue) that it
doesn't really work because of some oddball file that is written outside
of the workspace tree under some rare circumstances.

Does anyone know for sure of a clean way of getting this capability of
debugging a process with root permission and then having the capability of
running as a non-root user later ?


I have the same problem. Does anyone know how to run a Java application as superuser (running Eclipse as normal user)?
Tanks!

P.S. Sorry, but my english is not so good.
Re: Running as root [message #724852 is a reply to message #724809] Tue, 13 September 2011 10:58 Go to previous messageGo to next message
mib85 is currently offline mib85Friend
Messages: 4
Registered: September 2011
Junior Member
Ok, I found this expedient:

1. Rename your java application:
sudo mv /usr/lib/jvm/java-6-openjdk/jre/bin/java /usr/lib/jvm/java-6-openjdk/jre/bin/java.ori

2. Create the script /usr/lib/jvm/java-6-openjdk/jre/bin/java with the following content:
#!/bin/bash
gksudo "/usr/lib/jvm/java-6-openjdk/jre/bin/java.ori $*"

3. Change the permissions to make it executable:
sudo cmod 0755 /usr/lib/jvm/java-6-openjdk/jre/bin/java


In this way, the (any?) java application asks always the root password and it starts with root privileges.
It isn't the solution of the problem, but only a "bypass".
If you can give me a better solution, I'll be grateful! Tanks!
Re: Running as root [message #724933 is a reply to message #724852] Tue, 13 September 2011 14:13 Go to previous messageGo to next message
mib85 is currently offline mib85Friend
Messages: 4
Registered: September 2011
Junior Member
It's not a good solution. Eclipse is itself a Java application, and so it runs consequently in superuser mode... Sad
Re: Running as root [message #725196 is a reply to message #724933] Wed, 14 September 2011 08:09 Go to previous message
mib85 is currently offline mib85Friend
Messages: 4
Registered: September 2011
Junior Member
Ok! I found a better solution!
1. Download a jre from the Java site
2. extract it in a folder (e.g. /usr/lib/jre-1.6.0_27)
3. in Eclipse: Window->Preferences->Java->Installed JREs->Add...->ecc...
4. create the script above for this jre

Now Eclipse will run as normal user and the java app as super user! Wink
Previous Topic:How to set global preference?
Next Topic:Model to Model Transformation
Goto Forum:
  


Current Time: Thu Apr 25 22:27:57 GMT 2024

Powered by FUDForum. Page generated in 0.08185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top