From d7be7d29c28c54e407d38a62430a7d30a5832227 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 28 Jun 2021 23:06:12 +0200 Subject: [PATCH] helpers.cpp: fix possible crash Possible error is: terminate called after throwing an instance of 'std::logic_error' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d9c894a1e35d0fd11944f24cc1554aad9b506198 Author: Thilo Graf Date: 2021-06-28 (Mon, 28 Jun 2021) ------------------ This commit was generated by Migit --- 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 9134a3880..1a0c87a03 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -570,9 +570,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")