helpers.cpp: fix possible crash

Possible error is:
terminate called after throwing an instance of 'std::logic_error'
This commit is contained in:
2021-06-28 11:55:04 +02:00
parent c5d977cd63
commit 5289cb6b15

View File

@@ -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")