feat: check sudo privileges
This commit is contained in:
parent
fd218d4cec
commit
1a26c52816
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
11
src/utils.go
11
src/utils.go
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue