diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-27 12:08:17 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-27 12:09:34 +0900 |
| commit | 7df9d8d01dadcb05396d278aba11afc2ab4a2328 (patch) | |
| tree | 9114e61306153b50b2def1ab6f817af49e266427 /internal/early.go | |
| parent | 6d8bcb63f28fb289aef8d4b702d7d938ac0af4eb (diff) | |
system: move sd_booted implementation to os abstraction
This implements lazy loading of the systemd marker (they are not accessed in init and shim) and ensures consistent behaviour when running with a stub.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/early.go')
| -rw-r--r-- | internal/early.go | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/internal/early.go b/internal/early.go deleted file mode 100644 index 81ca49cd..00000000 --- a/internal/early.go +++ /dev/null @@ -1,35 +0,0 @@ -package internal - -import ( - "errors" - "io/fs" - "os" - - "git.ophivana.moe/security/fortify/internal/fmsg" -) - -const ( - systemdCheckPath = "/run/systemd/system" -) - -var SdBootedV = func() bool { - if v, err := SdBooted(); err != nil { - fmsg.Println("cannot read systemd marker:", err) - return false - } else { - return v - } -}() - -// SdBooted implements https://www.freedesktop.org/software/systemd/man/sd_booted.html -func SdBooted() (bool, error) { - _, err := os.Stat(systemdCheckPath) - if err != nil { - if errors.Is(err, fs.ErrNotExist) { - err = nil - } - return false, err - } - - return true, nil -} |
