重构架构
This commit is contained in:
14
internal/middler/auth/auth.go
Normal file
14
internal/middler/auth/auth.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// RequireRoot 检查是否以 root 身份运行
|
||||
func RequireRoot() error {
|
||||
if os.Geteuid() != 0 {
|
||||
return fmt.Errorf("此操作需要 root 权限,请使用 sudo 或切换到 root 用户")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user