Skip to content

Show a SELinux hint when Java execution is blocked #3227

Description

@vitormattos

Problem

LibreSign detects when Java exists but cannot be executed from the web-server/PHP process.

Currently, JavaSetupCheck returns a generic error when java -version produces no output.

This problem was originally investigated in #2327 on AlmaLinux, where Java worked from the CLI but failed in the Apache/PHP-FPM context due to SELinux restrictions.

Upstream status

SELinux detection is already implemented in LibreSign/whatosami.

The library provides OperatingSystem::getSELinuxStatus() with four possible states:

  • SELINUX_ENFORCING
  • SELINUX_PERMISSIVE
  • SELINUX_UNAVAILABLE
  • SELINUX_UNKNOWN

Remaining integration prerequisite: LibreSign still bundles an older WhatOSAmI version through LibreSign/3rdparty.

Maintainers will handle making the updated dependency available in LibreSign. This packaging work is not part of the contributor's implementation scope.

Goal

Provide a helpful SELinux-specific diagnostic when Java cannot execute in the web-server context and SELinux is enforcing.

SELinux should be presented as a possible cause, not a confirmed diagnosis.

What to change

Update lib/SetupCheck/JavaSetupCheck.php to:

  1. Detect Java execution failures using the existing execution check.
  2. Query SELinux status through the WhatOSAmI API.
  3. When SELinux is enforcing, display a troubleshooting tip about checking SELinux audit logs.
  4. For other SELinux states, preserve generic Java execution diagnostics.
  5. Preserve existing behavior for successful execution, missing binaries, incompatible versions, and integrity validation failures.

Consider both empty execution output and non-zero exit codes while keeping the existing error handling consistent.

Suggested message

Error:

Failed to execute Java.

Tip when SELinux is enforcing:

SELinux is enforcing and may be blocking Java execution by the web server. Check the SELinux audit logs for relevant denied operations.

Do not recommend disabling SELinux or automatically changing security policies.

Acceptance criteria

  • The upstream SELinux status API is implemented in WhatOSAmI.
  • The upstream GitHub release containing the API has been published.
  • The updated WhatOSAmI dependency is available in LibreSign's bundled dependencies.
  • JavaSetupCheck consumes the SELinux status API.
  • Java execution failures produce a SELinux-specific troubleshooting tip when SELinux is enforcing.
  • Permissive, unavailable, and unknown SELinux states preserve generic diagnostics.
  • Unrelated Java setup checks retain their existing behavior.
  • LibreSign does not read SELinux system files directly.
  • LibreSign does not execute SELinux detection commands or modify SELinux policies.
  • Unit tests cover enforcing and non-enforcing cases, including relevant Java execution failure paths.
  • New translatable messages use IL10N::t() with appropriate TRANSLATORS comments.
  • Focused unit tests pass.

The upstream release and dependency packaging criteria are maintained separately from the contributor's implementation work.

Good first issue

This is a focused PHP backend contribution.

Starting points:

  • lib/SetupCheck/JavaSetupCheck.php
  • tests/php/Unit/SetupCheck/JavaSetupCheckTest.php

The existing tests already provide mocks for Java execution and filesystem behavior.

Add focused tests using controlled SELinux states. Tests should not depend on the host operating system or require an SELinux-enabled environment.

Suggested validation:

composer test:unit -- --filter JavaSetupCheckTest

Out of scope:

  • Updating or repackaging third-party dependencies.
  • Changing installers or dependency providers.
  • Modifying SELinux configuration or policies.
  • Modifying the PHP Native or JSignPdf signing engines.
  • Refactoring unrelated setup checks.

Target branch: main.

Related issues

Additional context

  • If you have questions, feel free to ask in this issue.
  • See our development workflow.
  • Give a ⭐️ star to this repository if you find LibreSign useful and would like to support the project.
  • You can also join our community: https://t.me/LibreSign

Activity

  1. changed the title [-]Check how we can identify if has problem at SELinux side[/-] [+]Detect SELinux-related dependency failures and provide setup guidance[/+] on Sep 20, 2026
  2. changed the title [-]Detect SELinux-related dependency failures and provide setup guidance[/-] [+]Show a SELinux hint when Java execution is blocked[/+] on Sep 20, 2026
  3. Derick-Andres commented on Oct 27, 2026

    @Derick-Andres

    Hi!
    I'd like to contribute to this issue!
    I'm still new to contributing to open-source projects and learning about the community workflow works, but I'd love to give this a try.
    If someone else wants to work on it or picks it up before me, that's totally fine!

    Any guidance would be appreciated. Thanks!

  4. vitormattos commented on Oct 29, 2026

    @vitormattos
    MemberAuthor

    Hi @Derick-Andres!

    Thanks for your interest in contributing! This issue is still available, and you're welcome to work on it.

    We have some good news regarding the prerequisite: SELinux status detection was implemented in LibreSign/whatosami#3, and a new upstream release, v0.1.0, has been published.

    LibreSign still needs to update its bundled 3rdparty dependency to include the new API. We'll handle that separately, so you don't need to update the dependency yourself.

    Where to start:

    1. Review lib/SetupCheck/JavaSetupCheck.php, especially the existing java -version execution check.
    2. Look at tests/php/Unit/SetupCheck/JavaSetupCheckTest.php. It already provides execution mocks and related unit tests.
    3. Use the WhatOSAmI getSELinuxStatus() API to display a specific troubleshooting tip when Java execution fails and SELinux is enforcing.
    4. Preserve generic diagnostics for other SELinux states and add focused tests for these scenarios.

    One important detail: SELinux being in enforcing mode doesn't prove that it caused the execution failure. The message should suggest checking SELinux audit logs, not present SELinux as the confirmed cause.

    Please keep the changes focused on diagnostics. There's no need to modify SELinux policies, installers, or signing engines.

    You can start exploring the code and preparing your changes now. Final integration and validation will depend on the updated bundled dependency.

    Our development workflow explains how to prepare and submit pull requests. Please target main.

    Feel free to ask questions here if anything is unclear!

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

Metadata

Metadata

Assignees

Labels

backendBackend workgood first issueGood for newcomersphpWork involving PHP code

Fields

Priority

None yet

Start date

None yet

Target date

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions