Repair Permissions

SolidGroundUX DocumentationSolidGroundUX
NL

Apply declared ownership and permission rules to files and directories.

Source: target-root/usr/local/libexec/solidgroundux/sgnd-repair-permissions.sh

Apply declared ownership and permission rules to files and directories.

Public functions

Internal functions
FunctionPurposeArgumentsOutput
_trimTrim leading and trailing whitespace.- $1 — Text to trim.Trimmed text on stdout.
_init_defaultsResolve the default permission policy below the framework shared-data root.——
_resolve_operatorResolve the symbolic permission-policy identity "operator".——
_resolve_identityTranslate the symbolic value "operator" or preserve an explicit identity.- $1 — Raw owner/group value.Resolved identity on stdout.
_resolve_target_pathMake one policy file usable for both staged target-root trees and live systems.- $1 — Absolute target path or path relative to SGND_FRAMEWORK_ROOT.Resolved absolute target path on stdout.
_validate_modeValidate an octal permission mode.- $1 — Permission mode.—
_apply_target_permissionsApply one already-resolved permission rule to a single filesystem object.- $1 — Type: d for directory or f for regular file.—
_apply_policy_rowApply an exact target rule or an explicitly masked child selection.- $1 — Type: d for directory or f for regular file.—
_apply_policy_fileApply every active permission rule from one PSV policy file.- $1 — Policy file path.—

Description

Reads a pipe-separated permission policy file and applies the declared owner, group, and mode to each target. Relative target paths are resolved below the active SolidGroundUX framework root so the same policy can be used in staged development trees and on installed systems.

By default a policy row affects only its exact target. An optional filemask extends the rule below a directory: * selects all immediate children, ** selects all descendants recursively, and any other shell-style glob (for example sgnd-*) selects matching immediate children. The declared type still filters directories (d) from regular files (f).

Exact directory records create the directory when it is missing. File records and masked roots are never invented; missing objects are reported instead.

Design principles

  • Permission policy is declarative and external to the executable.
  • Permission changes are non-recursive unless a policy row explicitly uses **.
  • Named filemasks such as sgnd-* are limited to immediate children.
  • Recursive selection never follows symbolic links outside the declared tree.
  • The symbolic owner/group value "operator" resolves to the invoking sudo user.
  • Missing or invalid policy data fails visibly instead of being guessed.
  • Dry-run reports intended changes without modifying the filesystem.

Role in framework

  • Repairs runtime-writable ownership after root-owned installation or update work.
  • Provides one reusable implementation for sgnd-setup and Management Console actions.

Non-goals

  • Implicit or unrestricted recursive permission changes.
  • Following symbolic links while expanding masked selections.
  • Creating missing regular files or masked search roots.
  • Inferring ownership or modes that are not declared in the policy file.

Usage

Run the executable from its shell command (or installed wrapper):

sgnd-repair-permissions
sgnd-repair-permissions --file /path/to/permissions.dta
sgnd-repair-permissions --dryrun

Script-specific options:

  • --file VALUE, -f: Permission policy file; defaults to SGND_SHARE_DIR/permissions.dta.