package logic

import (
	"fmt"
	"os"
	"sshd-tool/utils"
)

var (
	NeedExec = []string{"chattr", "lsattr", "clamscan", "clamdscan"}
)

// CheckExec 检查必要的命令是否存在
func CheckExec() error {
	for _, v := range NeedExec {
		if p := utils.FindCmd(v); p == nil {
			return fmt.Errorf("command %s not found", v)
		}
	}
	return nil
}

// CheckRoot 检查是否以root的身份执行
func CheckRoot() bool {
	return os.Getuid() == 0
}
