From 5289cb6b15c134f418d434bf94d1d0d89090ab2b Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 28 Jun 2021 11:55:04 +0200 Subject: [PATCH] helpers.cpp: fix possible crash Possible error is: terminate called after throwing an instance of 'std::logic_error' --- src/system/helpers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index b7a83d78b..ad0712da8 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -469,9 +469,9 @@ bool exec_controlscript(std::string script) bool exec_initscript(std::string script, std::string command, std::string system_command) { - std::string user = getenv("USER"); - if (user != "root") - dprintf(DEBUG_NORMAL, "[helpers] [%s - %d] NOTE: current user is not root!\n", __func__, __LINE__); + const char* user = getenv("USER"); + if (strncmp("root", user, 4)) + dprintf(DEBUG_NORMAL, "[helpers] [%s - %d] NOTE: current user %s is not root!\n", __func__, __LINE__, user); int ret = 1; if (system_command == "service")