Prevent setup as root
This commit is contained in:
parent
52156f8892
commit
f224276749
1 changed files with 30 additions and 0 deletions
|
|
@ -4,8 +4,10 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/user"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/quexten/goldwarden/agent/systemauth/biometrics"
|
"github.com/quexten/goldwarden/agent/systemauth/biometrics"
|
||||||
|
|
@ -13,7 +15,20 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func isRoot() bool {
|
||||||
|
currentUser, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("[isRoot] Unable to get current user: %s", err)
|
||||||
|
}
|
||||||
|
return currentUser.Username == "root"
|
||||||
|
}
|
||||||
|
|
||||||
func setupPolkit() {
|
func setupPolkit() {
|
||||||
|
if isRoot() {
|
||||||
|
fmt.Println("Do not run this command as root!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
file, err := os.Create("/tmp/goldwarden-policy")
|
file, err := os.Create("/tmp/goldwarden-policy")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -77,6 +92,11 @@ ExecStart=BINARY_PATH daemonize
|
||||||
WantedBy=graphical-session.target`
|
WantedBy=graphical-session.target`
|
||||||
|
|
||||||
func setupSystemd() {
|
func setupSystemd() {
|
||||||
|
if isRoot() {
|
||||||
|
fmt.Println("Do not run this command as root!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
file, err := os.Create("/tmp/goldwarden.service")
|
file, err := os.Create("/tmp/goldwarden.service")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -125,6 +145,11 @@ var systemdCmd = &cobra.Command{
|
||||||
Short: "Sets up systemd autostart",
|
Short: "Sets up systemd autostart",
|
||||||
Long: "Sets up systemd autostart",
|
Long: "Sets up systemd autostart",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if isRoot() {
|
||||||
|
fmt.Println("Do not run this command as root!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
setupSystemd()
|
setupSystemd()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -134,6 +159,11 @@ var browserbiometricsCmd = &cobra.Command{
|
||||||
Short: "Sets up browser biometrics",
|
Short: "Sets up browser biometrics",
|
||||||
Long: "Sets up browser biometrics",
|
Long: "Sets up browser biometrics",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if isRoot() {
|
||||||
|
fmt.Println("Do not run this command as root!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err := browserbiometrics.DetectAndInstallBrowsers()
|
err := browserbiometrics.DetectAndInstallBrowsers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error: " + err.Error())
|
fmt.Println("Error: " + err.Error())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue