Skip to content

Fix Linux installer NetworkManager file URIs#354

Open
Game4Move78 wants to merge 2 commits intoGEANT:masterfrom
Game4Move78:fix-linux-nm-file-uri-nul
Open

Fix Linux installer NetworkManager file URIs#354
Game4Move78 wants to merge 2 commits intoGEANT:masterfrom
Game4Move78:fix-linux-nm-file-uri-nul

Conversation

@Game4Move78
Copy link
Copy Markdown

@Game4Move78 Game4Move78 commented Mar 28, 2026

Summary

Fix the Linux installer template so NetworkManager file URI settings are sent as plain length-delimited D-Bus byte arrays instead of NUL-terminated strings.

Problem

The generated Linux installer currently serializes ca-cert, client-cert, and private-key as dbus.ByteArray(b"file://...\0").
On newer NetworkManager setups this can persist as a %00 suffix in the stored path, which breaks TLS validation during 802.1X authentication.

Changes

  • add a small helper in devices/linux/Files/main.py to build NetworkManager file URI byte arrays without a trailing NUL
  • use that helper for ca-cert, client-cert, and private-key
  • add a PHPUnit regression test that checks the Linux template no longer contains the old NUL-terminated patterns

Testing

  • regression test added in tests/unit/devices/linux/Files/MainPyTemplateTest.php

Copilot AI review requested due to automatic review settings March 28, 2026 18:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the Linux installer template’s NetworkManager 802.1X file URI serialization to use length-delimited D-Bus byte arrays (no trailing NUL), preventing persisted paths with a \0 suffix that can break TLS validation.

Changes:

  • Add __nm_file_uri() helper to build NetworkManager file URI dbus.ByteArray values without NUL termination.
  • Use the helper for ca-cert, client-cert, and private-key settings.
  • Add a PHPUnit regression test ensuring the template no longer contains the NUL-terminated patterns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
devices/linux/Files/main.py Introduces __nm_file_uri() and updates NM settings to avoid NUL-terminated file URI byte arrays.
tests/unit/devices/linux/Files/MainPyTemplateTest.php Adds regression coverage by asserting the template contains the helper and omits the old \0-terminated patterns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to +35
$template = file_get_contents(__DIR__ . '/../../../../../devices/linux/Files/main.py');

$this->assertStringContainsString(
'def __nm_file_uri(path: str) -> dbus.ByteArray:',
$template
);
$this->assertStringContainsString(
'return dbus.ByteArray(f"file://{path}".encode())',
$template
);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file_get_contents() can return false if the relative path changes or the file is missing, which would cause a type error in the subsequent assertString* calls and make the test failure harder to diagnose. Consider asserting the file exists and/or that $template !== false before running string assertions (and optionally include a failure message with the resolved path).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants