Brijesh's Git Server — network-scan @ 5f24c81efef6551c7737d1bc4c8d73f94f12dc03

utils/sudo-check.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
package utils

import (
	"fmt"
	"os/user"
)

func CheckSudoPrivileges() (bool, error) {
	currentUser, err := user.Current()
	if err != nil {
		return false, fmt.Errorf("error getting current user: %w", err)
	}
	return currentUser.Uid == "0", nil
}