From 86d30a4740af5aaeca80b41577e33bb127e25725 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 30 Jun 2021 09:45:35 +0200 Subject: [PATCH] heipers.cpp: use getuid() instead getenv() Enabled only on generic hardware. Thanks seife for hint. --- src/system/helpers.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index ae0915f58..aee41a5ff 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -469,13 +469,10 @@ bool exec_controlscript(std::string script) bool exec_initscript(std::string script, std::string command, std::string system_command) { - const char* user = getenv("USER"); - if (user != NULL) - { - if (strncmp("root", user, 4)) - dprintf(DEBUG_NORMAL,"[helpers] [%s - %d] NOTE: current user %s is not root!\n", __func__, __LINE__, user); - } - +#if HAVE_GENERIC_HARDWARE + if (getuid()) + dprintf(DEBUG_NORMAL,"[helpers] [%s - %d] WARNING: current user is not root!\n", __func__, __LINE__); +#endif int ret = 1; if (system_command == "service") {