fortify: remove systemd check
This is no longer necessary as fortify no longer integrates with external user switchers. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
b48ece3bb0
commit
5d25bee786
@ -39,8 +39,6 @@ type System interface {
|
|||||||
Paths() Paths
|
Paths() Paths
|
||||||
// Uid invokes fsu and returns target uid.
|
// Uid invokes fsu and returns target uid.
|
||||||
Uid(aid int) (int, error)
|
Uid(aid int) (int, error)
|
||||||
// SdBooted implements https://www.freedesktop.org/software/systemd/man/sd_booted.html
|
|
||||||
SdBooted() bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paths contains environment dependent paths used by fortify.
|
// Paths contains environment dependent paths used by fortify.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package linux
|
package linux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
@ -19,9 +18,6 @@ type Std struct {
|
|||||||
paths Paths
|
paths Paths
|
||||||
pathsOnce sync.Once
|
pathsOnce sync.Once
|
||||||
|
|
||||||
sdBooted bool
|
|
||||||
sdBootedOnce sync.Once
|
|
||||||
|
|
||||||
uidOnce sync.Once
|
uidOnce sync.Once
|
||||||
uidCopy map[int]struct {
|
uidCopy map[int]struct {
|
||||||
uid int
|
uid int
|
||||||
@ -90,31 +86,3 @@ func (s *Std) Uid(aid int) (int, error) {
|
|||||||
return u.uid, u.err
|
return u.uid, u.err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Std) SdBooted() bool {
|
|
||||||
s.sdBootedOnce.Do(func() { s.sdBooted = copySdBooted() })
|
|
||||||
return s.sdBooted
|
|
||||||
}
|
|
||||||
|
|
||||||
const systemdCheckPath = "/run/systemd/system"
|
|
||||||
|
|
||||||
func copySdBooted() bool {
|
|
||||||
if v, err := sdBooted(); err != nil {
|
|
||||||
fmsg.Println("cannot read systemd marker:", err)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
4
main.go
4
main.go
@ -277,10 +277,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runApp(config *fst.Config) {
|
func runApp(config *fst.Config) {
|
||||||
if os.SdBooted() {
|
|
||||||
fmsg.VPrintln("system booted with systemd as init system")
|
|
||||||
}
|
|
||||||
|
|
||||||
a, err := app.New(os)
|
a, err := app.New(os)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmsg.Fatalf("cannot create app: %s\n", err)
|
fmsg.Fatalf("cannot create app: %s\n", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user