Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Failed to allocate closure when SELinux is enabled and non-root user is used

Đang mở
#1,505 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
java

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi trên Amazon Linux 2 với SELinux được bật, dưới tư cách người dùng không phải root, sử dụng JNA 5.13.0 và ví dụ Lazysodium được cung cấp. Truy vết lỗi từ com.sun.jna.Native.registerMethod qua Native.register và xác định tại sao việc cấp phát closure lại khác trong môi trường này. Công việc được xem là hoàn tất khi thư viện native được tải thành công cho cấu hình không phải root bị ảnh hưởng mà không làm suy yếu các cơ chế bảo vệ của SELinux.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

JNA fails to load a native library if SELinux is enabled and I run my code as a non-root user. I tested with Lazysodium for Java, but I don't think that this issue is specific to this particular library only.

Changing the SELinux mode to the permissive doesn't help and there is no record in /var/log/audit/audit.log.

If I run my code as root, the error won't occur. If I disable SELinux and I run my code as a non-root, the error won't occur either.

OS: Amazon Linux 2
System architecture: x86_64
Java: OpenJDK Runtime Environment (build 1.8.0_352-b08)
JNA version: 5.13.0

Stacktrace

Exception in thread "main" java.lang.UnsupportedOperationException: Failed to allocate closure
        at com.sun.jna.Native.registerMethod(Native Method)
        at com.sun.jna.Native.register(Native.java:1906)
        at com.sun.jna.Native.register(Native.java:1775)
        at com.goterl.resourceloader.SharedLibraryLoader.registerLibraryWithClasses(SharedLibraryLoader.java:81)
        at com.goterl.resourceloader.SharedLibraryLoader.load(SharedLibraryLoader.java:58)
        at com.goterl.lazysodium.utils.LibraryLoader.loadBundledLibrary(LibraryLoader.java:134)
        at com.goterl.lazysodium.utils.LibraryLoader.loadLibrary(LibraryLoader.java:95)
        at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:34)
        at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:23)

Steps to reproduce:

import com.goterl.lazysodium.SodiumJava;

public class JnaTest {

    public static void main(String[] args) {
        SodiumJava sodiumJava = new SodiumJava();
    }

}

Dependencies:

<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna</artifactId>
    <version>5.13.0</version>
</dependency>
<dependency>
    <groupId>com.goterl</groupId>
    <artifactId>lazysodium-java</artifactId>
    <version>5.1.4</version>
</dependency>
Ngôn ngữ chính
Java
Star
8.9k
Fork
1.7k
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của java-native-access/jna

Tất cả issue của java-native-access/jna

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.