CryptTabEntry

1. Overview

The CryptTabEntry module provides crypttab parsing and serialization for BastionGuard Backup. It models entries from Linux crypttab files, preserves comments when requested, manages option lists, and resolves entries by filesystem UUID.

The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.


2. Dependencies and Integration

The module imports:

  • TeeJee.Logging
  • TeeJee.FileSystem
  • TeeJee.JsonHelper
  • TeeJee.ProcessHelper
  • TeeJee.GtkHelper
  • TeeJee.System
  • TeeJee.Misc

Key runtime integrations include:

  • Gee – typed lists, maps, queues, or collection operations

3. Declared Types

3.1 CryptTabEntry

public class CryptTabEntry : GLib.Object

This class encapsulates the state and operations described by this source file.


4. State, Properties, Constants, and Signals

Public and protected state

  • public bool is_comment – Boolean state controlling or reporting comment.
  • public bool is_empty_line – Boolean state controlling or reporting empty line.
  • public string mapped_name – Name or identifier for mapped name.
  • public string device_string – Runtime state used by the module.
  • public string keyfile – Runtime state used by the module.
  • public string options – Runtime state used by the module.
  • public string line – Runtime state used by the module.
  • public string device_uuid – Runtime state used by the module.

5. Public API and Operational Methods

5.1 read_file()

public static Gee.ArrayList<CryptTabEntry> read_file(string file_path)

Parses a crypttab-compatible file line by line, preserving comments and empty lines as explicit entry objects.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

5.2 write_file()

public static string write_file(Gee.ArrayList<CryptTabEntry> entries, string file_path, bool keep_comments_and_empty_lines = true)

Serializes crypttab entries, optionally retains comments and blank lines, and writes the resulting text to the requested path.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

5.3 append_option()

public void append_option(string option)

Implements the append option operation for this module.

5.4 remove_option()

public void remove_option(string option)

Removes option and reports whether cleanup completed successfully.

5.5 find_entry_by_uuid()

public static CryptTabEntry? find_entry_by_uuid( Gee.ArrayList<CryptTabEntry> entries, string uuid)

Searches for entry by uuid and returns the matching object or value.


6. Operational Flow

  1. Read or discover source data and normalize it into the module data model.
  2. Apply the requested operation and update runtime or persistent state.
  3. Finalize the operation and release files, mounts, child processes, widgets, or cached state.

7. Error Handling and Diagnostics

  • Boolean, nullable, or empty-string return values communicate recoverable failures to callers.

8. Runtime and Security Considerations

  • Persistence: direct JSON writes may benefit from temporary-file and atomic-rename handling when configuration integrity is critical.
  • Shared state: static caches and global switches are shared by all callers and are not automatically thread-isolated.
  • Privilege and cleanup: mount or encryption operations should always pair successful setup with deterministic unmount or lock cleanup.

9. Licensing

The source is distributed under the GNU General Public License version 2 or any later version.

The source header identifies:

Copyright 2016 Tony George &lt;teejeetech@gmail.com&gt;