module

Fluxion::Executor::Sudo

Rewrites privileged commands and resolves their targets.

Two rules, both about not trusting PATH for anything that runs as root:

  • A privileged effect always becomes sudo -n -- <target> .... -n means it can never sit waiting for a password on a terminal nobody is watching; authentication happens once, up front, through the preflight.
  • The target is resolved to a real path under a root-owned system directory. Otherwise a writable directory earlier on PATH would decide what runs as root.

Constants

SUDO_PATHS = ["/usr/bin/sudo", "/bin/sudo"]
SYSTEM_DIRECTORIES = ["/usr/bin", "/usr/sbin", "/bin", "/sbin"]

Directories trusted to hold executables Fluxion will run as root.

Instance methods

available?
Source
executable
Source
for_effect(argv : Array(String)) : Array(String)

Turns a sudo ... marker into the command actually executed.

Source
invalidate_argv

Drops the cached credential at the end of a run.

Source
invocation?(argv : Array(String)) : Bool
Source
resolve(name : String) : String

Resolves an executable to a real path Fluxion is willing to run as root.

Refuses anything outside the system directories, anything not owned by root, and anything group- or other-writable — including every directory on the way to it, since a writable parent means the file can be swapped.

Source
validate_argv

Confirms sudo is usable without prompting. Run once before any mutation.

Source
validate_with_password_argv

Validates a password read from the user, with the prompt suppressed because Fluxion has already drawn its own.

Source