New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I set the setcap cap_net_raw,cap_net_admin=eip /path/to/java; the java can not run anymore, it report the error below #63

Closed
xiaoleihuang opened this Issue May 14, 2016 · 9 comments

Comments

Projects
None yet
2 participants
@xiaoleihuang

xiaoleihuang commented May 14, 2016

Initially, I would like to run java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.209.1;
It required to choose with the following instruction:
NIF[0]: enp9s0
: link layer address:
: address: /
: address: /
: address: /
NIF[1]: any
: description: Pseudo-device that captures on all interfaces
NIF[2]: lo
: link layer address: 00:00:00:00:00:00
: address: /127.0.0.1
: address: /0:0:0:0:0:0:0:1
NIF[3]: wlp3s0
: link layer address:
NIF[4]: docker0
: link layer address:
: address: /

*_Some exception prompted after choosing the first device._*

However, it said I did not have permission withe the exception below:
Exception in thread "main" org.pcap4j.core.PcapNativeException: enp9s0: You don't have permission to capture on that device (socket: Operation not permitted)
at org.pcap4j.core.PcapNetworkInterface.openLive(PcapNetworkInterface.java:258)
at org.pcap4j.sample.SendArpRequest.main(SendArpRequest.java:74)

So I set the setcap cap_net_raw,cap_net_admin=eip /path/to/java in my Ubuntu. Then the java can not run anymore, it report the error below:
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

How to fix it?

@kaitoy

This comment has been minimized.

Show comment
Hide comment
@kaitoy

kaitoy May 14, 2016

Owner

It's probably the same issue as this.
Setting LD_LIBRARY_PATH to include where libjli.so is may solve the issue.

Owner

kaitoy commented May 14, 2016

It's probably the same issue as this.
Setting LD_LIBRARY_PATH to include where libjli.so is may solve the issue.

@xiaoleihuang

This comment has been minimized.

Show comment
Hide comment
@xiaoleihuang

xiaoleihuang May 14, 2016

I tried this method to set libjli.so in the PATH, but it did not work either. I tried following in either /etc/profile or ~/.bashrc:

libjli.so path

export PATH=/usr/local/java/jre/lib/amd64/jli/libjli.so:$PATH

Later, I tried:

libjli.so path

export PATH=/usr/local/java/jre/lib/amd64/jli:$PATH

They did not work at all. Then I tried root,
under root account, java -v does not work, but java -version does work....

xiaoleihuang commented May 14, 2016

I tried this method to set libjli.so in the PATH, but it did not work either. I tried following in either /etc/profile or ~/.bashrc:

libjli.so path

export PATH=/usr/local/java/jre/lib/amd64/jli/libjli.so:$PATH

Later, I tried:

libjli.so path

export PATH=/usr/local/java/jre/lib/amd64/jli:$PATH

They did not work at all. Then I tried root,
under root account, java -v does not work, but java -version does work....

@kaitoy

This comment has been minimized.

Show comment
Hide comment
@kaitoy

kaitoy May 14, 2016

Owner

How was LD_LIBRARY_PATH? Did you try it?

Owner

kaitoy commented May 14, 2016

How was LD_LIBRARY_PATH? Did you try it?

@xiaoleihuang

This comment has been minimized.

Show comment
Hide comment
@xiaoleihuang

xiaoleihuang May 14, 2016

Yeah, I just tried it with the following code in either /etc/profile or ~/.bashrc:
export LD_LIBRARY_PATH=/usr/local/java/jre/lib/amd64/jli
export PATH=${LD_LIBRARY_PATH}:$PATH
#export PATH=/usr/local/java/jre/lib/amd64/jli/libjli.so:$PATH

It did not work. T-T, sad Saturday afternoon.

xiaoleihuang commented May 14, 2016

Yeah, I just tried it with the following code in either /etc/profile or ~/.bashrc:
export LD_LIBRARY_PATH=/usr/local/java/jre/lib/amd64/jli
export PATH=${LD_LIBRARY_PATH}:$PATH
#export PATH=/usr/local/java/jre/lib/amd64/jli/libjli.so:$PATH

It did not work. T-T, sad Saturday afternoon.

@kaitoy

This comment has been minimized.

Show comment
Hide comment
@kaitoy

kaitoy May 14, 2016

Owner

Try ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/.
Or echo /usr/local/java/jre/lib/amd64/jli/ >> /etc/ld.so.conf

