From ef0adeb7218e321ec80bda97db90f547d2ebc85d Mon Sep 17 00:00:00 2001 From: Pcornat Date: Sun, 21 Mar 2021 22:09:23 +0100 Subject: [PATCH] Security about the user --- main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index ed9dcdf..436699c 100644 --- a/main.cpp +++ b/main.cpp @@ -11,6 +11,12 @@ int main(int argc, char *argv[]) { auto logger = spdlog::stdout_color_st("single_log"); spdlog::set_default_logger(logger); + // If the user si root, stop the program + if (getuid() == 0) { + spdlog::error("The user is root. Stopping the program."); + return EXIT_FAILURE; + } + po::options_description description{ "Allowed options" }; description.add_options()("help", "produce help message")("config", po::value(), "path to the config file"); po::variables_map vm;