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
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
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
pathstring
Returns
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
contentstringFull new file contents.
destinationPathstringDestination path (will be overwritten).
ownerstringUnix owner (e.g.
postgres,root).groupstringUnix group (e.g.
postgres,pgbouncer).modestringOctal mode string (e.g.
0600,0640,0644).
Returns
SudoReadAsync(string)
Reads a privileged file via sudo cat. Returns null on failure.
public static Task<string?> SudoReadAsync(string path)
Parameters
pathstring