Table of Contents

Class LinuxConfigHardeningHelper

Namespace
FishMMO.Installer
Assembly
FishMMO-Installer.dll

Shared helpers for reading and atomically writing Linux system configuration files that are owned by privileged users (root, postgres, pgbouncer, ...). All writes go through a temp file in /tmp followed by sudo install -o <owner> -g <group> -m <mode> which provides atomic rename + ownership/mode in a single privileged step.

public static class LinuxConfigHardeningHelper
Inheritance
LinuxConfigHardeningHelper
Inherited Members

Fields

BackupSuffix

Suffix used for the one-time backup of any system configuration file before FishMMO-Installer modifies it.

public const string BackupSuffix = ".pre-fishmmo.bak"

Field Value

string

ManagedMarker

Marker comment string appended to every block this installer adds to a system configuration file, allowing future runs to detect prior edits and stay idempotent.

public const string ManagedMarker = "# fishmmo-managed"

Field Value

string

Methods

EnsureBackupAsync(string)

Creates a one-time backup at path + BackupSuffix owned by the same uid/gid as the original. Returns true if the backup already existed or was created.

public static Task<bool> EnsureBackupAsync(string path)

Parameters

path string

Returns

Task<bool>

SudoInstallAsync(string, string, string, string, string)

Writes content to destinationPath atomically via a temp file and sudo install with the requested ownership and mode.

public static Task<bool> SudoInstallAsync(string content, string destinationPath, string owner, string group, string mode)

Parameters

content string

Full new file contents.

destinationPath string

Destination path (will be overwritten).

owner string

Unix owner (e.g. postgres, root).

group string

Unix group (e.g. postgres, pgbouncer).

mode string

Octal mode string (e.g. 0600, 0640, 0644).

Returns

Task<bool>

SudoReadAsync(string)

Reads a privileged file via sudo cat. Returns null on failure.

public static Task<string?> SudoReadAsync(string path)

Parameters

path string

Returns

Task<string>