Bug 221213

Summary: java/linux-oracle-jdk18: Does not work with NONE-ROOT user
Product: Ports & Packages Reporter: jinlong.hao <jinlong.hao>
Component: Individual Port(s)Assignee: freebsd-java (Nobody) <java>
Status: Open ---    
Severity: Affects Only Me CC: java, jinlong.hao, petteri.valkonen, trasz
Priority: --- Keywords: needs-qa
Version: LatestFlags: koobs: maintainer-feedback? (java)
koobs: merge-quarterly?
Hardware: Any   
OS: Any   

Description jinlong.hao 2017-08-04 04:01:57 UTC
Hi, ALL:

For some reason, I have change openjdk to linux-oracle-jdk. I've install linux-oracle-jdk on FreeBSD-11(linux-c7 by pkg, linux-oracle-jdk18 by ports), and i find two problems with it:

1. After install linux-oracle-jdk, with root user, i type "java -version" command, and  the error msg appears: "libjli.so: cannot open shared object file: No such file or directory". I simply cp this file from jdk directory to  /compat/linux/lib, the problem is solved.

2. when i change user from root to common user,  the "java -version" seems does not work correctly,  and there is no response any more. Could anyone tell me what's the problem, and how to solve it?
Comment 1 Edward Tomasz Napierala freebsd_committer 2020-01-13 12:43:36 UTC
Seems to work here, on 13-CURRENT:

trasz@v2:~ % java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
trasz@v2:~ % /usr/local/linux-oracle-jdk1.8.0/bin/java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

Are you still able to reproduce this?
Comment 2 Petteri Valkonen 2020-10-18 10:08:31 UTC
(In reply to jinlong.hao from comment #0)

For what it's worth, I was experiencing the same symptoms, and allowing unprivileged processes to use process debugging facilities fixed the problem for me.

❯ sysctl security.bsd.unprivileged_proc_debug
security.bsd.unprivileged_proc_debug: 0
❯ /usr/local/linux-oracle-jdk1.8.0/bin/java -version # hangs
^C
❯ doas sysctl security.bsd.unprivileged_proc_debug=1
security.bsd.unprivileged_proc_debug: 0 -> 1
❯ /usr/local/linux-oracle-jdk1.8.0/bin/java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

truss(1) output for a non-priviledged user with 'security.bsd.unprivileged_proc_debug' set to 0 shows an endless loop of "Operation not permitted" errors when trying to open /proc/self/maps:

60130: linux_open("/proc/self/maps",0x0,0666)    = 3 (0x3)
60130: linux_newfstat(3,0x800729d80)             = 0 (0x0)
60130: linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffffffffffff,0x0) = 34366181376 (0x800625000)
60130: read(3,0x800625000,4096)                  ERR#-1 'Operation not permitted'
60130: read(3,0x800625000,4096)                  ERR#-1 'Operation not permitted'
60130: read(3,0x800625000,4096)                  ERR#-1 'Operation not permitted'
60130: read(3,0x800625000,4096)                  ERR#-1 'Operation not permitted'
60130: read(3,0x800625000,4096)                  ERR#-1 'Operation not permitted'
...

With the variable set to 1, /proc/self/maps can be opened (and closed) successfully.

39570: linux_open("/proc/self/maps",0x0,0666)    = 3 (0x3)
39570: linux_newfstat(3,0x800729d80)             = 0 (0x0)
39570: linux_mmap2(0x0,0x1000,0x3,0x22,0xffffffffffffffff,0x0) = 34366181376 (0x800625000)
39570: read(3,"0000000000400000-000000000040100"...,4096) = 4096 (0x1000)
39570: read(3,"    /compat/linux/usr/lib64/libr"...,4096) = 1357 (0x54d)
39570: close(3)                                  = 0 (0x0)