introduce basic fact collection
This commit is contained in:
@@ -4,13 +4,31 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
|
||||
"git.dubyatp.xyz/orphanage/client/server"
|
||||
)
|
||||
|
||||
func check_superuser() bool {
|
||||
current, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if current.Uid != "0" {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func run(ctx context.Context, w io.Writer, args []string) error {
|
||||
if !check_superuser() {
|
||||
log.Fatal("orphan must run as superuser")
|
||||
}
|
||||
|
||||
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
|
||||
defer cancel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user