Owner

kaitoy commented May 14, 2016

Try ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/.
Or echo /usr/local/java/jre/lib/amd64/jli/ >> /etc/ld.so.conf

@xiaoleihuang

This comment has been minimized.

Show comment
Hide comment
@xiaoleihuang

xiaoleihuang May 14, 2016

Thank you. The first command works! I appreciate your help.

I have not tried the second command.
BTW, I am curious why the both commands would work.
Why making such soft link could solve the problem? Does that mean to add the file to lib path?

xiaoleihuang commented May 14, 2016

Thank you. The first command works! I appreciate your help.

I have not tried the second command.
BTW, I am curious why the both commands would work.
Why making such soft link could solve the problem? Does that mean to add the file to lib path?

@kaitoy

This comment has been minimized.

Show comment
Hide comment
@kaitoy

kaitoy May 14, 2016

Owner

You are right.
The error occurred because java couldn't find a shared library, libjli.so. The reason why the java lost sight of it after setting setcap cap_net_raw,cap_net_admin=eip is explained at the link I indicated above.
All of my suggestions intended to let the java know the place of libjli.so. Generally speaking, shared libraries are searched in specific directories. LD_LIBRARY_PATH and /etc/ld.so.conf are to specify the directories. ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/ is another approach that adds libjli.so to the directory (i.e. /usr/lib/) which is searched by default.

Owner

kaitoy commented May 14, 2016

You are right.
The error occurred because java couldn't find a shared library, libjli.so. The reason why the java lost sight of it after setting setcap cap_net_raw,cap_net_admin=eip is explained at the link I indicated above.
All of my suggestions intended to let the java know the place of libjli.so. Generally speaking, shared libraries are searched in specific directories. LD_LIBRARY_PATH and /etc/ld.so.conf are to specify the directories. ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/ is another approach that adds libjli.so to the directory (i.e. /usr/lib/) which is searched by default.

@kaitoy kaitoy closed this May 14, 2016

@xiaoleihuang

This comment has been minimized.

Show comment
Hide comment
@xiaoleihuang

xiaoleihuang May 18, 2016

Thank you. BTW, pcap packet seems to contains no timestamp, instead, I have
to use handler.gettimestamp method to retrieve the time. Will this cause
any time errors? Is there a method to retrieve packets that contain
timestamp inside of them?

On Sat, May 14, 2016 at 2:20 AM, Kaito Yamada notifications@github.com
wrote:

You are right.
The error occurred because java couldn't find a shared library, libjli.so.
The reason why the java lost sight of it after setting setcap
cap_net_raw,cap_net_admin=eip is explained at the link I indicated above.
All of my suggestions intended to let the java know the place of
libjli.so. Generally speaking, shared libraries are searched in specific
directories. LD_LIBRARY_PATH and /etc/ld.so.conf are to specify the
directories. ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/
is another approach that adds libjli.so to the directory (i.e. /usr/lib/)
which is searched by default.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#63 (comment)

xiaoleihuang commented May 18, 2016

Thank you. BTW, pcap packet seems to contains no timestamp, instead, I have
to use handler.gettimestamp method to retrieve the time. Will this cause
any time errors? Is there a method to retrieve packets that contain
timestamp inside of them?

On Sat, May 14, 2016 at 2:20 AM, Kaito Yamada notifications@github.com
wrote:

You are right.
The error occurred because java couldn't find a shared library, libjli.so.
The reason why the java lost sight of it after setting setcap
cap_net_raw,cap_net_admin=eip is explained at the link I indicated above.
All of my suggestions intended to let the java know the place of
libjli.so. Generally speaking, shared libraries are searched in specific
directories. LD_LIBRARY_PATH and /etc/ld.so.conf are to specify the
directories. ln -s /usr/local/java/jre/lib/amd64/jli/libjli.so /usr/lib/
is another approach that adds libjli.so to the directory (i.e. /usr/lib/)
which is searched by default.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#63 (comment)

@kaitoy

This comment has been minimized.

Show comment
Hide comment
@kaitoy

kaitoy May 18, 2016

Owner

No, PcapHandler#getTimestamp() returns a correct timestamp.

Owner

kaitoy commented May 18, 2016

No, PcapHandler#getTimestamp() returns a correct timestamp.

@kaitoy kaitoy added the question label Nov 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment