DistroUtils.hpp

1. Overview

The DistroUtils.hpp file is a Header-only platform detection utility in BastionGuard.

Provides normalized parsing of /etc/os-release, identifies Fedora/RHEL-family systems, and exposes compile-time/runtime checks for Chromium Embedded Framework availability.

The documentation below is generated from the supplied source and covers its API surface, runtime responsibilities, data flow, filesystem or command interactions, concurrency model, and security considerations.


2. Source Inventory

  • Original path: DistroUtils.hpp
  • Language: C++
  • Source type: .hpp
  • Line count: 68
  • SHA-256: db871ebd536175b0ab9018b7cb05305e6cf5e3f798c88ab0229765d513ae6948

3. Dependencies

The file declares the following compile-time dependencies:

C/C++ Runtime

  • algorithm
  • cctype
  • fstream
  • string
  • unordered_map

4. Types and Public Contract

No standalone class, structure, or enumeration is declared directly in this file.

Declared Public Members

  • std::string line;

5. API and Method Inventory

The following functions or methods are implemented in this file:

  • normalize_os_release_value(std::string value) – Removes quotes and lowercases an operating-system release value.
  • read_os_release() – Parses /etc/os-release into a key/value map.
  • is_fedora_rhel_family() – Returns whether the current distribution belongs to the Fedora/RHEL family.
  • cef_supported() – Applies the distribution policy for CEF support.
  • cef_available() – Combines compile-time CEF availability with runtime support policy.

6. Functional Architecture

Operating-System Parsing

  • Reads /etc/os-release line by line and ignores empty lines, comments, and malformed entries.
  • Removes surrounding double quotes and normalizes values to lowercase.
  • Recognizes Fedora, RHEL, AlmaLinux, and Rocky Linux identifiers.

CEF Capability Policy

  • BASTIONGUARD_HAS_CEF defaults to 1 when no build-system value is supplied.
  • cef_supported() disables CEF on the Fedora/RHEL family.
  • cef_available() combines build-time availability with distribution support.

7. Operational Flow

  1. Read key/value pairs from /etc/os-release.
  2. Normalize values for case-insensitive comparison.
  3. Classify the distribution family.
  4. Combine the distribution policy with the build-time CEF capability flag.

8. Filesystem and External Command Surface

Referenced Absolute Paths

  • /etc/os-release

Commands or Security Primitives Referenced

  • sh

9. Concurrency and Lifecycle

The file contains no explicit worker-thread or callback-lifetime mechanism.


10. Security Considerations

  • Distribution detection reads a trusted system file but should tolerate missing or malformed values.
  • Build-time capability flags and runtime distribution policy jointly determine feature exposure.

11. Implementation Considerations

  • This header defines the public or private class contract; behavior is implemented by the matching .cpp file unless marked inline.
  • Because the functions are inline, every consumer compiles its own copy and receives the same platform policy.

12. Licensing and Branding

The source is distributed under the GNU General Public License version 3.

The source header identifies BastionGuard™ as a trademark and states that the name and branding are not licensed under the GPL.

The software is provided without warranty, including implied warranties of merchantability or fitness for a particular purpose.