From 119c19a9d56a96e4f006cdd3f262b0f7f6ea5678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Ban=CC=83os=20Lo=CC=81pez?= Date: Thu, 5 Apr 2018 17:15:41 +0200 Subject: [PATCH] Fallback check for windows administration rights (issue #34) --- utils/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/config.go b/utils/config.go index 5f92154..0539844 100644 --- a/utils/config.go +++ b/utils/config.go @@ -263,7 +263,7 @@ func (config *Config) evaluateCurrentUser() (*user.User, error) { if runtime.GOOS == "windows" { currUser.Username = currUser.Username[strings.LastIndex(currUser.Username, "\\")+1:] log.Debugf("Windows username is %s", currUser.Username) - config.CurrentUserIsAdmin = (currUser.Gid == "S-1-5-32-544" || isWinAdministrator(currUser.Username)) + config.CurrentUserIsAdmin = (currUser.Gid == "S-1-5-32-544" || isWinAdministrator(currUser.Username) || canPerformAdministratorTasks()) } else { config.CurrentUserIsAdmin = (currUser.Uid == "0" || currUser.Username == "root") } @@ -349,6 +349,15 @@ func isWinAdministrator(user string) bool { user == "imco" } +func canPerformAdministratorTasks() bool { + f, err := os.Open("\\\\.\\PHYSICALDRIVE0") + if err != nil { + return false + } + defer f.Close() + return true +} + // readConcertoURL reads URL from CONCERTO_URL envrionment or calculates using API URL func (config *Config) readConcertoURL() error {