| 30 | #endif |
| 31 | |
| 32 | bool Shell::IsRunningAsAdmin() { |
| 33 | #ifdef WINDOWS |
| 34 | BOOL isAdmin = FALSE; |
| 35 | PSID adminGroup = nullptr; |
| 36 | SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY; |
| 37 | if(!AllocateAndInitializeSid(&ntAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminGroup)) { |
| 38 | spdlog::error("AllocateAndInitializeSid failed. (Code={})", GetLastError()); |
| 39 | return false; |
| 40 | } |
| 41 | if(!CheckTokenMembership(nullptr, adminGroup, &isAdmin)) { |
| 42 | spdlog::error("CheckTokenMembership failed. (Code={})", GetLastError()); |
| 43 | isAdmin = FALSE; |
| 44 | } |
| 45 | if(adminGroup) |
| 46 | FreeSid(adminGroup); |
| 47 | return isAdmin; |
| 48 | #else |
| 49 | return geteuid() == 0; |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | ShellCmdResult Shell::RunCommand(const std::string &cmd) { |
| 54 | /*boost::process::child proc(boost::process::search_path("osascript"), ToDo |
nothing calls this directly
no outgoing calls
no test coverage detected