feat: check sudo privileges

This commit is contained in:
Haletran 2026-03-30 17:47:37 +02:00
parent fd218d4cec
commit 1a26c52816
3 changed files with 14 additions and 0 deletions

View file

@ -12,6 +12,7 @@ Package Manager made in Go
- [ ] Rootless install (use install path from global var instead of typing one in the lua script)
- [ ] Online Database of the packages
- [ ] Keep track of installed packages
- [ ] Add database change like you can add multiple sources like a real pm
### Source

View file

@ -14,8 +14,10 @@ func command_parser(command_args []string) {
}
switch command_args[1] {
case "install":
isRoot() // might need to check later if rootless install
InstallCommand(command_args[2])
case "uninstall":
isRoot()
UninstallCommand(command_args[2])
case "search":
SearchCommand(command_args[2])

View file

@ -8,9 +8,20 @@ import (
"log"
"net/http"
"os"
"os/user"
"strings"
)
func isRoot() bool {
currentUser, _ := user.Current()
if currentUser.Username != "root" {
fmt.Println("Need superuser privileges")
os.Exit(1)
return false
}
return true
}
func ChangePermisions(source string, perms os.FileMode) {
fileInfo, err := os.Stat(source)
if err != nil {